little fix for amiga(morphos)-compilation , thanks to SixK <dasixk@free.fr>
[supertux.git] / Makefile
1 # Makefile for supertux
2
3 # by Bill Kendrick & Tobias Glaesser
4 # bill@newbreedsoftware.com
5 # tobi.web@gmx.de
6 # http://www.newbreedsoftware.com/
7
8 # Version 0.0.6 (in development)
9
10 # April 11, 2000 - December 29, 2000
11
12
13 # User-definable stuff:
14
15 ifeq ($(PREFIX),)
16 ifeq ($(USERNAME),root)
17 PREFIX=/usr/local
18 else
19 PREFIX=$(PWD)
20 endif
21 DATA_PREFIX=$(PWD)/data/
22 else
23 DATA_PREFIX=$(PREFIX)/share/games/supertux/data/
24 endif
25 JOY=YES
26
27
28 #undefine this for non debugging compilation
29
30 DEBUG_FLAG=-DDEBUG
31
32 # Defaults for Linux:
33
34 TARGET=supertux
35 TARGET_DEF=LINUX
36
37 CFLAGS=-Wall -O2 $(SDL_CFLAGS) -DDATA_PREFIX=\"$(DATA_PREFIX)\" \
38         -D$(NOSOUNDFLAG) -D$(TARGET_DEF) -DJOY_$(JOY) $(DEBUG_FLAG)
39
40
41 # Other definitions:
42
43 SDL_MIXER=-lSDL_mixer
44 SDL_IMAGE=-lSDL_image
45 NOSOUNDFLAG=__SOUND
46 SDL_LIB=$(SDL_MIXER) $(SDL_IMAGE) $(SDL_LDFLAGS) 
47 SDL_CFLAGS := $(shell sdl-config --cflags)
48 SDL_LDFLAGS := $(shell sdl-config --libs)
49 installbin = install -g $(USERNAME) -o $(USERNAME) -m 755 
50 installdat = install -g $(USERNAME) -o $(USERNAME) -m 644
51
52
53 OBJECTS=obj/supertux.o obj/setup.o obj/intro.o obj/title.o obj/level.o obj/gameloop.o \
54         obj/screen.o obj/sound.o obj/high_scores.o obj/menu.o obj/leveleditor.o
55
56 # Make commands:
57
58 all:    $(TARGET)
59
60 install: $(TARGET)
61         mkdir -p $(PREFIX)/games/$(TARGET)
62         mkdir -p $(PREFIX)/share/games/$(TARGET)
63         mkdir -p $(PREFIX)/bin/
64         cp -r data $(PREFIX)/share/games/$(TARGET)/
65         chmod -R 0755 $(PREFIX)/share/games/$(TARGET)/data/
66         -$(installbin) $(TARGET) $(PREFIX)/games/$(TARGET)/$(TARGET)
67         ln -sf $(PREFIX)/games/$(TARGET)/$(TARGET) $(PREFIX)/bin/$(TARGET)
68
69 uninstall:
70         rm -r $(PREFIX)/games/$(TARGET)
71         rm -r $(PREFIX)/share/games/$(TARGET)
72         rm $(PREFIX)/bin/$(TARGET)
73
74 nosound:
75         make supertux SDL_MIXER= NOSOUNDFLAG=NOSOUND
76
77 win32:
78         make TARGET_DEF=WIN32 TARGET=supertux.exe \
79                 DATA_PREFIX=data/
80         cp /usr/local/cross-tools/i386-mingw32/lib/SDL*.dll .
81         chmod 644 SDL*.dll
82
83 clean:
84         -rm -f supertux supertux.exe
85         -rm -f obj/*.o
86         -rm -f SDL*.dll
87
88
89 # Main executable:
90
91 $(TARGET):      $(OBJECTS)
92         $(CC) $(CFLAGS) $(OBJECTS) -o $(TARGET) $(SDL_LIB)
93
94 # Objects:
95
96 obj/supertux.o: src/supertux.c src/supertux.h src/defines.h src/globals.h \
97                 obj/setup.o obj/intro.o obj/title.o obj/gameloop.o \
98                 obj/screen.o obj/sound.o obj/leveleditor.o
99         $(CC) $(CFLAGS) src/supertux.c -c -o obj/supertux.o
100
101 obj/setup.o:    src/setup.c src/setup.h obj/sound.o \
102                 src/defines.h src/globals.h obj/screen.o
103         $(CC) $(CFLAGS) src/setup.c -c -o obj/setup.o
104
105 obj/intro.o:    src/intro.c src/intro.h \
106                 src/defines.h src/globals.h src/screen.h
107         $(CC) $(CFLAGS) src/intro.c -c -o obj/intro.o
108
109 obj/title.o:    src/title.c src/title.h \
110                 src/defines.h src/globals.h src/screen.h
111         $(CC) $(CFLAGS) src/title.c -c -o obj/title.o
112
113 obj/level.o:    src/level.c src/defines.h src/globals.h \
114                         src/level.h src/gameloop.h src/screen.h src/badguy.h
115         $(CC) $(CFLAGS) src/level.c -c -o obj/level.o
116         
117 obj/gameloop.o: src/gameloop.c src/gameloop.h \
118                 src/defines.h src/globals.h src/screen.h obj/sound.o \
119                 src/setup.h obj/level.o
120         $(CC) $(CFLAGS) src/gameloop.c -c -o obj/gameloop.o
121
122 obj/screen.o:   src/screen.c src/defines.h src/globals.h src/screen.h
123         $(CC) $(CFLAGS) src/screen.c -c -o obj/screen.o
124
125 obj/sound.o:    src/sound.c src/defines.h src/globals.h src/sound.h
126         $(CC) $(CFLAGS) src/sound.c -c -o obj/sound.o
127
128 obj/high_scores.o:      src/high_scores.c src/defines.h src/globals.h \
129                                 obj/sound.o
130         $(CC) $(CFLAGS) src/high_scores.c -c -o obj/high_scores.o
131
132 obj/menu.o:     src/menu.c src/defines.h src/globals.h \
133                         obj/sound.o src/menu.h src/leveleditor.h
134         $(CC) $(CFLAGS) src/menu.c -c -o obj/menu.o
135
136 obj/leveleditor.o:      src/leveleditor.c src/defines.h src/globals.h \
137                         src/leveleditor.h src/gameloop.h src/screen.h src/badguy.h
138         $(CC) $(CFLAGS) src/leveleditor.c -c -o obj/leveleditor.o