LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 07-05-2009, 02:50 PM   #1
JimHughen
Member
 
Registered: Jun 2009
Location: Austin, Texas
Distribution: Ubuntu
Posts: 44

Rep: Reputation: 16
Wink TABs in Makefile


Why are TAB characters absolutely necessary in Makefile?

For me a TAB character is "non-printable" and therefore should not be used in source files (and Makefile). Same thing with trailing space lines...

If the make utility was modified to allow space(s) or TAB(s) for all separators, there is no side effect and backwards compatibility is not affected. So the only, apparent, reason for the absolute requirement to use TAB's looks like the TAB police.

This does bode very well for Linux. Looks like there may be some fanatics in here...

Any thoughts?
...Jim Hughen
 
Old 07-05-2009, 03:18 PM   #2
JimHughen
Member
 
Registered: Jun 2009
Location: Austin, Texas
Distribution: Ubuntu
Posts: 44

Original Poster
Rep: Reputation: 16
sorry...
This does not bode well for Linux.
 
Old 07-05-2009, 03:41 PM   #3
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
They're necessary because they are part of the syntax.

But, what can this possibly have to do with the linux kernel? This post/mini-rant should really be in non-*Nix General as it really has nothing to do with linux.
 
Old 07-05-2009, 06:42 PM   #4
JimHughen
Member
 
Registered: Jun 2009
Location: Austin, Texas
Distribution: Ubuntu
Posts: 44

Original Poster
Rep: Reputation: 16
The Linux kernel requires Tab characters to be used in source files.
However, the gcc compiler will accept spaces or tabs as equivalent white space.

I had hoped this would not be ranting, but it surely is a mini-rant (I suppose).

Tab usage is only required (by the tool) in this one place. To make gcc require tabs would probably contradict K&R or other C standards about white space.

The syntax of 'make' could just as well been "white space" instead of "tab" only. Then white space and source file 'rules' processing could be done uniformly either way. Because the 'make' tool requires the 'tab' character, any source processing that expands tabs will not work on Makefile.

This is surely a small point.
I have seen C source files that are difficult to read because the use of TABs and spaces has been mixed from different developers working on the source. Once the reader get the correct number of tab spaces set for the source display, the code reads ok. C source code readability seems very important to the quality of the C program. Tabs in source code may be a usage that facilitates code entry, etc. There are times, however, when it confuses clarity in reading.

Oh well, I love to read your code, even if tabs are in it. I hope to write some Linux kernel code, and I will use tabs, because I appreciate the great value that coding standards/uniformity gives to our programs.

Linux is poised to be a champion software operating system. Others have left the doors wide open. The movement, in Linux development, to have many diverse people working on this collaborative programming task is very, very cool. So sometimes, nuts like me fuss about tab usage. ...go figure
 
Old 07-05-2009, 06:50 PM   #5
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 71
Are you sure you don't confuse several things here? What do K&R and C source files have to do with tabs in Makefiles? Makefiles are not written in C, and in C source nobody requires any tabs...

Last edited by Uncle_Theodore; 07-05-2009 at 06:54 PM.
 
Old 07-05-2009, 06:56 PM   #6
JimHughen
Member
 
Registered: Jun 2009
Location: Austin, Texas
Distribution: Ubuntu
Posts: 44

Original Poster
Rep: Reputation: 16
I studied the Linux kernel coding standards, and they do specify that Tabs NOT be expanded to spaces. Also the extant Linux kernel C source code consistently has TAB characters embedded in it.
 
Old 07-05-2009, 06:59 PM   #7
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 71
So, now you're talking about tabs not being expanded in C sources?
OK. So, what's so terribly wrong with that? You want them expanded?
 
Old 07-05-2009, 07:15 PM   #8
JimHughen
Member
 
Registered: Jun 2009
Location: Austin, Texas
Distribution: Ubuntu
Posts: 44

Original Poster
Rep: Reputation: 16
My experience tells me not to embed tab characters in C source. It can (and does) cause reading ambiguities. However, the value of establishing and using of coding standards far out weighs any particular coding/source file convention.

I am saying:
  1. Tabs are not required in C source files.
  2. Our source file prep tools are generally used many times to create and edit Makefile.
  3. The Tab requirement by make complicates using the same tool configured similarly.
  4. The tab character in make is different than 'white space'
  5. It's use does not seem syntacticly necessary to make.
  6. Why is it used?
 
Old 07-05-2009, 08:28 PM   #9
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
1) You don't seem to have enough experience to be a useful critic of what is probably one of the greatest results of the combination of many, many masters and doctoral theses, i.e. C, make, (not to mention lex and yacc) as well as Linux, in general.

2) You don't seem to understand the difference between a Makefile and C source.

When both of the above are taken into consideration, it's hard to take your complaint seriously.
 
Old 07-05-2009, 09:10 PM   #10
JimHughen
Member
 
Registered: Jun 2009
Location: Austin, Texas
Distribution: Ubuntu
Posts: 44

