In some ways, “Machete” is what “The Expendables” would have been if “The Expendables” had been written and directed by someone with a sense of humor, i.e., not Sylvester Stallone. Both films are self-conscious throwbacks to bygone genres; part of the problem with Stallone’s movie is that it wasn’t self-conscious enough. I loved what Anthony Lane said about it in The New Yorker: “You might expect, given the title, a few shafts of irony or pathos to be leveled at this symposium of has-beens, but … Stallone seems genuinely to believe that he is dealing in still-cans.”

Robert Rodriguez is much more eager to embrace the camp value of the ultra-violent B-movies of yesteryear. “Machete,” which he co-wrote with his cousin Alvaro Rodriguez and co-directed with editor Ethan Maniquis, is an enthusiastic and affectionate exploitation flick, a movie that is fully aware of (and delighted by) its own absurdity. The story is updated for 2010, but the style and tone — minus the irony — would have been at home in a greasy Times Square-adjacent theater in the early ’70s.

“Machete” began as a fake trailer attached to Rodriguez and Quentin Tarantino’s “Grindhouse” double feature in 2007, advertising the sort of film you’d expect to see advertised at an actual grindhouse. (“If you’re going to hire Machete to kill the bad guy, you better make damn sure the bad guy isn’t you!” was a typically clunky line of narration.) The level of violence and sleaze promised by such movies was so ludicrously high that they either had to be works of pure innocence, made by earnest but clumsy filmmakers attempting to produce legitimate action dramas — or else works of pure calculation, designed to tap into, take advantage of, and perhaps even mock the audience’s lust for extremes.

Rodriguez’s movie is the calculated kind, of course, and he’s walking a line trod just two weeks ago by Alexandre Aja and “Piranha”: the line between reveling in irony as you make something deliberately “bad,” and using irony as an excuse to not have to make something better. “Machete” is much more successful at finding the balance. Plenty of the characters, dialogue, and performances are interesting in their own right, even outside the context. I suspect you could get a kick out of this even if you’ve never seen the type of movie it’s emulating.

Danny Trejo, an actor whose distinctive face is most charitably described as “full of character,” plays Machete, a Mexican federal agent whose insistence on being the only Mexican federal agent who can’t be bribed has put him at odds with the leader of a drug cartel. (This drug lord, Torrez, is played by Steven Seagal, a felicitous bit of casting made even better by Seagal’s willingness to go along with the joke.) Now working as a common day-laborer in Texas, Machete is hired by a shady fellow (Jeff Fahey) to assassinate a state senator (Robert De Niro) running for reelection on an anti-immigrant platform. But Machete is double-crossed, framed for something he didn’t do, and must prove his innocence. This will require killing a lot of people.

With the United States currently embroiled in a heated immigration debate, “Machete” could hardly have come at a more opportune time. But like its exploitative forefathers, it has no interest in nuance or subtlety. The state senator and his militia-leading friend (played by Don Johnson) aren’t just racist crackers — they actually hunt Mexicans for sport. The lines are drawn very clearly in a movie like this. The bad guys are REALLY bad. Complex issues like immigration reform are, like everything else in the movie, outrageously oversimplified to maximize the entertainment value.

The cast also includes Jessica Alba as an immigration officer, Michelle Rodriguez as a taco-cart proprietor who helps a network of illegal aliens defend themselves against the vigilantes, and Lindsay Lohan as a drugged-up skank with ties to the senator. All three give laughably flat performances, just like many of the beautiful actresses in the B-movies Rodriguez is imitating. The only question is whether Rodriguez specifically directed them to act that way, or whether he cast them in the first place because he knew that’s what he would get. He also cast Cheech Marin as Machete’s priest brother, but Cheech clearly knows what he’s doing.

It’s impressive that Rodriguez and company keep this from turning into a one-joke affair. The outlandish violence is a constant (including an intestine-based stunt that I know I’ve seen in an “Itchy & Scratchy” cartoon), but that’s buoyed by political satire, politically incorrect satire, and general comic mania. Like last year’s tragically under-seen “Black Dynamite,” which it resembles, “Machete” is brimming with infectious energy — a well-made movie in the style of poorly made movies.

B+ (1 hr., 45 min.; R, abundant harsh profanity, abundant graphic violence, some sexuality, a lot of nudity.)