On November 23, 2023 12:11:08 p.m. MST, ron minnich rminnich@gmail.com wrote:
I believe Max was proposing to use spaces for makefile syntax control flow, not tabs. That seems like it would work, I've seen it done on other projects.
I did try this out the other day and it does seem to work, but I think the point Felix was making was that having tabs for indenting some things (shell syntax in recipes) and spaces for indenting other things (visual indents of Makefile syntax) sounds like a bad idea. In most other contexts you don't need to worry about the exact type of whitespace, as it only serves one purpose. For instance, in languages like C, whitespace is purely visual, and most projects stick to only one of tabs or spaces for discrete indentation levels. In languages like Python, whitespace serves the functional purpose of separating blocks of code (similar to curly braces in C), which also doubles as a visual indent. Generally you also only stick to one of either tabs or spaces. In the Makefile case the type of whitespace actually matters, where one type is used functionally and the other is used visually. That said, I think make is pretty good at erroring on invalid indentations (you can't use spaces to indent a make recipe after a target, only tabs) so perhaps it isn't too bad. It's probably the sort of thing where you'd want your editor to display tabs and spaces with a visual character.
On Thu, Nov 23, 2023 at 10:26 AM Felix Held felix-coreboot@felixheld.de wrote:
Hi,
the odd thing about Makefiles is that those use two different syntax': Everything that's indented by a tab is shell syntax and everything else is Makefile syntax. So we can't just indent the Makefile syntax part with tabs to make it look nicer and mixing tabs and spaces which do different things here if I'm not mistaken doesn't sound too good to me either. I'd say that we should add some comments to the else and endif to point out to which ifeq/ifneq those belong in cases where there are multiple nested if(n)eq or where the else/endif is far away from the if(n)eq. Separating unrelated if(n)eq blocks by a newline also helps a bit. Maybe there's a better way that I'm not aware of though.
Regards, Felix
On 23/11/2023 02:51, Maximilian Brune wrote:
Hi
Reading Makefiles especially in big projects like coreboot is a constant. pain. One of the big issues is that conditionals are very hard to read since we cannot use tabs for indentation. Has anyone ever thought about using whitespaces as indentation for conditionals in our Makefiles or is that connected to known problems?
greetings Max
coreboot mailing list -- coreboot@coreboot.org To unsubscribe send an email to coreboot-leave@coreboot.org
coreboot mailing list -- coreboot@coreboot.org To unsubscribe send an email to coreboot-leave@coreboot.org
Nicholas