> Microsoft has an implementation of make called Nmake, which comes with Visual Studio. It’s nearly a POSIX-compatible make, but necessarily breaks [...] Windows also lacks a Bourne shell and the standard unix tools, so all of the commands will necessarily be different. What I've been mulling over is an implementation of make that accepts only a restricted subset of the make syntax, eliding the extensions found in ei…
What you're mulling over is the precept for the autotools toolchain.. spare the next generation the same pain we bore :)
A Tutorial on Portable Makefiles
51–60 of 114 posts
Re: A Tutorial on Portable Makefiles
#52Earlier quoted context omitted.
I don't think this problem is limited to system headers. Something as innocent as #include "foo/bar.h" can be affected by this if you pass -I with at least two unique paths to the compiler.
ok, sure, I revise my answer to don't shadow any header.
Re: A Tutorial on Portable Makefiles
#53> Microsoft has an implementation of make called Nmake, which comes with Visual Studio. It’s nearly a POSIX-compatible make, but necessarily breaks [...] Windows also lacks a Bourne shell and the standard unix tools, so all of the commands will necessarily be different. What I've been mulling over is an implementation of make that accepts only a restricted subset of the make syntax, eliding the extensions found in ei…
What you're mulling over is the precept for the autotools toolchain.. spare the next generation the same pain we bore :)
Re: A Tutorial on Portable Makefiles
#54Re: A Tutorial on Portable Makefiles
#55Doesn't cmake take care of most of this? Is there any reason not to use cmake on middle to large scale projects? I am genuinely curious. I've only recently started looking at cmake, and it seems like they should generate portable Makefiles, or at least have an option to generate them.
Re: A Tutorial on Portable Makefiles
#56An issue I have with make is that it can not handle non-existence dependencies. DJB noted this in 2003 [1]. To quote myself on this [2]: > Especially when using C or C++, often target files depend on nonexistent files as well, meaning that a target file should be rebuilt when a previosly nonexistent file is created: If the preprocessor includes /usr/include/stdio.h because it could not find /usr/local/include/stdio.h…
Make has no memory so it can't remember things. It simply compares the dates of files. If a dependency is newer than a target the target is rebuilt. If you want to keep some kind of memory you have to build and keep track of it yourself. But the problem you point at is simply poor design. It is not a normal occurrence for system header files to move around like you state. If they do, a full rebuild is indeed required…
test(1) also compares the dates of files
test file1 -nt file2
test file1 -ot file2
Is there anything else that make does in addition to comparing dates of files?(Besides running the shell.)
tsort(1) does topological sorting
tsort + sed + sort + join + nm = lorder(1)
lorder can determine interdependencies
Re: A Tutorial on Portable Makefiles
#57Earlier quoted context omitted.
Simply add: -include $(OBJS:%.o=%.d) in your makefile (with -MMD in CFLAGS).
Don't you need a pattern rule for %.d? GNU Make doesn't seem to come with this rule. There is a profoundly ugly example here: https://www.gnu.org/software/make/manual/html_node/Automatic... %.d: %.c @set -e; rm -f $@; \ $(CC) -M $(CPPFLAGS) $ $@.$$$$; \ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' $@; \ rm -f $@.$$$$ I copied it into a running example here for anyone curious: https://github.com/oilshell/blog-code/tree/master/…
Re: A Tutorial on Portable Makefiles
#58Re: A Tutorial on Portable Makefiles
#59Re: A Tutorial on Portable Makefiles
#60Honestly, just use Cmake. It is far easier to make it work cross playform and better yet cross compile. There's no good reason to write a Makefile by hand and no large projects do it anyway
Also, the Linux kernel is pure GNU Make (no autotools, since that doesn't really make sense).
But yes those are platforms/OSes and not applications. Applications typically work on multiple Unix flavors and Windows, so something like cmake makes sense. Although honestly it's a shame that they made the same mistake as GNU make -- not paying enough attention to the programming language design and ending up with a crappy macro language.