.NOTPARALLEL:
-MAKECMDGOALS ?= +ack +tests
-BUILD_FILES = $(shell find * -name '*.lua')
-
-ifneq ($(shell which ninja),)
+ifeq ($(BUILDSYSTEM),)
+ ifneq ($(shell which ninja),)
BUILDSYSTEM = ninja
-BUILDFLAGS = $(NINJAFLAGS)
-else
+ else
BUILDSYSTEM = make
-BUILDFLAGS = $(MAKEFLAGS)
+ endif
endif
-LUA = $(BUILDDIR)/lua
+build-file = $(BUILDDIR)/build.$(BUILDSYSTEM)
+lua-files = $(shell find * -name '*.lua')
+our-lua = $(BUILDDIR)/lua
+
+# GNU make sets MAKECMDGOALS to the list of targets from the command
+# line. We look for targets with '+' and forward them to BUILDSYSTEM.
+# This handles commands like
+# $ make util/opt+pkg util/ego+pkg
+
+all-goals = +ack +tests
+plus-goals := $(patsubst all,$(all-goals),$(or $(MAKECMDGOALS),all))
+plus-goals := $(foreach g,$(plus-goals),$(if $(findstring +,$(g)),$(g),))
-ifneq ($(findstring +, $(MAKECMDGOALS)),)
+# @true silences extra message, "make: Nothing to be done..."
-$(MAKECMDGOALS): $(BUILDDIR)/build.$(BUILDSYSTEM)
- @$(BUILDSYSTEM) $(BUILDFLAGS) -f $^ $(MAKECMDGOALS)
+all: build-plus-goals
+ @true
+ifneq ($(plus-goals),)
+$(plus-goals): build-plus-goals
+ @true
endif
-$(BUILDDIR)/build.$(BUILDSYSTEM): first/ackbuilder.lua Makefile $(BUILD_FILES) $(LUA)
+build-plus-goals: $(build-file)
+ifeq ($(BUILDSYSTEM),ninja)
+ @ninja $(NINJAFLAGS) -f $(build-file) $(plus-goals)
+else ifeq ($(BUILDSYSTEM),make)
+# GNU make passes MAKEFLAGS in environment.
+ @$(MAKE) -f $(build-file) $(plus-goals)
+else
+$(error unknown BUILDSYSTEM = $(BUILDSYSTEM))
+endif
+
+$(build-file): first/ackbuilder.lua Makefile $(lua-files) $(our-lua)
@mkdir -p $(BUILDDIR)
- @$(LUA) first/ackbuilder.lua \
+ @$(our-lua) first/ackbuilder.lua \
first/build.lua build.lua \
--$(BUILDSYSTEM) \
DEFAULT_PLATFORM=$(DEFAULT_PLATFORM) \
PREFIX=$(PREFIX) \
AR=$(AR) \
CC=$(CC) \
- > $(BUILDDIR)/build.$(BUILDSYSTEM)
+ > $(build-file)
install:
mkdir -p $(PREFIX)
tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX)
clean:
- @rm -rf $(BUILDDIR)
+ rm -rf $(BUILDDIR)
-$(LUA): first/lua-5.1/*.c first/lua-5.1/*.h
+$(our-lua): first/lua-5.1/*.c first/lua-5.1/*.h
@echo Bootstrapping build
@mkdir -p $(BUILDDIR)
- @$(CC) -o $(LUA) -O first/lua-5.1/*.c -lm
-
+ @$(CC) -o $(our-lua) -O first/lua-5.1/*.c -lm
- GNU make.
-- Lua 5.1 and the luaposix library (used by the build system).
-
- (optionally) ninja; if you've got this, this will be autodetected and give
you faster builds.
architectures. Get both the qemu-system-* platform emulators and the qemu-*
userland emulators (only works on Linux).
-- about 40MB free in /tmp (or some other temporary directory).
+- about 115MB free in /tmp (or some other temporary directory).
-- about 6MB in the target directory.
+- about 15MB in the target directory.
Instructions:
install ninja and it'll use all your cores. If you don't have ninja, you
can still use make for parallel builds with:
- make MAKEFLAGS='-r -j8' # or however many cores you have
+ make -r -j8 # or however many cores you have
...but frankly, I recommend ninja.