snb icon indicating copy to clipboard operation
snb copied to clipboard

Sane and portable Makefile

Open drbig opened this issue 10 years ago • 2 comments

The big question:

Is there a sane way to make a Makefile smart-enough to figure out whether it should call ncursesw5-config or ncursesw6-config, or to report a human-readable error when it doesn't know how to deal with that, without resorting to contraptions like autotools.

Second question:

Is it possible to do a single, portable Makefile - i.e. one that will work on Linuxes and BSD/OS X (perhaps only when invoked with gmake, but that would be acceptable).

Third question:

My opinion right now is that the compiler and linker flags should at the same time be: as strict on errors as possible; and as non-assuming as possible. This is not currently the case, as there are some optimisation/hardening flags on and -Wno-implicit-function-declaration (presumably to deal with ncurses weirdness).

I'm tempted to remove the additional flags because:

  • They assume compiler features to be present
  • Any 'sane' build system should apply such flags anyway (e.g. ArchLinux's makepkg, BSD ports (if snb ever gets there)) - in a way that's actually appropriate for the particular platform

The above approach is debatable, so I'm leaving the flags as-is.

drbig avatar Jan 04 '15 09:01 drbig

Re: autotools phk said the following:

Some day when I have the time, I will rip out all the autocrap stuff and replace it with a 5 line shellscript that calls uname -s.

I guess it's possible to use a $(shell ...) thing to find the ncurses*config thing. But anyway, ports/pkgbuilds/formulas/etc. should just override NCURS_CONF. And users who compile manually from git should do the same. The OS X note in the README is an example.

Re: make portability the current Makefile works if you use gmake on BSD. My little BSDmakefile makes it work with BSD make. I totally get your point about gmake being acceptable – it's just my personal hatred of things whose names start with the word "GNU" :D

Re: flags -Wno-implicit-function-declaration is indeed for ncurses weirdness, it must stay in the Makefile. If -fstack-protector-all -fPIC -fPIEespecially PIC/PIE – aren't available on a system, I'd say that system is ancient, but that's debatable.

valpackett avatar Jan 04 '15 09:01 valpackett

Oh, one little thing: the BSDmakefile is not just for BSD make compatibility. There's this line:

NCURS_INC+=-I/usr/local/include

ncursesw5-config --cflags on FreeBSD doesn't include that path, and everything breaks without it, because one of the headers includes a different one with an absolute path like so: <ncurses/something.h>

valpackett avatar Jan 04 '15 09:01 valpackett