As a filmmaker, Emilio Estevez is the most sincere kid in the pumpkin patch, with never a hint of cynicism — and he wears his heart proudly on his sleeve in “The Public,” an earnest comedy-drama about people looking out for their fellow humans.

Estevez stars in this movie, which he wrote and directed, inspired by a 2007 essay by Chip Ward, a now-retired Salt Lake City librarian who wrote plainly and eloquently about how public libraries have become de facto shelters for the homeless. That germ of an idea infuses itself in the story of a librarian who is embroiled in a standoff between homeless patrons and the police.

Estevez plays librarian Stuart Goodson, who encounters these homeless men and women every day at The Public Library in Cincinnati (where the movie was filmed). Stuart’s job requires him to deal with the most unruly of the homeless, which he does good-naturedly when possible.

Stuart is juggling a lot, from a junior librarian, Myra (Jena Malone), who wants to transfer to a different floor, to his boss, Mr. Anderson (Jeffrey Wright), who warns him that the board wants to fire him — because he removed a homeless patron for having bad body odor, an incident that led to a large lawsuit against the city.

One winter night, the chronically homeless who spend their days in the library decide they’re not going to leave at closing time. Led by Jackson (Michael Kenneth Williams), a veteran caught in hard times, the patrons stage a 1960s-style sit-in, barricading themselves — along with Stuart and Myra — on one floor of the library. Stuart sides with Jackson and the other homeless patrons for a very understandable reason: Once upon a time, he was one of them.

What follows is a standoff between the homeless people inside the library and the police outside, with Det. Bill Ramstead (Alec Baldwin) working as a negotiator. Also on the outside is Josh Davis (Christian Slater), a slick prosecutor running for mayor on a law-and-order platform, who suggests the cops end the standoff by lobbing some tear gas into the library.

Also factoring into Estevez’s story are Angela (Taylor Schilling), who manages Stuart’s apartment building and may become a romantic interest, and Rebecca Parks (Gabrielle Union), a TV reporter who labors to fit the homeless patrons’ plight into a pre-fab news narrative.

It’s hard not to make comparisons between “The Public” and the greatest of all hostage dramas, Sidney Lumet’s “Dog Day Afternoon.” Estevez, as writer and director, strikes a lighter tone than that Al Pacino classic, but he mines the same vein of absurdity in the discord between two sides, each not understanding the other.

Estevez gathers a strong ensemble cast, with some fascinating standouts. Williams gives a soulful turn as Jackson, trying to squeeze out a little recognition and dignity despite his current circumstances. The hip-hop artist Rhymefest is sympathetic as Big George, a homeless man battling internal demons. And Baldwin, working out his dramatic side for the first time in ages, is powerful as a cop whose personal life — we’re told early that Ramstead’s drug-addicted son is living on the streets — both informs and hamstrings his efforts to bring about a truce.

The gentle humor and simple humanity of Estevez’s script helps the audience digest the messages within “The Public,” to engender sympathy for our nation’s homeless and sing the praises of libraries. When, at one point, Stuart quotes John Steinbeck’s “The Grapes of Wrath” to Union’s reporter character, he tells his boss, Anderson, “I wish they were my words.” Anderson replies, “They are your words. Yours, mine, theirs, all of ours.” That line, like most of “The Public,” is a heartfelt reminder that libraries are keepers of our democracy’s collective soul.

——

★★★

‘The Public’

Inspired by a Salt Lake City librarian’s essay, director-writer-star Emilio Estevez tells an earnest story of homeless patrons finding shelter in an American public library.

Where • Broadway Centre Cinemas (Salt Lake City), Megaplex Jordan Commons (Sandy), AMC West Jordan 12 (West Jordan).

When • Opens Friday, April 5.

Rated • PG-13 for thematic material, nudity, language, and some suggestive content.

Running time • 122 minutes.