Re: [dev] Special target ".POSIX" in Makefiles

From: Laslo Hunhold <>
Date: Sat, 1 Jan 2022 16:11:45 +0100

On Sat, 1 Jan 2022 14:08:24 +0100
Ralph Eastwood <> wrote:

Dear Ralph,

> So... makellint? :D
> I like it; it seems 'makel' is unused as a project name.

and even if, it's not like names are reserved. When some 13-year-old
kid dumps some Rust-crap with a name on GitHub I wouldn't see it as
reserved. The threshold is if a program or library gets packaged,
because then you may have namespace-conflicts.

> Are there any suggestions for handling out-of-source builds using
> POSIX makefiles? I recently had a project where we needed to
> support multiple platforms and so output-ing object files and binaries
> into platform-specific directories was needed.
> I know that GNU's pattern matching rules support this behaviour, i.e.:
> $(OBJDIR)/%.o: $(SRCDIR)/%.c
> $(CC) $(CFLAGS) -c $< -o $_AT_
> Perhaps just listing all of the object files and source +
> dependencies would be the easiest way in this instance?

So did you build all of the platforms or would it need to be
selectable? If you have multiple platform sources e.g. in folders "x86"
and "arm", I would create a folder "target" that contains the files

--------------- ---------------
   SRC =\

--------------- ---------------
   SRC =\

and then in have a variable

   TARGET = arm

and then in the Makefile have a line

   include target/$

(this works according to the standard, see [0] under "Include Lines")

The nice thing about this is that you can do all kinds of things within
these mk-files apart from defining SRC-files. You can also change
CFLAGS or whatnot, but do as little as possible to ensure that maximum
control is retained within the

Within the Makefile, you can then easily just work with the
$SRC-variable that is automatically set, and if you want to build for
certain architectures, you simply run

   make TARGET=arm

It also "breaks" elegantly because it would output an error that
target/ (or something) could not be found, which is pretty
easy to understand.

You can also, if you have shared source files, only define a variable
$TARGET_SRC in the target files that is then appended to SRC in the
Makefile itself.

I think that should work out in your case, but let me know if it is
different from how I understood it.

With best regards


Received on Sat Jan 01 2022 - 16:11:45 CET

This archive was generated by hypermail 2.3.0 : Sat Jan 01 2022 - 16:24:08 CET