Live data from Hacker News

One line you should add to every makefile

blog.jgc.org

41–50 of 99 posts

Re: One line you should add to every makefile

#41
post #5
post #3

I firmly believe that there is only one production-quality makefile that has ever been written from scratch. Every other makefile has been copied from an earlier makefile, dating back to the one Ur-makefile, and modified to suit the author's purpose.

To be honest, a simple Makefile is very simple to write and efficient once you know the syntax fairly well. Then you add more and more things as the time pass, and it starts to morph into a giant huge monster that eat puppies.

> a giant huge monster that eat puppies

Not puppies, but brains of the poor programmer who is confronted with a problem of building your bloatware on a non-supported platform (typically Windows).

Re: One line you should add to every makefile

#42
post #30

Earlier quoted context omitted.

The problem is that C/C++ files have internal depenedencies which make needs to know about. Yes, for gcc you can use a simple trick to extract the dependencies to makefile rules, but in case you use a different compiler, you need to do it yourself. If you are compiling a different language, you need to do it yourself again. Using something like CMake or even automake, which can automatically track the dependencies, s…

How do they track the dependencies automatically?

With gcc/clang it's a set of flags starting with -M, and with MSVC it's /showIncludes. They're discussed a bit here:

http://martine.github.io/ninja/manual.html#ref_headers

Re: One line you should add to every makefile

#43
post #39

Earlier quoted context omitted.

that this blogger is probably rehashing anyway Nope. Eric (who wrote that blog you are referrring to is a friend), but I wrote this little trick up years before him: http://www.cmcrossroads.com/article/printing-value-makefile-... and now I'm rehashing my own writing 10 years later.

I shouldn't be surprised that you published that before I did -- to be fair, it's quite a challenge to find _any_ topic related to make that you _haven't_ written about. :)

The real question is who wrote the original line? My bet's on it being Usman.

Re: One line you should add to every makefile

#44
post #32
post #21

Earlier quoted context omitted.

It may be my inexperience speaking, but every time I come across code that was built not by hand I visibly cringe and search for something else. It's not that it's bad, it's just that if I don't understand it then there is nothing for me to fix or play around with.

I am old enough to remember when assembly programmers used to use that complaint as a reason not to program in C. And when C programmers would use that complaint as a reason not to program with templates in C++. And when C++ programmers used that complaint as a reason not to program in languages with garbage collection. The truth is that no matter what level you program at, you are depending on a long toolchain that…

Here's the post you were thinking of, be sure to bookmark it this time! :)

https://plus.google.com/+JeanBaptisteQueru/posts/dfydM2Cnepe

Re: One line you should add to every makefile

#45
The best quality of life change I ever made was turning off email notifications. I just have have the numeric counter on, and check it every so often like I always did anyway. I only have notifications for things that people expect quicker replies to like texts, calls, voicemails, etc.

Re: One line you should add to every makefile

#46
post #39

Earlier quoted context omitted.

I shouldn't be surprised that you published that before I did -- to be fair, it's quite a challenge to find _any_ topic related to make that you _haven't_ written about. :)

The real question is who wrote the original line? My bet's on it being Usman.

I'll take any excuse for a little code spelunking -- according to Perforce it was Scott, in October 2002.

Re: One line you should add to every makefile

#48
post #46

Earlier quoted context omitted.

The real question is who wrote the original line? My bet's on it being Usman.

I'll take any excuse for a little code spelunking -- according to Perforce it was Scott, in October 2002.

Nice. Thanks for looking that up.

Re: One line you should add to every makefile

#49

Or, if you're using BSD Make: # make -V SOURCE_FILES

Oh man I've missed -V! I've done something like this in gmake, basically using the : in sh and -n of make to print whatever I wanted:

  $ foo() { echo 'foo: ; @ : ${'"$1"'}'; echo include Makefile; }
  $ foo SRCS
  foo: ; @ : ${SRCS}
  include Makefile
  $ foo OBJS | make -n -f- foo
  : foo.o bar.o baz.o

Re: One line you should add to every makefile

#50
post #33
post #3

I firmly believe that there is only one production-quality makefile that has ever been written from scratch. Every other makefile has been copied from an earlier makefile, dating back to the one Ur-makefile, and modified to suit the author's purpose.

Not exactly true. I tend to start with a new makefile for a good amount of projects. Know your tools, know your code.

I wrote a god-awful Perl script to gen (and update) Makefiles for me: https://github.com/wspeirs/makemake
Post reply on HN