This package provides supporting glue for cross-platform Makefiles using GNU make.
Plenty of tools exist to add sanity as a layer atop Makefiles, generating makefiles at runtime for a specific target, etc., but make itself is plenty featureful.
Harnessing the power of make, we get:
- Dependency tracking for minimal rebuild
- Parallel builds via
make -j
- Some scripting, useful for platform-specific configuration (who needs
./configure
?).
The philosophy of the makefiles was inspired by the recursive make considered
harmful paper. A library using these makefiles authors its own
Makefile.inc
defining variables and targets to be consumed by the parent.
Thus we simulate "recursive" makefiles via inclusion of the Makefile.inc
files.
In the scripts
directory is a simple script that parses files looking for
#include
directives, generating dependency rules to be consumed by make.
Example usage (a make depend
target in a Makefile):
export
depend:
env PROJECT=LIBFOO $(DEPEND) src/*.c src/*.cc src/*.m > depend.mk
Then in Makefile.inc
:
# include "depend.mk" if it exists
-include $(LIBFOO_ROOT)depend.mk
make depend
will generate rules such as:
# This file was generated by "make depend".
#
$(LIBFOO_ROOT)src/foo.o: $(LIBFOO_ROOT)src/foo.c $(LIBFOO_ROOT)include/foo/bar.h
$(CC) $(CFLAGS) $(LIBFOO_CFLAGS) -c -o $@ $<
This allows make to not only correctly calculate header dependencies for
src/foo.o
, but also allows us to set per-library CFLAGS
via LIBFOO_CFLAGS
.
Windows builds work inside cmd.exe
. It is assumed that MSysGit binaries
a Win32 port of GNU make, and nasm are on the PATH.
C and C++ compilation happen via clwrapper, included with the repo. It has been tested with VS2015 and Windows SDK 10586. VS and Windows SDK are a bit of a moving target so I make no guarantees about more recent builds.
By default, x86 and WinXP support are assumed. Try "make WIN64=y" to build for amd64.
scripts/remote-build.sh
will take a tarball of the repo, push it to hosts
over ssh
, and running make -j
for parallel builds on the remote host.
The server piece of this also works with the MS port of sshd for Windows 10.
First, we assume that the remote host recognizes your SSH key and you can
authenticate with it using the username user
. These instructions are beyond
the scope of this writing.
On the remote host we set up a hacky host discovery method:
perl scripts/bcast.pl -d -n myhost
You can verify this works with a client:
$ perl scripts/bcast.pl -n myhost
[ip address should appear]
$ ssh user@`perl scripts/bcast.pl -n myhost`
[make sure your config works so you can get a shell this way]
When you're ready to build:
$ sh scripts/remote-build.sh myhost
This will copy resulting binaries into ./out/
.
Note that you can specify multiple hosts on the command line, and the script will run the necessary ssh commands in parallel.