On Monday, 18 April 2016 at 23:17:39 UTC, Marco Leise wrote:
Am Mon, 18 Apr 2016 15:15:26 +0000
schrieb Atila Neves <[email protected]>:
Just remember that makefiles are well integrated with other
systems (i.e. package managers) and there are some conventions,
about what certain environment variables mean. To name a few:
MAKEOPTS=-j4 (parallel build with N processes)
This is make-dependent though. ninja and the reggae binary
backend run with the number of cores by default.
DC=/opt/ldc2-0.17/bin/ldc2 (Dlang compiler)
DC, CC, and CXX all work already.
DC_FLAGS=-O5 (flags for that compiler)
LDFLAGS=-L=-O1 (flags for the linker)
PREFIX=/usr (installation prefix)
These I need to add. Well, if there's enough of a use-case anyway.
Dlang projects already have some make files that handle linker
flag prefixes while others will pass them verbatim to gcc and
some make files accept a DMD (ldmd2, gdmd, dmd) and others a
DC (ldc2, gdc, dmd). The more things we can override, the
better.
The phobos makefile only has DMD.
As a practical example, on Gentoo, the package management sets
all kinds of environment variables, most importantly PREFIX,
LDFLAGS, CFLAGS and CXXFLAGS. It would be great if any
replacement system would also honor those (translated to D).
I didn't even know CFLAGS was a default!
Even better if it could handle GDC and LDC2 directly (since
gdmd and ldmd2 don't do all the way).
Here it'd be better to improve gdmd and ldmd2, I think. In any
case it's a leaky abstraction. I've never seen a CMake build that
doesn't have ifs for what compiler is being used in order to
choose the appropriate flags.
LDFLAGS need translation from the default (GCC) syntax to DMD
and LDC2. I currently do this in a helper script and would not
depend on the build script doing that.
Why does it need translating? If you use the system linker
directly, use LDFLAGS as is. If not, use whatever linker flags
are appropriate for the compiler being used (-L-l... for
instance).
Atila