fix link errors on compilers with strict "extern" enforcement
[rofl0r-openbor.git] / Makefile
blobb5acd942f37c4a534fef7f0eec823099faa72b56
2 # OpenBOR - http://www.LavaLit.com
3 # ---------------------------------------------------------------------------------------------------
4 # Licensed under the BSD license, see LICENSE in OpenBOR root for details.
6 # Copyright (c) 2004 - 2011 OpenBOR Team
9 ifndef VERSION_NAME
10 VERSION_NAME = OpenBOR
11 endif
13 STRINGSWITCH_GEN=../stringswitch/stringswitch_gen.out
15 TARGET = $(VERSION_NAME)
16 BUILD_SDL = 1
17 BUILD_GFX = 1
18 BUILD_PTHREAD = 1
19 BUILD_SDL_IO = 1
20 ifndef NO_GL
21 BUILD_OPENGL = 1
22 BUILD_LOADGL = 1
23 CFLAGS += -DOPENGL
24 endif
25 BUILD_VORBIS = 1
26 BUILDING = 1
27 CC ?= gcc
28 INCLUDES = $(SDKPATH)/include \
29 $(SDKPATH)/include/SDL
31 #----------------------------------------------------------------------------------------------------
32 # Directories
33 #----------------------------------------------------------------------------------------------------
35 ifdef BUILD_SDL
36 INCS += sdl
37 endif
39 INCS += . \
40 source \
41 source/adpcmlib \
42 source/gamelib \
43 source/preprocessorlib \
44 source/randlib \
45 source/scriptlib \
46 source/pnglib \
47 source/pcxlib
49 ifdef BUILD_GFX
50 INCS += source/gfxlib
51 endif
53 INCS += $(INCLUDES)
55 #----------------------------------------------------------------------------------------------------
56 # Objects
57 #----------------------------------------------------------------------------------------------------
59 ADPCM = source/adpcmlib/adpcm.o
61 ifdef BUILD_GFX
62 GFX = source/gfxlib/2xSaI.o \
63 source/gfxlib/bilinear.o \
64 source/gfxlib/dotmatrix.o \
65 source/gfxlib/gfx.o \
66 source/gfxlib/hq2x.o \
67 source/gfxlib/motionblur.o \
68 source/gfxlib/scale2x.o \
69 source/gfxlib/scanline.o \
70 source/gfxlib/simple2x.o \
71 source/gfxlib/tv2x.o
72 endif
74 GAME = source/gamelib/draw.o \
75 source/gamelib/draw16.o \
76 source/gamelib/draw32.o \
77 source/gamelib/font.o \
78 source/gamelib/anigif.o \
79 source/gamelib/bitmap.o \
80 source/gamelib/screen.o \
81 source/gamelib/screen16.o \
82 source/gamelib/screen32.o \
83 source/gamelib/loadimg.o \
84 source/gamelib/palette.o \
85 source/gamelib/packfile.o \
86 source/gamelib/filecache.o \
87 source/gamelib/pixelformat.o \
88 source/gamelib/soundmix.o \
89 source/gamelib/spritef.o \
90 source/gamelib/spriteq.o \
91 source/gamelib/spritex8p16.o \
92 source/gamelib/spritex8p32.o \
93 source/gamelib/texture.o \
94 source/gamelib/texture16.o \
95 source/gamelib/commands.o \
96 source/gamelib/models.o \
97 source/gamelib/texture32.o source/gamelib/movie.o source/gamelib/menus.o
98 SCRIPT = source/scriptlib/StackedSymbolTable.o \
99 source/scriptlib/ScriptVariant.o \
100 source/scriptlib/SymbolTable.o \
101 source/scriptlib/Instruction.o \
102 source/scriptlib/Interpreter.o \
103 source/scriptlib/ImportCache.o \
104 source/scriptlib/ParserSet.o \
105 source/scriptlib/Parser.o \
106 source/scriptlib/Lexer.o \
107 source/scriptlib/Stack.o \
108 source/scriptlib/List.o \
109 source/scriptlib/SolidList.o \
110 source/preprocessorlib/pp_lexer.o \
111 source/preprocessorlib/pp_parser.o
112 RAND = source/randlib/rand32.o
113 PNG = source/pnglib/pngdec.o source/pnglib/savepng.o
114 SOURCE = source/stringptr.o \
115 source/utils.o \
116 source/stristr.o
119 ifdef BUILD_SDL
120 GAME += source/gamelib/filters.o
121 endif
125 ifdef BUILD_SDL_IO
126 GAME_CONSOLE += sdl/joysticks.o \
127 sdl/control.o \
128 sdl/sblaster.o \
129 sdl/timer.o \
130 sdl/sdlport.o \
131 sdl/video.o \
132 sdl/menu.o
133 endif
136 ifdef BUILD_OPENGL
137 GAME_CONSOLE += sdl/opengl.o
138 endif
141 ifdef BUILD_LOADGL
142 GAME_CONSOLE += sdl/loadgl.o
143 endif
145 MAIN = openbor.o data.o openborscript.o
147 OBJS = $(MAIN) $(GAME_CONSOLE) $(ADPCM) $(GFX) $(GAME) $(SOURCE) $(SCRIPT) $(RAND) $(PNG)
150 #----------------------------------------------------------------------------------------------------
151 # Compiler Flags
152 #----------------------------------------------------------------------------------------------------
154 CFLAGS += $(addprefix -I", $(addsuffix ", $(INCS))) $(ARCHFLAGS)
155 CFLAGS += -Wall -fsigned-char
157 ifndef BUILD_DEBUG
158 CFLAGS += -fno-ident -freorder-blocks
159 else
160 CFLAGS += -DDEBUG -O0 -g
161 ifdef NO_RAM_DEBUGGER
162 CFLAGS += -DNO_RAM_DEBUGGER
163 endif
164 endif
166 ifdef BUILD_SDL
167 CFLAGS += -DSDL
168 endif
170 ifdef BUILD_VORBIS
171 CFLAGS += -DOV_EXCLUDE_STATIC_CALLBACKS
172 endif
175 ifdef BUILD_TREMOR
176 CFLAGS += -DTREMOR
177 endif
180 ifdef BUILD_OPENGL
181 CFLAGS += -DOPENGL
182 endif
185 ifdef BUILD_LOADGL
186 CFLAGS += -DLOADGL
187 endif
190 ifdef BUILD_GLES
191 CFLAGS += -DGLES
192 endif
195 ifdef BUILD_VERBOSE
196 CFLAGS += -DVERBOSE
197 endif
200 CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
201 ASFLAGS = $(CFLAGS)
203 #----------------------------------------------------------------------------------------------------
204 # Library
205 #----------------------------------------------------------------------------------------------------
207 LIBS = $(addprefix -L", $(addsuffix ", $(LIBRARIES)))
210 ifdef BUILD_SDL
211 LIBS += -lSDL -lSDL_gfx
212 endif
215 ifdef BUILD_PTHREAD
216 LIBS += -lpthread
217 endif
219 ifdef BUILD_STATIC
220 LIBS += -static
221 endif
223 ifdef BUILD_VORBIS
224 LIBS += -lvorbisfile -lvorbis -logg
225 endif
227 ifdef BUILD_TREMOR
228 LIBS += -lvorbisidec
229 endif
232 LIBS += -lpng -lz -lm
235 #----------------------------------------------------------------------------------------------------
236 # Rules to manage Files and Libraries for SDL
237 #----------------------------------------------------------------------------------------------------
239 all : $(TARGET) $(TARGET_FINAL)
240 @echo
241 %.o : %.asm
242 @echo Compiling $(TARGET_PLATFORM) Port: $<...
243 @$(YASM) -D $(TARGET_PLATFORM) -f $(OBJTYPE) -m $(TARGET_ARCH) -o $@ $<
244 %.o : %.c
245 @echo Compiling $(TARGET_PLATFORM) Port: $<...
246 @echo $(CC) $(CFLAGS) -c $< -o $@
247 @$(CC) $(CFLAGS) -c $< -o $@
248 $(TARGET) : $(OBJS) $(RES)
249 @echo
250 @echo Linking $(TARGET_PLATFORM) Port: $(TARGET)...
251 @echo $(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(TARGET_RESOURCE) $(LIBS)
252 @$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(TARGET_RESOURCE) $(LIBS)
253 @echo Completed $(TARGET_PLATFORM) Port!
254 @echo $(TARGET) is now ready!
256 #call make switch_gen to re-generate the stringswitch files
257 switch_gen:
258 $(STRINGSWITCH_GEN) openbor.c
260 clean-all: clean-releases clean
262 clean-releases:
263 @rm -rf releases/*
265 clean:
266 @echo
267 @echo "Removing All $(TARGET_PLATFORM) Files..."
268 @rm -f $(TARGET) $(TARGET_MAP) PARAM.SFO linkmap $(OBJS)
269 @echo Done!
270 @echo
272 version:
273 @echo "-------------------------------------------------------"
274 @echo "OpenBOR $(VERSION) - http://www.LavaLit.com"
275 @echo
276 @echo "Licensed under the BSD license."
277 @echo "See LICENSE and README within OpenBOR root for details."
278 @echo
279 @echo "Copyright (c) 2004 - 2011 OpenBOR Team"
280 @echo "-------------------------------------------------------"