-
Notifications
You must be signed in to change notification settings - Fork 62
/
Makefile
146 lines (110 loc) · 3.54 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# ======================================================================= #
# ACK CONFIGURATION #
# (Edit this before building) #
# ======================================================================= #
# What platform to build for by default?
DEFAULT_PLATFORM ?= pc86
# Where should the ACK put its temporary files?
ifeq ($(TMPDIR),)
ACK_TEMP_DIR ?= /tmp
else
ACK_TEMP_DIR ?= $(TMPDIR)
endif
# Where is the ACK going to be installed, eventually? If you don't want to
# install it and just want to run the ACK from the build directory
# ($(TMPDIR)/ack-build/staging, by default), leave this as $(INSDIR).
ifeq ($(OS),Windows_NT)
PREFIX ?= c:/ack
else
PREFIX ?= /usr/local
#PREFIX = $(INSDIR)
endif
# Where do you want to put the object files used when building?
BUILDDIR ?= $(ACK_TEMP_DIR)/ack-build
# What build flags do you want to use for native code?
CFLAGS ?= -g -Wno-return-type
LDFLAGS ?=
# Various commands.
AR ?= ar
CC ?= gcc
LUA ?= lua
# 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 ?=
# ======================================================================= #
# END OF CONFIGURATION #
# ======================================================================= #
# You shouldn't need to change anything below this point unless you are
# actually developing ACK.
OBJDIR = $(abspath $(BUILDDIR)/obj)
BINDIR = $(abspath $(BUILDDIR)/bin)
LIBDIR = $(abspath $(BUILDDIR)/lib)
INCDIR = $(abspath $(BUILDDIR)/include)
INSDIR = $(abspath $(BUILDDIR)/staging)
PLATIND = $(INSDIR)/share/ack
PLATDEP = $(INSDIR)/lib/ack
.NOTPARALLEL:
ifeq ($(BUILDSYSTEM),)
ifneq ($(shell which ninja),)
BUILDSYSTEM = ninja
else
BUILDSYSTEM = make
endif
endif
build-file = $(BUILDDIR)/build.$(BUILDSYSTEM)
lua-files = $(shell find . -name 'build*.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),))
# @true silences extra message, "make: Nothing to be done..."
all: build-plus-goals
@true
ifneq ($(plus-goals),)
$(plus-goals): build-plus-goals
@true
endif
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)
@mkdir -p $(BUILDDIR)
@$(LUA) first/ackbuilder.lua \
first/build.lua build.lua \
--$(BUILDSYSTEM) \
LUA=$(LUA) \
DEFAULT_PLATFORM=$(DEFAULT_PLATFORM) \
OBJDIR=$(OBJDIR) \
BINDIR=$(BINDIR) \
LIBDIR=$(LIBDIR) \
INCDIR=$(INCDIR) \
INSDIR=$(INSDIR) \
PLATIND=$(PLATIND) \
PLATDEP=$(PLATDEP) \
PREFIX="$(PREFIX)" \
AR=$(AR) \
CC=$(CC) \
CFLAGS="$(CFLAGS)" \
LDFLAGS="$(LDFLAGS)" \
> $(build-file)
ack-setup.exe: etc/windows-installer.nsi
makensis -dBUILDDIR=$(BUILDDIR)/staging -dOUTFILE="$$(realpath $@)" $<
install:
mkdir -p $(PREFIX)
tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX)
clean:
rm -rf $(BUILDDIR)