Earlier quoted context omitted.
Can you humor a dumb question and tell me how you got the manual in your terminal? I'm on Debian, and when I `man make`, I just get a typical GNU CLI util manpage that's five paragraphs of intro and a line-by-line explanation of each command line option. Same for `info make`.
Have you installed the make-info ( https://packages.debian.org/jessie/make-doc ) package? It adds info documentation as well as pdf and html formats.
Makefiles – Best Practices
121–127 of 127 posts
Re: Makefiles – Best Practices
#122Earlier quoted context omitted.
Because CFLAGS may not be set in the environment, resulting in concatenation to an undefined variable error.
No such error occurs. $ cat Makefile FOO += foo all: ; @echo $(FOO) $ make foo
Re: Makefiles – Best Practices
#123Earlier quoted context omitted.
Because CFLAGS may not be set in the environment, resulting in concatenation to an undefined variable error.
There's no such thing as an undefined variable in Make. The variable expands to text. Variables which are not defined by definition expand to no text.
Re: Makefiles – Best Practices
#124I really wish blog posts like this would at least mention that they are going to use GNUMake extensions. There's some good stuff in here, but just calling it "make" and leaving it at that is misleading. It's not going to work on my minimal (non-GNU) Linux boxes that mostly run NetBSD make (bmake in many distros) or busybox style tools. I know a very small minority of people do something like that (or maybe not, what…
I doubt most people even know that there are different versions. (I didn't!)
Re: Makefiles – Best Practices
#125I really wish blog posts like this would at least mention that they are going to use GNUMake extensions. There's some good stuff in here, but just calling it "make" and leaving it at that is misleading. It's not going to work on my minimal (non-GNU) Linux boxes that mostly run NetBSD make (bmake in many distros) or busybox style tools. I know a very small minority of people do something like that (or maybe not, what…
/ # make --version GNU Make 4.2.1 Built for x86_64-alpine-linux-musl Copyright (C) 1988-2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Re: Makefiles – Best Practices
#126Earlier quoted context omitted.
Its not actually all that hard to make well-parallelized makefiles, provided you follow a few basic rules. - Each build step has a unique artifact. - That artifact is visible to Make as a file in the filesystem. - That artifact is named $@ in the rule's recipe. - Every time the recipe is executed, $@ is updated on success. - If the recipe fails, it must return nonzero to Make. - All of the dependencies of the artifac…
That's a nice set of rules, although I don't think they're all easy to follow or verify that 1000 lines of Make is following. I considered 3 main use cases, and I wrote Makefiles from scratch for all of them. Make works to an extent for each case, but I still have problems. 1. Building mixed Python/C app bundles [1] 2. Building my website [2]. Notably people actually do complain about Jekyll build speed, to the point…
There are at least two ways that this problem can be addressed. One is to support out-of-tree builds, one side directory per configuration. Builds based on the autotools do this by default.
The other is to use a separate build directory per configuration within the build. My current project uses local in-tree directories named .host-release, .host-debug (including asan), .host-tsan, .cross-release, and .cross-debug. All of them are built in parallel with a single invocation of Make, and I use target-scoped variables to control the various toolchain options.
The engineer's incremental work factor to add another build configuration isn't quite constant time, since each top-level target needs to opt into each build configuration that is relevant for that target.
> I hit the multiple outputs problem
I wouldn't really classify that as a problem in GNU Make, as long as you can specify the rule as a pattern rule.
I hear you on the testing problem. Make certainly behaves as if the Makefile's correctness isn't decidable. Even if you levied the requirement that a Makefile's decidability was predicated on the recipes being well-behaved, I'm not sure that the correctness is decidable.
Re: Makefiles – Best Practices
#127CFLAGS := ${CFLAGS} CFLAGS += -ansi -std=99 What's the point of the first line? Why not just: CFLAGS += -ansi -std=99
My guess is that the left hand side is a make variable while the right hand side is an environment variable. However the make manual says “Every environment variable that make sees when it starts up is transformed into a make variable with the same name and value.“ so maybe it’s not necessary?...