Tabs and Makefile (2015)
beebo.org
beebo.org
I for one was eternally flustered as a new programmer in college trying to edit Makefiles with the tools that I felt comfortable with and that were available to me. The tab/space debacle is a completely unnecessary footgun, even worse than the various atrocities of variable assignment spacing and test bracket spacing in `sh`. I am grateful for Make to exist in that it is an important part of the history of Unix and software development, but would rather not use it if given the option.
I for one graciously accept Stuart Feldman's apology.
C begot Unix
Unix begot Make
And Make begot the 10_000 thingsThis is not something I'd be proud to announce or expect well-configured cooling showers of sympathy.
As a developer or sysadmin, among the problems I have to solve every random hour of every day, this one rates all the way up there with the printer being across the room.
I'm in the tabs for indentation camp, but even I was a little surprised by this, as I had always assumed the semantics were to match and strip whatever leading whitespace was found on the first line. When I emulate this feature in other languages (e.g. heredoc function in tandem with a language's multiline string quotation), that's the semantic I employ, even though in my own code that leading whitespace will invariably be all tabs.
I should add that learning make well has been a great boon for my career. It's an incredibly powerful and elegant tool, assuming your project can inhabit the subset of projects that will never, ever have paths containing spaces.
If you let Make accept spaces then there’s no backwards compatible way for it to tell the difference.
You can change the behavior of make to allow a different character to be used before recipes, but then it’s not backwards compatible with other files.
"Rules start with non-whitespace"?
nonws:
<tab>echo nonws
ws:
<tab>echo wsWell, that's stupid.
And it's news to me. I have never seen a makefile that actually did this. So you could still fix the problem and be backwards-compatible for probably 99% of actual cases. And you could provide a --stupid-whitespace-mode flag for non-backwards-compatible makefies.
Honestly, I still see no legitimate reason to continue this insanity.
ifdef (something,something)
rule:
something specific recipe
else
rule:
common recipe
endif
It's also not just rules. Variable assignments are also separate from recipes, and can be indented with spaces. ifdef (something)
CFLAGS=something
else
CFLAGS=otherthing
endif"At least, I’m pretty sure how things happened, but Wikipedia is inconclusive. Does anyone know?"
What specifically about the linked Wikipedia article are they confused about and how is it inconclusive on that issue?
What could go wrong?
* this may be a gnu extension, not sure. I did test it once and it works perfectly.
As noted somewhere else in this thread, this would essentially assume you don't have job names beginning with whitespaces, and that's the compatibility bit you're losing, but hey exactly why would you have a job named ' fdsfgs' in your Makefile.
Another caveat is that whitespace-Makefiles will be supported by new versions of make only. Well, if you expect your Makefile to be called by a 40 y. o. box running UNIX that can't get a new version you'll have to stick to tabs.
https://www.gnu.org/software/make/manual/html_node/Special-V...
Tell me that your editor has bad defaults and you don't know how to configure it without telling me that your editor has bad defaults and you don't know how to configure it.
I can't understand how that still gets always claimed. I can't remember when editors got clever enough to show whitespace with distinct features but Eclipse had that, so at least early 2000s?
Fun fact, on the homepage of Apache Ant, there was for years the paragraph that one reason for its existence was due to the author not being able to handle tabs in Makefiles.
> Makefiles are inherently evil as well. Anybody who has worked on them for any time has run into the dreaded tab problem. "Is my command not executing because I have a space in front of my tab!!!" said the original author of Ant way too many times. Tools like Jam took care of this to a great degree, but still have yet another format to use and remember.
https://web.archive.org/web/20100203102803/http://ant.apache...
Talk about a badly configured editor...
Naturally vi had that as well.
There may be some people for whom this is always true, but it is not everyone. There are plenty of people who don't use heavyweight IDEs, or debug stuff on remote servers, etc... And often, those same people decide which build system to use.
No, usually.
It's not like it's impossible to work with semantic tabs on an editor that doesn't distinguish, it's just slightly more of a pain to debug.
And it's still much less of an issue than common fonts making 0 and O or l and I and 1 look alike.