Original Poster
Rep: Reputation: 16
A C source file has C program statements and comments.

A Makefile is a sequence of dependency lists.
Each list has an 'output' object, then a colon,
then the list of files that are used to build the output.
If the time stamp on any of dependency files is later than the output time stamp, the output is out of date.
The output is rebuilt using the next line(s) as a command line(s) to rebuild output.

It is not very relevant, but I have written a complex make utility.
 
Old 07-06-2009, 08:44 PM   #11
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
You'll have to ask Dr. Stewart Feldman. He invented make in 1977 at Bell Labs, and in 2003 he won a prestigious award of recognition from the ACM for the feat.

Many things in the computer world "are what they are," and there is neither an explanation nor an apology given for it.

This is not to say that other folks have not "improved upon" this system, because they certainly have. But incompatibility, for incompatibility's own sake, really is not an "improvement." And so it goes.
 
Old 07-07-2009, 12:09 AM   #12
CSandman
Member
 
Registered: Mar 2007
Distribution: Fedora/SUSE/Debian/Knoppix
Posts: 34

Rep: Reputation: 16
make is under gnu... If you don't like it change it.

Nuf said really. As for the rest about coding, style, its just that style. My previous statement stands; if you don't like it change it. Heck, you could even write yourself a nice utility to fix your personal code style faux pas.

Any further argument here is just silly.

Cheers

Last edited by CSandman; 07-07-2009 at 12:10 AM.
 
Old 07-07-2009, 07:54 AM   #13
JimHughen
Member
 
Registered: Jun 2009
Location: Austin, Texas
Distribution: Ubuntu
Posts: 44

Original Poster
Rep: Reputation: 16
Yes, I agree.

Thanks for the discussion.
 
Old 11-02-2009, 05:19 PM   #14
yacwroy
LQ Newbie
 
Registered: Nov 2009
Posts: 1

Rep: Reputation: 0
I was just searching to see if there was an alternate to tab in standard makefiles and I came across this, since it's fairly recent I'd just like to lend my weight to the argument instead of writing my own.


My current editor and many before it have the option to auto-convert tabs to spaces. I, and I'm guessing many others, like to have this enabled.

The problem is, there's no way to emit a tab character with this option active. So, whenever I'm editing a makefile I have to go through the menu system (preferences, editing, tabs) and flip a tickbox.

Even worse, I can't use cut / paste in my current editor as it replaces pasted tabs, too.

So, it is slightly more than just a stylistic issue, to me it's a usage issue.

It is an easy fix to make my own script to achieve this, but that introduces more problems than it solves (considering other people are likely to build using it I would need to write instructions). Editing make myself would be problematic for the same reasons unless my patch were accepted (how likely would this be?).




As for incompatibility for incompatibilities' sake, allowing the usage of both tab and an alternate character or rule based on standard characters wouldn't cause incompatibility except in the relatively uncommon case of attempting to use the new syntax with incompatible "make"s.

If the standard version of make was updated to accept this alternate method (perhaps enabled via a command-line parameter), the only incompatible "make"s would be ones that aren't able to be updated. And, if I were to guess, the frequency of these incompatible "make"s being used on fresh make code using the new syntax would be very small indeed.


I guess a few options are:
- any whitespace.
- pick an unused non alphanumeric, eg ^.

Perhaps use -notab or -ftab (false tab) or something as a parameter in the command-line invocation of make.




Does that make it worth considering further?
 
Old 01-01-2010, 06:42 AM   #15
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Rep: Reputation: 57
Quote:
Creating the Makefile

In your working directory ("xpad"), copy and paste the following to a file called "Makefile", using your favourite editor. Make sure the tabs under "all:" and "install:" remain intact.
In this content the make gives errors. It says that tabs arent correct. Any ideas, shall it be two tabs entered?

I edited it with :

Code:
mc -e Makefile
Code:
KERNEL_PATH?=/usr/src/linux-headers-$(shell uname -r)

EXTRA_CFLAGS=-I$(shell pwd)

obj-m:=xpad.o

all:
        $(MAKE) modules -C $(KERNEL_PATH) SUBDIRS=$(shell pwd)

install:
        cp -f xpad.ko /lib/modules/$(shell uname -r)/kernel/drivers/input/joystick
EDITED:
SOLVED

mc -e Makefile
press twice tab, and it is becoming red
then
make works after

Last edited by frenchn00b; 01-01-2010 at 06:53 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vim not putting tabs in Makefile sarin Programming 6 01-15-2018 12:58 PM
Is it mandatory to have the name of the makefile as 'Makefile' for kernal module comp narender.d Linux - Kernel 3 05-29-2009 06:26 AM
automake, makefile, makefile.in and makefile.am Fond_of_Opensource Linux - Newbie 1 09-12-2006 08:35 PM
how to get (makefile -f makefile )output into the textview widget in Pygtk sailu_mvn Programming 3 02-28-2005 03:57 AM
generate Makefile from Makefile.in without calling ./configure ? chris78 Programming 2 05-02-2004 12:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 06:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration