Clean up the top level makefile.

This commit is contained in:
David Given 2016-09-01 23:36:39 +02:00
parent 2b6d251dec
commit 96e7447bfa

View file

@ -32,6 +32,19 @@ LDFLAGS =
AR = ar AR = ar
CC = gcc CC = gcc
# Which build system to use; use 'ninja' or 'make' (in lower case). Leave
# blank to autodetect.
BUILDSYSTEM =
# Build flags for ninja.
NINJAFLAGS =
# Build flags for make.
MAKEFLAGS = -r
# ======================================================================= # # ======================================================================= #
# END OF CONFIGURATION # # END OF CONFIGURATION #
# ======================================================================= # # ======================================================================= #
@ -51,25 +64,26 @@ PLATDEP = $(INSDIR)/lib/ack
MAKECMDGOALS ?= +ack MAKECMDGOALS ?= +ack
BUILD_FILES = $(shell find * -name '*.lua') BUILD_FILES = $(shell find * -name '*.lua')
NINJA := $(shell which ninja) ifneq ($(shell which ninja),)
ifneq ($(findstring +, $(MAKECMDGOALS)),) BUILDSYSTEM = ninja
ifneq ($(NINJA),) BUILDFLAGS = $(NINJAFLAGS)
$(MAKECMDGOALS): $(BUILDDIR)/build.ninja
@ninja -f $(BUILDDIR)/build.ninja $(MAKECMDGOALS)
else else
BUILDSYSTEM = make
$(MAKECMDGOALS): $(BUILDDIR)/rules.mk BUILDFLAGS = $(MAKEFLAGS)
+@make -r -f $(BUILDDIR)/rules.mk $@ \
$(MAKEFLAGS)
endif
endif endif
$(BUILDDIR)/build.ninja: first/ackbuilder.lua Makefile $(BUILD_FILES) ifneq ($(findstring +, $(MAKECMDGOALS)),)
$(MAKECMDGOALS): $(BUILDDIR)/build.$(BUILDSYSTEM)
@$(BUILDSYSTEM) $(BUILDFLAGS) -f $^ $(MAKECMDGOALS)
endif
$(BUILDDIR)/build.$(BUILDSYSTEM): first/ackbuilder.lua Makefile $(BUILD_FILES)
@mkdir -p $(BUILDDIR) @mkdir -p $(BUILDDIR)
@lua5.1 first/ackbuilder.lua first/build.lua build.lua --ninja \ @lua5.1 first/ackbuilder.lua \
first/build.lua build.lua \
--$(BUILDSYSTEM) \
OBJDIR=$(OBJDIR) \ OBJDIR=$(OBJDIR) \
BINDIR=$(BINDIR) \ BINDIR=$(BINDIR) \
LIBDIR=$(LIBDIR) \ LIBDIR=$(LIBDIR) \
@ -79,21 +93,7 @@ $(BUILDDIR)/build.ninja: first/ackbuilder.lua Makefile $(BUILD_FILES)
PLATDEP=$(PLATDEP) \ PLATDEP=$(PLATDEP) \
AR=$(AR) \ AR=$(AR) \
CC=$(CC) \ CC=$(CC) \
> $(BUILDDIR)/build.ninja > $(BUILDDIR)/build.$(BUILDSYSTEM)
$(BUILDDIR)/rules.mk: first/ackbuilder.lua Makefile $(BUILD_FILES)
@mkdir -p $(BUILDDIR)
@lua5.1 first/ackbuilder.lua first/build.lua build.lua --make \
OBJDIR=$(OBJDIR) \
BINDIR=$(BINDIR) \
LIBDIR=$(LIBDIR) \
INCDIR=$(INCDIR) \
INSDIR=$(INSDIR) \
PLATIND=$(PLATIND) \
PLATDEP=$(PLATDEP) \
AR=$(AR) \
CC=$(CC) \
> $(BUILDDIR)/rules.mk
clean: clean:
@rm -rf $(BUILDDIR) @rm -rf $(BUILDDIR)