author | Ryan C. Gordon <icculus@icculus.org> |
Mon, 16 Jul 2001 10:31:03 +0000 | |
changeset 36 | 60b6076ae5c2 |
parent 34 | 86c247b7be8d |
child 43 | 8a68085acebf |
permissions | -rw-r--r-- |
9 | 1 |
#-----------------------------------------------------------------------------# |
2 |
# PhysicsFS -- A filesystem abstraction. |
|
3 |
# |
|
4 |
# Please see the file LICENSE in the source's root directory. |
|
5 |
# This file written by Ryan C. Gordon. |
|
6 |
#-----------------------------------------------------------------------------# |
|
7 |
||
8 |
||
9 |
#-----------------------------------------------------------------------------# |
|
10 |
# Makefile for building PhysicsFS on Unix-like systems. Follow the |
|
11 |
# instructions for editing this file, then run "make" on the command line. |
|
12 |
#-----------------------------------------------------------------------------# |
|
13 |
||
14 |
||
15 |
#-----------------------------------------------------------------------------# |
|
16 |
# Set to your liking. |
|
17 |
#-----------------------------------------------------------------------------# |
|
18 |
CC = gcc |
|
19 |
LINKER = gcc |
|
20 |
||
21 |
||
22 |
#-----------------------------------------------------------------------------# |
|
23 |
# If this makefile fails to detect Cygwin correctly, or you want to force |
|
24 |
# the build process's behaviour, set it to "true" or "false" (w/o quotes). |
|
25 |
#-----------------------------------------------------------------------------# |
|
26 |
#cygwin := true |
|
27 |
#cygwin := false |
|
28 |
cygwin := autodetect |
|
29 |
||
30 |
#-----------------------------------------------------------------------------# |
|
31 |
# Set this to true if you want to create a debug build. |
|
32 |
#-----------------------------------------------------------------------------# |
|
33 |
#debugging := false |
|
34 |
debugging := true |
|
35 |
||
36 |
#-----------------------------------------------------------------------------# |
|
37 |
# Set the archive types you'd like to support. |
|
38 |
# Note that various archives may need external libraries. |
|
39 |
#-----------------------------------------------------------------------------# |
|
40 |
use_archive_zip := false |
|
21
b1ea58d70a56
Archive implementation (Build Groupfiles), other tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
20
diff
changeset
|
41 |
use_archive_grp := true |
9 | 42 |
|
43 |
#-----------------------------------------------------------------------------# |
|
44 |
# Set to "true" if you'd like to build a DLL. Set to "false" otherwise. |
|
45 |
#-----------------------------------------------------------------------------# |
|
46 |
#build_dll := false |
|
47 |
build_dll := true |
|
48 |
||
49 |
#-----------------------------------------------------------------------------# |
|
50 |
# Set one of the below. Currently, none of these are used. |
|
51 |
#-----------------------------------------------------------------------------# |
|
52 |
#use_asm = -DUSE_I386_ASM |
|
53 |
use_asm = -DUSE_PORTABLE_C |
|
54 |
||
55 |
||
56 |
#-----------------------------------------------------------------------------# |
|
57 |
#-----------------------------------------------------------------------------# |
|
58 |
#-----------------------------------------------------------------------------# |
|
59 |
#-----------------------------------------------------------------------------# |
|
60 |
# Everything below this line is probably okay. |
|
61 |
#-----------------------------------------------------------------------------# |
|
62 |
#-----------------------------------------------------------------------------# |
|
63 |
#-----------------------------------------------------------------------------# |
|
64 |
#-----------------------------------------------------------------------------# |
|
65 |
||
66 |
||
67 |
#-----------------------------------------------------------------------------# |
|
68 |
# CygWin autodetect. |
|
69 |
#-----------------------------------------------------------------------------# |
|
70 |
||
71 |
ifeq ($(strip $(cygwin)),autodetect) |
|
72 |
ifneq ($(strip $(shell gcc -v 2>&1 |grep "cygwin")),) |
|
73 |
cygwin := true |
|
74 |
else |
|
75 |
cygwin := false |
|
76 |
endif |
|
77 |
endif |
|
78 |
||
79 |
||
80 |
#-----------------------------------------------------------------------------# |
|
81 |
# Platform-specific binary stuff. |
|
82 |
#-----------------------------------------------------------------------------# |
|
83 |
||
84 |
ifeq ($(strip $(cygwin)),true) |
|
85 |
# !!! FIXME |
|
86 |
build_dll := false |
|
87 |
# !!! FIXME |
|
88 |
||
89 |
ASM = nasmw |
|
90 |
EXE_EXT = .exe |
|
91 |
DLL_EXT = .dll |
|
92 |
STATICLIB_EXT = .a |
|
93 |
ASMOBJFMT = win32 |
|
94 |
ASMDEFS = -dC_IDENTIFIERS_UNDERSCORED |
|
95 |
CFLAGS += -DC_IDENTIFIERS_UNDERSCORED |
|
96 |
else |
|
97 |
ASM = nasm |
|
98 |
EXE_EXT = |
|
99 |
DLL_EXT = .so |
|
100 |
STATICLIB_EXT = .a |
|
101 |
ASMOBJFMT = elf |
|
102 |
endif |
|
103 |
||
104 |
ifeq ($(strip $(build_dll)),true) |
|
105 |
LIB_EXT := $(DLL_EXT) |
|
34 | 106 |
SHAREDFLAGS += -shared |
9 | 107 |
else |
108 |
LIB_EXT := $(STATICLIB_EXT) |
|
109 |
endif |
|
110 |
||
111 |
#-----------------------------------------------------------------------------# |
|
112 |
# General compiler, assembler, and linker flags. |
|
113 |
#-----------------------------------------------------------------------------# |
|
114 |
||
115 |
BINDIR := bin |
|
116 |
SRCDIR := . |
|
117 |
||
36
60b6076ae5c2
Added readline library to test program.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
118 |
CFLAGS += $(use_asm) -I$(SRCDIR) -I/usr/include/readline -D_REENTRANT -fsigned-char -DPLATFORM_UNIX |
13 | 119 |
CFLAGS += -Wall -Werror -fno-exceptions -fno-rtti -ansi -pedantic |
9 | 120 |
|
121 |
LDFLAGS += -lm |
|
122 |
||
123 |
ifeq ($(strip $(debugging)),true) |
|
124 |
CFLAGS += -DDEBUG -g -fno-omit-frame-pointer |
|
125 |
LDFLAGS += -g -fno-omit-frame-pointer |
|
126 |
else |
|
127 |
CFLAGS += -DNDEBUG -O2 -fomit-frame-pointer |
|
128 |
LDFLAGS += -O2 -fomit-frame-pointer |
|
129 |
endif |
|
130 |
||
131 |
ASMFLAGS := -f $(ASMOBJFMT) $(ASMDEFS) |
|
132 |
||
36
60b6076ae5c2
Added readline library to test program.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
133 |
TESTLDFLAGS := -lreadline |
9 | 134 |
|
135 |
#-----------------------------------------------------------------------------# |
|
136 |
# Source and target names. |
|
137 |
#-----------------------------------------------------------------------------# |
|
138 |
||
139 |
BASELIBNAME := physfs |
|
140 |
MAINLIB := $(BINDIR)/$(strip $(BASELIBNAME))$(strip $(LIB_EXT)) |
|
141 |
||
34 | 142 |
TESTSRCS := test/test_physfs.c |
143 |
||
18 | 144 |
MAINSRCS := physfs.c platform/unix.c archivers/dir.c |
9 | 145 |
|
146 |
ifeq ($(strip $(use_archive_zip)),true) |
|
18 | 147 |
MAINSRCS += archivers/zip.c |
9 | 148 |
CFLAGS += -DPHYSFS_SUPPORTS_ZIP |
149 |
endif |
|
150 |
||
22
49f6101707b4
More tweaks; GRP completely implemented. Everything builds clean.
Ryan C. Gordon <icculus@icculus.org>
parents:
21
diff
changeset
|
151 |
ifeq ($(strip $(use_archive_grp)),true) |
49f6101707b4
More tweaks; GRP completely implemented. Everything builds clean.
Ryan C. Gordon <icculus@icculus.org>
parents:
21
diff
changeset
|
152 |
MAINSRCS += archivers/grp.c |
49f6101707b4
More tweaks; GRP completely implemented. Everything builds clean.
Ryan C. Gordon <icculus@icculus.org>
parents:
21
diff
changeset
|
153 |
CFLAGS += -DPHYSFS_SUPPORTS_GRP |
49f6101707b4
More tweaks; GRP completely implemented. Everything builds clean.
Ryan C. Gordon <icculus@icculus.org>
parents:
21
diff
changeset
|
154 |
endif |
49f6101707b4
More tweaks; GRP completely implemented. Everything builds clean.
Ryan C. Gordon <icculus@icculus.org>
parents:
21
diff
changeset
|
155 |
|
34 | 156 |
TESTEXE := $(BINDIR)/test_physfs$(EXE_EXT) |
157 |
||
9 | 158 |
# Rule for getting list of objects from source |
159 |
MAINOBJS1 := $(MAINSRCS:.c=.o) |
|
160 |
MAINOBJS2 := $(MAINOBJS1:.cpp=.o) |
|
161 |
MAINOBJS3 := $(MAINOBJS2:.asm=.o) |
|
162 |
MAINOBJS := $(foreach f,$(MAINOBJS3),$(BINDIR)/$(f)) |
|
163 |
MAINSRCS := $(foreach f,$(MAINSRCS),$(SRCDIR)/$(f)) |
|
164 |
||
34 | 165 |
TESTOBJS1 := $(TESTSRCS:.c=.o) |
166 |
TESTOBJS2 := $(TESTOBJS1:.cpp=.o) |
|
167 |
TESTOBJS3 := $(TESTOBJS2:.asm=.o) |
|
168 |
TESTOBJS := $(foreach f,$(TESTOBJS3),$(BINDIR)/$(f)) |
|
169 |
TESTSRCS := $(foreach f,$(TESTSRCS),$(SRCDIR)/$(f)) |
|
170 |
||
9 | 171 |
CLEANUP = $(wildcard *.exe) $(wildcard *.obj) \ |
172 |
$(wildcard $(BINDIR)/*.exe) $(wildcard $(BINDIR)/*.obj) \ |
|
173 |
$(wildcard *~) $(wildcard *.err) \ |
|
174 |
$(wildcard .\#*) core |
|
175 |
||
176 |
||
177 |
#-----------------------------------------------------------------------------# |
|
178 |
# Rules. |
|
179 |
#-----------------------------------------------------------------------------# |
|
180 |
||
181 |
# Rules for turning source files into .o files |
|
182 |
$(BINDIR)/%.o: $(SRCDIR)/%.cpp |
|
183 |
$(CC) -c -o $@ $< $(CFLAGS) |
|
184 |
||
185 |
$(BINDIR)/%.o: $(SRCDIR)/%.c |
|
186 |
$(CC) -c -o $@ $< $(CFLAGS) |
|
187 |
||
188 |
$(BINDIR)/%.o: $(SRCDIR)/%.asm |
|
189 |
$(ASM) $(ASMFLAGS) -o $@ $< |
|
190 |
||
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
191 |
.PHONY: all clean distclean listobjs |
9 | 192 |
|
34 | 193 |
all: $(BINDIR) $(MAINLIB) $(TESTEXE) |
9 | 194 |
|
195 |
$(MAINLIB) : $(BINDIR) $(MAINOBJS) |
|
34 | 196 |
$(LINKER) -o $(MAINLIB) $(LDFLAGS) $(SHAREDFLAGS) $(MAINOBJS) |
197 |
||
198 |
$(TESTEXE) : $(MAINLIB) $(TESTOBJS) |
|
36
60b6076ae5c2
Added readline library to test program.
Ryan C. Gordon <icculus@icculus.org>
parents:
34
diff
changeset
|
199 |
$(LINKER) -o $(TESTEXE) $(LDFLAGS) $(TESTLDFLAGS) $(TESTOBJS) $(MAINLIB) |
34 | 200 |
|
9 | 201 |
|
202 |
$(BINDIR): |
|
203 |
mkdir -p $(BINDIR) |
|
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
18
diff
changeset
|
204 |
mkdir -p $(BINDIR)/archivers |
18 | 205 |
mkdir -p $(BINDIR)/platform |
34 | 206 |
mkdir -p $(BINDIR)/test |
9 | 207 |
|
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
208 |
distclean: clean |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
209 |
|
9 | 210 |
clean: |
211 |
rm -f $(CLEANUP) |
|
212 |
rm -rf $(BINDIR) |
|
213 |
||
214 |
listobjs: |
|
215 |
@echo SOURCES: |
|
216 |
@echo $(MAINSRCS) |
|
217 |
@echo |
|
218 |
@echo OBJECTS: |
|
219 |
@echo $(MAINOBJS) |
|
220 |
@echo |
|
221 |
@echo BINARIES: |
|
222 |
@echo $(MAINLIB) |
|
223 |
||
224 |
showcfg: |
|
225 |
@echo "Using CygWin : $(cygwin)" |
|
226 |
@echo "Debugging : $(debugging)" |
|
227 |
@echo "ASM flag : $(use_asm)" |
|
228 |
@echo "Building DLLs : $(build_dll)" |
|
229 |
@echo "Supports .ZIP : $(use_archive_zip)" |
|
230 |
||
231 |
#-----------------------------------------------------------------------------# |
|
232 |
# This section is pretty much just for Ryan's use to make distributions. |
|
233 |
# You Probably Should Not Touch. |
|
234 |
#-----------------------------------------------------------------------------# |
|
235 |
||
236 |
# These are the files needed in a binary distribution, regardless of what |
|
237 |
# platform is being used. |
|
238 |
BINSCOMMON := LICENSE.TXT physfs.h |
|
239 |
||
240 |
.PHONY: package msbins win32bins nocygwin |
|
241 |
package: clean |
|
242 |
cd .. ; zip -9rz ./physfs-src-$(shell date +%m%d%Y).zip physfs -x "*CVS*" < physfs/FILEID.DIZ |
|
243 |
||
244 |
||
245 |
ifeq ($(strip $(cygwin)),true) |
|
246 |
msbins: win32bins |
|
247 |
||
248 |
win32bins: clean all |
|
249 |
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@linuxgames.com)\r\n\r\n" |zip -9rz ../physfs-win32bins-$(shell date +%m%d%Y).zip $(MAINLIB) $(EXTRAPACKAGELIBS) README-win32bins.txt |
|
250 |
||
251 |
else |
|
252 |
||
253 |
msbins: nocygwin |
|
254 |
win32bins: nocygwin |
|
255 |
||
256 |
nocygwin: |
|
257 |
@echo This must be done on a Windows box in the Cygwin environment. |
|
258 |
||
259 |
endif |
|
260 |
||
261 |
#-----------------------------------------------------------------------------# |
|
262 |
# That's all, folks. |
|
263 |
#-----------------------------------------------------------------------------# |
|
264 |
||
265 |
# end of Makefile ... |