1 # ======================================================================= #
3 # (Edit this before building) #
4 # ======================================================================= #
6 # What platform to build for by default?
8 DEFAULT_PLATFORM = pc86
10 # Where should the ACK put its temporary files?
14 # Where is the ACK going to be installed, eventually? If you don't want to
15 # install it and just want to run the ACK from the build directory
16 # (/tmp/ack-build/staging, by default), leave this as $(INSDIR).
21 # Where do you want to put the object files used when building?
23 BUILDDIR = $(ACK_TEMP_DIR)/ack-build
25 # What build flags do you want to use for native code?
27 CFLAGS = -g -Wno-return-type
35 # Which build system to use; use 'ninja' or 'make' (in lower case). Leave
36 # blank to autodetect.
40 # Build flags for ninja.
44 # Build flags for make.
48 # ======================================================================= #
49 # END OF CONFIGURATION #
50 # ======================================================================= #
52 # You shouldn't need to change anything below this point unless you are
53 # actually developing ACK.
55 OBJDIR = $(abspath $(BUILDDIR)/obj)
56 BINDIR = $(abspath $(BUILDDIR)/bin)
57 LIBDIR = $(abspath $(BUILDDIR)/lib)
58 INCDIR = $(abspath $(BUILDDIR)/include)
59 INSDIR = $(abspath $(BUILDDIR)/staging)
61 PLATIND = $(INSDIR)/share/ack
62 PLATDEP = $(INSDIR)/lib/ack
66 ifeq ($(BUILDSYSTEM),)
67 ifneq ($(shell which ninja),)
74 build-file = $(BUILDDIR)/build.$(BUILDSYSTEM)
75 lua-files = $(shell find . -name 'build*.lua')
76 our-lua = $(BUILDDIR)/lua
78 # GNU make sets MAKECMDGOALS to the list of targets from the command
79 # line. We look for targets with '+' and forward them to BUILDSYSTEM.
80 # This handles commands like
81 # $ make util/opt+pkg util/ego+pkg
83 all-goals = +ack +tests
84 plus-goals := $(patsubst all,$(all-goals),$(or $(MAKECMDGOALS),all))
85 plus-goals := $(foreach g,$(plus-goals),$(if $(findstring +,$(g)),$(g),))
87 # @true silences extra message, "make: Nothing to be done..."
92 ifneq ($(plus-goals),)
93 $(plus-goals): build-plus-goals
97 build-plus-goals: $(build-file)
98 ifeq ($(BUILDSYSTEM),ninja)
99 @ninja $(NINJAFLAGS) -f $(build-file) $(plus-goals)
100 else ifeq ($(BUILDSYSTEM),make)
101 # GNU make passes MAKEFLAGS in environment.
102 @$(MAKE) -f $(build-file) $(plus-goals)
104 $(error unknown BUILDSYSTEM = $(BUILDSYSTEM))
107 $(build-file): first/ackbuilder.lua Makefile $(lua-files) $(our-lua)
108 @mkdir -p $(BUILDDIR)
109 @$(our-lua) first/ackbuilder.lua \
110 first/build.lua build.lua \
113 DEFAULT_PLATFORM=$(DEFAULT_PLATFORM) \
129 tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX)
134 uname := $(shell uname)
135 ifeq (Linux,$(uname))
136 # Turn on LUA_USE_POSIX so that Lua is not compiled with the dangerous
137 # tmpnam(.) function. But, do not use LUA_USE_LINUX here, since that will
138 # also turn on LUA_USE_READLINE, and I do not want to force everyone to
139 # install libreadline-dev. -- tkchia
140 $(our-lua): CFLAGS += -DLUA_USE_POSIX -DLUA_USE_DLOPEN
141 $(our-lua): LDFLAGS += -ldl
143 ifeq (Darwin,$(uname))
144 $(our-lua): CFLAGS += -DLUA_USE_MACOSX
148 $(our-lua): first/lua-5.1/*.c first/lua-5.1/*.h
149 @echo Bootstrapping build
150 @mkdir -p $(BUILDDIR)
151 @$(CC) $(CFLAGS) -o $(our-lua) -O first/lua-5.1/*.c $(LDFLAGS) -lm