-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAKEFILE
325 lines (266 loc) · 9.15 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# ----------------------------------------------------------------------------
# AlMake
# ----------------------------------------------------------------------------
# Generic Allegro build system
#
# This is a group of scripts and files that helps the developer and end-user
# to configure, update, and build Allegro and AllegroGL projects,
# on many platforms, and with different compilers.
#
# Get updates of AlMake at official website
# http://almake.sf.net/
# ----------------------------------------------------------------------------
# Project main developer : Kronoman
# Project started: 26/May/2005
# ----------------------------------------------------------------------------
# <Kronoman> In loving memory of my father
#
# <MattyMatt> almake, pure and simple, caught in a world where love survives
# ----------------------------------------------------------------------------
# Thanks to Schwarzung for the help on making the legacy first makefile system.
#
# Thanks to roaet (Justin Hammond) and Solak for the great help with the Macintosh target.
#
# Greetz to KittyCat, Sevalecan, and #allegro in general.
#
# Greetz to Harley Owners Group Argentina.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# ** Configuration stuff **
# ----------------------------------------------------------------------------
# Please set this to fit your project
# Also check the compiler dependent section.
# Project name
PROJECT_NAME = ZeroUFO
# Binary to produce
BINARY = zeroufo
# Source directory
SRCDIR = src
# Include directory
INCDIR = include
# Source code suffix (Values: .c or .cpp ; will also set the compiler to use)
SRCSUF = .cpp
# this should be /bin/sh
SHELL = /bin/sh
# ----------------------------------------------------------------------------
# ** Compiler-dependent section **
# SET THIS TO FIT YOUR PROJECT
# ----------------------------------------------------------------------------
# Here you can set if your project uses Allegro or AllegroGL,
# the compiler to use, flags, other libraries to link, etc...
# The platform is autodetected (DJGPP, Mingw, Unix(Linux, Darwin, etc), in that order)
ifdef DJDIR
# -------------------------------------
# Here goes DJGPP stuff
# -------------------------------------
PLATFORMDIR=djgpp
TARGET=DOS/DJGPP
# compiler to invoque (C or C++ compiler)
ifeq "$(SRCSUF)" ".c"
CC = gcc
else
CC = gxx
endif
# Binary file suffix
BINSUF = .exe
# object suffix
OBJSUF = .o
# ** IMPORTANT - CONFIGURE **
# ** If you need extra link options (like more librarys, add them HERE!)
LFLAGS = -s -lalleg
# ** Compiler flags
# NOTA : para hardware real 386, poner los parametros: -mpc32 -march=i386 (-mpc32 dudoso, investigar bien)
CFLAGS = -I$(INCDIR) -Wall -Wfatal-errors -O3 -fomit-frame-pointer
# command for deletion
DELETE_CMD = del
else
ifdef MINGDIR
# -------------------------------------
# Here goes MingW32 stuff
# -------------------------------------
PLATFORMDIR=mingw32
TARGET=Win32/Mingw32
# compiler to invoque (C or C++ compiler)
ifeq "$(SRCSUF)" ".c"
CC = gcc
else
CC = g++
endif
# Binary file suffix
BINSUF = _w32.exe
# object suffix
OBJSUF = .o
# ** IMPORTANT - CONFIGURE **
# ** If you need extra link options (like more librarys, add them HERE!)
LFLAGS = -Wl,--subsystem,windows -s -lalleg
# ** Compiler flags
CFLAGS = -I$(INCDIR) -Wall -O3 -fomit-frame-pointer
# command for deletion
DELETE_CMD = del
else
# -------------------------------------
# Here goes GCC (Linux) stuff
#
# This section also works for *nix and *BSD variants.
# Also, Darwin (Mac) stuff, because is a *nix variant.
# -------------------------------------
PLATFORMDIR=linux
TARGET=Unix/gcc
# compiler to invoque (C or C++ compiler)
ifeq "$(SRCSUF)" ".c"
CC = gcc
else
CC = g++
endif
# Binary file suffix
BINSUF = _unix
# object suffix
OBJSUF = .o
# ** IMPORTANT - CONFIGURE **
# ** If you need extra link options (like more librarys, add them HERE!)
LFLAGS = -s `allegro-config --libs`
# ** Compiler flags
CFLAGS = -I$(INCDIR) -Wall -O3 -fomit-frame-pointer
# command for deletion
DELETE_CMD = rm
# check if this is Linux
ifeq ($(shell uname -s), Linux)
TARGET=Linux/gcc
BINSUF=_linux
endif
# check if this is Darwin (Macintosh)
# if this is Darwin, we adjust some parameters
ifeq ($(shell uname -s), Darwin)
TARGET=Darwin/gcc
BINSUF=_darwin
endif
endif
endif
# ---------------------------------
# Platform non-specific stuff
# ---------------------------------
OBJDIR = obj/$(PLATFORMDIR)
BINDIR = bin
# ----------------------------------------------------------------------------
# Build process from here
# ----------------------------------------------------------------------------
TEMP = $(wildcard $(SRCDIR)/*$(SRCSUF))
ifeq ($(strip $(TEMP)),)
$(error ERROR: No source code found at $(SRCDIR)/*$(SRCSUF) )
endif
FILES = $(TEMP)
OBJS = $(addprefix $(OBJDIR)/,$(addsuffix $(OBJSUF), $(basename $(notdir $(FILES) ) ) ) )
# ---------------------------------
# Main target
# ---------------------------------
.PHONY: all
all: $(BINDIR)/$(BINARY)$(BINSUF) adbanner
@echo "Finished $(PROJECT_NAME)"
@echo "Product is at $(BINDIR)/$(BINARY)$(BINSUF)."
# ---------------------------------
# binary
# ---------------------------------
$(BINDIR)/$(BINARY)$(BINSUF) : $(OBJS)
$(CC) $^ -o $@ $(LFLAGS)
@echo "The $(BINDIR)/$(BINARY)$(BINSUF) is ready!"
# ---------------------------------
# objects
# ---------------------------------
$(OBJDIR)/%$(OBJSUF) : $(SRCDIR)/%$(SRCSUF)
$(CC) $(CFLAGS) -c $< -o $@
# ---------------------------------
# status report
# ---------------------------------
.PHONY: status
status: adbanner
@echo "-----------------"
@echo "- Status Report -"
@echo "-----------------"
@echo " Build : $(PROJECT_NAME)"
@echo " Detected platform : $(TARGET)"
@echo " Compiler to use : $(CC)"
@echo " Link Flags : $(LFLAGS)"
@echo " Compilation Flags: $(CFLAGS)"
@echo " Files : $(FILES)"
@echo " Obj : $(OBJS)"
@echo " Target : $(BINDIR)/$(BINARY)$(BINSUF)"
# ---------------------------------
# clean
# ---------------------------------
.PHONY: clean
clean:
-$(DELETE_CMD) $(BINDIR)/$(BINARY)$(BINSUF) $(OBJS)
# ---------------------------------
# Strip symbols and compress with upx packer (http://upx.sf.net/)
# ---------------------------------
.PHONY: upx
upx: $(BINDIR)/$(BINARY)$(BINSUF)
strip --strip-all $(BINDIR)/$(BINARY)$(BINSUF)
-upx --best $(BINDIR)/$(BINARY)$(BINSUF)
# ---------------------------------
# Install - THIS NEEDS TO BE DONE YET... HOLD PLEASE...
# TODO -- SEE HERE --> http://www.gnu.org/prep/standards/html_node/Command-Variables.html#Command-Variables
# SEE ALSO : http://www.gnu.org/prep/standards/html_node/Directory-Variables.html#Directory-Variables
# SEE ALSO : http://www.gnu.org/prep/standards/html_node/Standard-Targets.html#Standard-Targets
# ---------------------------------
.PHONY: install
install: $(BINDIR)/$(BINARY)$(BINSUF)
@echo Sorry, the install feature is not done yet.
# ---------------------------------
# install compressed and stripped (saves disk space)
# ---------------------------------
.PHONY: install-strip
install-strip: upx install
# ---------------------------------
# uninstall - - THIS NEEDS TO BE DONE
# TODO TODO TODO TODO
# ---------------------------------
.PHONY: uninstall
uninstall: $(BINDIR)/$(BINARY)$(BINSUF)
@echo Sorry, the uninstall feature is not done yet.
# ---------------------------------
# distribution - - THIS NEEDS TO BE POLISHED
# TODO TODO TODO TODO
# check
# http://www.gnu.org/prep/standards/html_node/Releases.html
# ---------------------------------
.PHONY: dist
dist: $(BINDIR)/$(BINARY)$(BINSUF)
@echo Creating a binary distribution... please wait...
mkdir $(PROJECT_NAME)_relase
cp $(BINDIR)/* $(PROJECT_NAME)_relase
-rm $(PROJECT_NAME)_relase/remove.me
-rm $(PROJECT_NAME).tar.gz
tar -czvf $(PROJECT_NAME).tar.gz $(PROJECT_NAME)_relase
rm -rf $(PROJECT_NAME)_relase
@echo Done. The file is at $(PROJECT_NAME).tar.gz
# ---------------------------------
# Cleans and do again (rebuild)
# ---------------------------------
.PHONY: rebuild
rebuild: clean all
# ---------------------------------
# Help -- shows available targets
# ---------------------------------
.PHONY: help
help: adbanner
@echo "--------"
@echo "- Help -"
@echo "--------"
@echo "make all } Compile the entire program."
@echo "make rebuild } Cleans and builds."
@echo "make clean } Clean objects and binary."
@echo "make install } Install."
@echo "make install-strip } Install compressed and stripped (saves disk space)."
@echo "make uninstall } Uninstall."
@echo "make upx } Strip, and compress binary with UPX."
@echo "make dist } Create a distribution file for this program."
#@echo "make check } Perform self-tests (if any)."
@echo "make status } Show configuration status and detected platform."
@echo "make help } Show this help."
# ---------------------------------
# Little ad for my website and updates.
# ---------------------------------
.PHONY: adbanner
adbanner:
@echo "~ AlMake makefile system - http://almake.sf.net/ ~"