Live data from Hacker News

Show HN: One makefile to rule them all

gist.github.com

1–10 of 19 posts

Re: Show HN: One makefile to rule them all

#3
interesting! how much of this is already implemented with implicit rules? is there any documentation about how to adapt this to one's own projects? how does a user trigger the verbosity on and off for example, is it `-DV=1 -Dsilent=0` to get all the nice debugging?

Some things seem hardcoded and some things are not, e.g. $LANG specifies the file extension (not language) of the input files, but the assumption is that each of these files winds up as a .o, so there's some tweaking required for your projects.

Re: Show HN: One makefile to rule them all

#6
- No idea whats up with the QUIET_* variables as most of them dont seem to get used

- $(RM), $(CP), $(MKDIR) and $(ECHO) are unnecessary - these variables are for programs that are not portable. These 4 are some of the few portable ones.

- It only builds and installs a single executable (without extension), no library, no headers

- The install target does not honour DESTDIR, but distributors can get away with prepending it to PREFIX. For programs that use the PREFIX at build time, thats not okay.

Makefile portability is hard. Take this makefile and try to build on FreeBSD or cross-compiling for Windows (where executables have a suffix). Or cross-compiling in general.

Re: Show HN: One makefile to rule them all

#7
post #4

It looks like it doesn't deal with C/C++/etc. header files?

Yeah, you have to run GCC with `-MMD -MP` so you get .d files along with your .o files. Then in my own Makefile I have:

    include $(shell find $(BUILD_DIR) -type f -name '\*.d')
so that make will check for header file changes.

Re: Show HN: One makefile to rule them all

#10

Was crossing my fingers this would be for Python projects...

Here is my "one true" Makefile for Python projects[1]. The skeleton gets tweaked slightly each time, but it's served me well for 4+ years.

[1]: https://github.com/pypa/pip-audit/blob/main/Makefile

Post reply on HN