Skip to content

Latest commit

 

History

History
335 lines (261 loc) · 10.9 KB

Makefile

File metadata and controls

335 lines (261 loc) · 10.9 KB
 
Jul 6, 2001
Jul 6, 2001
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
#-----------------------------------------------------------------------------#
# PhysicsFS -- A filesystem abstraction.
#
# Please see the file LICENSE in the source's root directory.
# This file written by Ryan C. Gordon.
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# Makefile for building PhysicsFS on Unix-like systems. Follow the
# instructions for editing this file, then run "make" on the command line.
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# Set to your liking.
#-----------------------------------------------------------------------------#
CC = gcc
LINKER = gcc
#-----------------------------------------------------------------------------#
# If this makefile fails to detect Cygwin correctly, or you want to force
# the build process's behaviour, set it to "true" or "false" (w/o quotes).
#-----------------------------------------------------------------------------#
#cygwin := true
#cygwin := false
cygwin := autodetect
#-----------------------------------------------------------------------------#
# Set this to true if you want to create a debug build.
#-----------------------------------------------------------------------------#
#debugging := false
debugging := true
#-----------------------------------------------------------------------------#
# Set the archive types you'd like to support.
# Note that various archives may need external libraries.
#-----------------------------------------------------------------------------#
Jul 23, 2001
Jul 23, 2001
40
use_archive_zip := true
Jul 8, 2001
Jul 8, 2001
41
use_archive_grp := true
Jul 6, 2001
Jul 6, 2001
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#-----------------------------------------------------------------------------#
# Set to "true" if you'd like to build a DLL. Set to "false" otherwise.
#-----------------------------------------------------------------------------#
#build_dll := false
build_dll := true
#-----------------------------------------------------------------------------#
# Set one of the below. Currently, none of these are used.
#-----------------------------------------------------------------------------#
#use_asm = -DUSE_I386_ASM
use_asm = -DUSE_PORTABLE_C
Aug 1, 2001
Aug 1, 2001
56
57
58
59
60
61
62
63
#-----------------------------------------------------------------------------#
# Set this to where you want PhysicsFS installed. It will put the
# files in $(install_prefix)/bin, $(install_prefix)/lib, and
# $(install_prefix)/include ...
#-----------------------------------------------------------------------------#
install_prefix := /usr/local
Jul 6, 2001
Jul 6, 2001
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
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# Everything below this line is probably okay.
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# CygWin autodetect.
#-----------------------------------------------------------------------------#
ifeq ($(strip $(cygwin)),autodetect)
ifneq ($(strip $(shell gcc -v 2>&1 |grep "cygwin")),)
cygwin := true
else
cygwin := false
endif
endif
#-----------------------------------------------------------------------------#
# Platform-specific binary stuff.
#-----------------------------------------------------------------------------#
ifeq ($(strip $(cygwin)),true)
# !!! FIXME
build_dll := false
# !!! FIXME
ASM = nasmw
EXE_EXT = .exe
DLL_EXT = .dll
STATICLIB_EXT = .a
ASMOBJFMT = win32
ASMDEFS = -dC_IDENTIFIERS_UNDERSCORED
CFLAGS += -DC_IDENTIFIERS_UNDERSCORED
else
ASM = nasm
EXE_EXT =
DLL_EXT = .so
STATICLIB_EXT = .a
ASMOBJFMT = elf
endif
ifeq ($(strip $(build_dll)),true)
LIB_EXT := $(DLL_EXT)
Jul 15, 2001
Jul 15, 2001
113
SHAREDFLAGS += -shared
Jul 6, 2001
Jul 6, 2001
114
115
116
117
else
LIB_EXT := $(STATICLIB_EXT)
endif
Aug 1, 2001
Aug 1, 2001
118
119
120
121
122
123
124
125
126
127
128
129
130
#-----------------------------------------------------------------------------#
# Version crapola.
#-----------------------------------------------------------------------------#
VERMAJOR := $(shell grep "define PHYSFS_VER_MAJOR" physfs.h | sed "s/\#define PHYSFS_VER_MAJOR //")
VERMINOR := $(shell grep "define PHYSFS_VER_MINOR" physfs.h | sed "s/\#define PHYSFS_VER_MINOR //")
VERPATCH := $(shell grep "define PHYSFS_VER_PATCH" physfs.h | sed "s/\#define PHYSFS_VER_PATCH //")
VERMAJOR := $(strip $(VERMAJOR))
VERMINOR := $(strip $(VERMINOR))
VERPATCH := $(strip $(VERPATCH))
VERFULL := $(VERMAJOR).$(VERMINOR).$(VERPATCH)
Jul 6, 2001
Jul 6, 2001
131
132
133
134
135
136
137
#-----------------------------------------------------------------------------#
# General compiler, assembler, and linker flags.
#-----------------------------------------------------------------------------#
BINDIR := bin
SRCDIR := .
Jul 16, 2001
Jul 16, 2001
138
CFLAGS += $(use_asm) -I$(SRCDIR) -I/usr/include/readline -D_REENTRANT -fsigned-char -DPLATFORM_UNIX
Mar 24, 2002
Mar 24, 2002
139
140
CFLAGS += -Wall -Werror -fno-exceptions -fno-rtti -ansi
#-pedantic
Jul 6, 2001
Jul 6, 2001
141
142
143
144
145
146
147
148
149
150
151
152
153
LDFLAGS += -lm
ifeq ($(strip $(debugging)),true)
CFLAGS += -DDEBUG -g -fno-omit-frame-pointer
LDFLAGS += -g -fno-omit-frame-pointer
else
CFLAGS += -DNDEBUG -O2 -fomit-frame-pointer
LDFLAGS += -O2 -fomit-frame-pointer
endif
ASMFLAGS := -f $(ASMOBJFMT) $(ASMDEFS)
Jul 16, 2001
Jul 16, 2001
154
TESTLDFLAGS := -lreadline
Jul 6, 2001
Jul 6, 2001
155
156
157
158
159
#-----------------------------------------------------------------------------#
# Source and target names.
#-----------------------------------------------------------------------------#
Aug 29, 2001
Aug 29, 2001
160
161
162
163
164
PUREBASELIBNAME := physfs
ifeq ($(strip $(cygwin)),true)
BASELIBNAME := $(strip $(PUREBASELIBNAME))
else
BASELIBNAME := lib$(strip $(PUREBASELIBNAME))
Aug 1, 2001
Aug 1, 2001
165
166
endif
Jul 6, 2001
Jul 6, 2001
167
168
MAINLIB := $(BINDIR)/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
Jul 15, 2001
Jul 15, 2001
169
170
TESTSRCS := test/test_physfs.c
Aug 23, 2001
Aug 23, 2001
171
MAINSRCS := physfs.c archivers/dir.c
Jul 6, 2001
Jul 6, 2001
172
173
ifeq ($(strip $(use_archive_zip)),true)
Aug 23, 2001
Aug 23, 2001
174
175
MAINSRCS += archivers/zip.c archivers/unzip.c
CFLAGS += -DPHYSFS_SUPPORTS_ZIP
Sep 1, 2001
Sep 1, 2001
176
LDFLAGS += -lz
Aug 23, 2001
Aug 23, 2001
177
ifeq ($(strip $(cygwin)),true)
Sep 1, 2001
Sep 1, 2001
178
EXTRABUILD += zlibwin32/zlib.a
Aug 23, 2001
Aug 23, 2001
179
CFLAGS += -Izlibwin32
Sep 1, 2001
Sep 1, 2001
180
LDFLAGS += -Lzlibwin32
Aug 23, 2001
Aug 23, 2001
181
endif
Aug 23, 2001
Aug 23, 2001
182
endif
Jul 6, 2001
Jul 6, 2001
183
Jul 8, 2001
Jul 8, 2001
184
185
186
187
188
ifeq ($(strip $(use_archive_grp)),true)
MAINSRCS += archivers/grp.c
CFLAGS += -DPHYSFS_SUPPORTS_GRP
endif
Aug 23, 2001
Aug 23, 2001
189
190
ifeq ($(strip $(cygwin)),true)
MAINSRCS += platform/win32.c
Aug 23, 2001
Aug 23, 2001
191
CFLAGS += -DWIN32
Aug 23, 2001
Aug 23, 2001
192
193
194
195
else
MAINSRCS += platform/unix.c
endif
Jul 15, 2001
Jul 15, 2001
196
197
TESTEXE := $(BINDIR)/test_physfs$(EXE_EXT)
Jul 6, 2001
Jul 6, 2001
198
199
200
201
202
203
204
# Rule for getting list of objects from source
MAINOBJS1 := $(MAINSRCS:.c=.o)
MAINOBJS2 := $(MAINOBJS1:.cpp=.o)
MAINOBJS3 := $(MAINOBJS2:.asm=.o)
MAINOBJS := $(foreach f,$(MAINOBJS3),$(BINDIR)/$(f))
MAINSRCS := $(foreach f,$(MAINSRCS),$(SRCDIR)/$(f))
Jul 15, 2001
Jul 15, 2001
205
206
207
208
209
210
TESTOBJS1 := $(TESTSRCS:.c=.o)
TESTOBJS2 := $(TESTOBJS1:.cpp=.o)
TESTOBJS3 := $(TESTOBJS2:.asm=.o)
TESTOBJS := $(foreach f,$(TESTOBJS3),$(BINDIR)/$(f))
TESTSRCS := $(foreach f,$(TESTSRCS),$(SRCDIR)/$(f))
Jul 6, 2001
Jul 6, 2001
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
CLEANUP = $(wildcard *.exe) $(wildcard *.obj) \
$(wildcard $(BINDIR)/*.exe) $(wildcard $(BINDIR)/*.obj) \
$(wildcard *~) $(wildcard *.err) \
$(wildcard .\#*) core
#-----------------------------------------------------------------------------#
# Rules.
#-----------------------------------------------------------------------------#
# Rules for turning source files into .o files
$(BINDIR)/%.o: $(SRCDIR)/%.cpp
$(CC) -c -o $@ $< $(CFLAGS)
$(BINDIR)/%.o: $(SRCDIR)/%.c
$(CC) -c -o $@ $< $(CFLAGS)
$(BINDIR)/%.o: $(SRCDIR)/%.asm
$(ASM) $(ASMFLAGS) -o $@ $<
Aug 1, 2001
Aug 1, 2001
231
.PHONY: all clean distclean listobjs install
Jul 6, 2001
Jul 6, 2001
232
Sep 1, 2001
Sep 1, 2001
233
all: $(BINDIR) $(EXTRABUILD) $(MAINLIB) $(TESTEXE)
Jul 6, 2001
Jul 6, 2001
234
235
$(MAINLIB) : $(BINDIR) $(MAINOBJS)
Sep 1, 2001
Sep 1, 2001
236
$(LINKER) -o $(MAINLIB) $(SHAREDFLAGS) $(MAINOBJS) $(LDFLAGS)
Jul 15, 2001
Jul 15, 2001
237
238
$(TESTEXE) : $(MAINLIB) $(TESTOBJS)
Mar 16, 2002
Mar 16, 2002
239
$(LINKER) -o $(TESTEXE) $(TESTOBJS) -L$(BINDIR) -l$(strip $(PUREBASELIBNAME)) $(LDFLAGS) $(TESTLDFLAGS)
Jul 15, 2001
Jul 15, 2001
240
Jul 6, 2001
Jul 6, 2001
241
Aug 1, 2001
Aug 1, 2001
242
install: all
Sep 14, 2001
Sep 14, 2001
243
rm -f $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERMAJOR)).$(strip $(VERMINOR)).*
Aug 1, 2001
Aug 1, 2001
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
mkdir -p $(install_prefix)/bin
mkdir -p $(install_prefix)/lib
mkdir -p $(install_prefix)/include
cp $(SRCDIR)/physfs.h $(install_prefix)/include
cp $(TESTEXE) $(install_prefix)/bin
ifeq ($(strip $(cygwin)),true)
cp $(MAINLIB) $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
else
cp $(MAINLIB) $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERFULL))
ln -sf $(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERFULL)) $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
ln -sf $(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERFULL)) $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERMAJOR))
chmod 0755 $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERFULL))
chmod 0644 $(install_prefix)/include/physfs.h
endif
Jul 6, 2001
Jul 6, 2001
259
260
$(BINDIR):
mkdir -p $(BINDIR)
Jul 8, 2001
Jul 8, 2001
261
mkdir -p $(BINDIR)/archivers
Jul 7, 2001
Jul 7, 2001
262
mkdir -p $(BINDIR)/platform
Jul 15, 2001
Jul 15, 2001
263
mkdir -p $(BINDIR)/test
Jul 6, 2001
Jul 6, 2001
264
Sep 1, 2001
Sep 1, 2001
265
266
267
268
269
270
271
ifeq ($(strip $(cygwin)),true)
zlibwin32/zlib.a:
cd zlibwin32 ; $(MAKE) CC=$(CC)
endif
Jul 6, 2001
Jul 6, 2001
272
273
distclean: clean
Jul 6, 2001
Jul 6, 2001
274
275
276
clean:
rm -f $(CLEANUP)
rm -rf $(BINDIR)
Sep 1, 2001
Sep 1, 2001
277
278
279
ifeq ($(strip $(cygwin)),true)
cd zlibwin32 ; $(MAKE) clean
endif
Jul 6, 2001
Jul 6, 2001
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
listobjs:
@echo SOURCES:
@echo $(MAINSRCS)
@echo
@echo OBJECTS:
@echo $(MAINOBJS)
@echo
@echo BINARIES:
@echo $(MAINLIB)
showcfg:
@echo "Using CygWin : $(cygwin)"
@echo "Debugging : $(debugging)"
@echo "ASM flag : $(use_asm)"
@echo "Building DLLs : $(build_dll)"
Aug 1, 2001
Aug 1, 2001
296
297
@echo "Install prefix : $(install_prefix)"
@echo "PhysFS version : $(VERFULL)"
Aug 23, 2001
Aug 23, 2001
298
@echo "Supports .GRP : $(use_archive_grp)"
Jul 6, 2001
Jul 6, 2001
299
300
301
302
303
304
305
306
307
308
309
310
311
@echo "Supports .ZIP : $(use_archive_zip)"
#-----------------------------------------------------------------------------#
# This section is pretty much just for Ryan's use to make distributions.
# You Probably Should Not Touch.
#-----------------------------------------------------------------------------#
# These are the files needed in a binary distribution, regardless of what
# platform is being used.
BINSCOMMON := LICENSE.TXT physfs.h
.PHONY: package msbins win32bins nocygwin
package: clean
Aug 1, 2001
Aug 1, 2001
312
cd .. ; mv physfs physfs-$(VERFULL) ; tar -cyvvf ./physfs-$(VERFULL).tar.bz2 --exclude="*CVS*" physfs-$(VERFULL) ; mv physfs-$(VERFULL) physfs
Jul 6, 2001
Jul 6, 2001
313
314
315
316
317
318
ifeq ($(strip $(cygwin)),true)
msbins: win32bins
win32bins: clean all
Aug 7, 2001
Aug 7, 2001
319
echo -e "\r\n\r\n\r\nHEY YOU.\r\n\r\n\r\nTake a look at README-win32bins.txt FIRST.\r\n\r\n\r\n--ryan. (icculus@clutteredmind.org)\r\n\r\n" |zip -9rz ../physfs-win32bins-$(shell date +%m%d%Y).zip $(MAINLIB) $(EXTRAPACKAGELIBS) README-win32bins.txt
Jul 6, 2001
Jul 6, 2001
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
else
msbins: nocygwin
win32bins: nocygwin
nocygwin:
@echo This must be done on a Windows box in the Cygwin environment.
endif
#-----------------------------------------------------------------------------#
# That's all, folks.
#-----------------------------------------------------------------------------#
# end of Makefile ...