Improved install and added uninstall. Added a prefix, which defaults to /usr/local...
[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.5
9
10 # April 11, 2000 - December 26, 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 # Defaults for Linux:
29
30 TARGET=supertux
31 TARGET_DEF=LINUX
32
33
34 CFLAGS=-Wall -O2 $(SDL_CFLAGS) -DDATA_PREFIX=\"$(DATA_PREFIX)\" \
35         -D$(NOSOUNDFLAG) -D$(TARGET_DEF) -DJOY_$(JOY)
36
37
38 # Other definitions:
39
40 SDL_MIXER=-lSDL_mixer
41 SDL_IMAGE=-lSDL_image
42 NOSOUNDFLAG=__SOUND
43 SDL_LIB=$(SDL_LDFLAGS) $(SDL_MIXER) $(SDL_IMAGE)
44 SDL_CFLAGS := $(shell sdl-config --cflags)
45 SDL_LDFLAGS := $(shell sdl-config --libs)
46 installbin = install -g $(USERNAME) -o $(USERNAME) -m 755 
47 installdat = install -g $(USERNAME) -o $(USERNAME) -m 644
48
49
50 OBJECTS=obj/supertux.o obj/setup.o obj/intro.o obj/title.o obj/gameloop.o \
51         obj/screen.o obj/sound.o obj/high_scores.o
52
53 # Make commands:
54
55 all:    $(TARGET)
56
57 install: $(TARGET)
58         mkdir -p $(PREFIX)/games/$(TARGET)
59         mkdir -p $(PREFIX)/share/games/$(TARGET)
60         mkdir -p $(PREFIX)/bin/
61         cp -r data $(PREFIX)/share/games/$(TARGET)/
62         chmod -R 0755 $(PREFIX)/share/games/$(TARGET)/data/
63         -$(installbin) $(TARGET) $(PREFIX)/games/$(TARGET)/$(TARGET)
64         ln -sf $(PREFIX)/games/$(TARGET)/$(TARGET) $(PREFIX)/bin/$(TARGET)
65
66 uninstall:
67         rm -r $(PREFIX)/games/$(TARGET)
68         rm -r $(PREFIX)/share/games/$(TARGET)
69         rm $(PREFIX)/bin/$(TARGET)
70
71 nosound:
72         make supertux SDL_MIXER= NOSOUNDFLAG=NOSOUND
73
74 win32:
75         make TARGET_DEF=WIN32 TARGET=supertux.exe \
76                 DATA_PREFIX=data/
77         cp /usr/local/cross-tools/i386-mingw32/lib/SDL*.dll .
78         chmod 644 SDL*.dll
79
80 clean:
81         -rm supertux supertux.exe
82         -rm obj/*.o
83         -rm SDL*.dll
84
85
86 # Main executable:
87
88 $(TARGET):      $(OBJECTS)
89         $(CC) $(CFLAGS) $(OBJECTS) -o $(TARGET) $(SDL_LIB)
90
91 # Objects:
92
93 obj/supertux.o: src/supertux.c src/defines.h src/globals.h \
94                 src/setup.h src/intro.h src/title.h src/gameloop.h \
95                 src/screen.h src/sound.h
96         $(CC) $(CFLAGS) src/supertux.c -c -o obj/supertux.o
97
98 obj/setup.o:    src/setup.c src/setup.h \
99                 src/defines.h src/globals.h src/screen.h
100         $(CC) $(CFLAGS) src/setup.c -c -o obj/setup.o
101
102 obj/intro.o:    src/intro.c src/intro.h \
103                 src/defines.h src/globals.h src/screen.h
104         $(CC) $(CFLAGS) src/intro.c -c -o obj/intro.o
105
106 obj/title.o:    src/title.c src/title.h \
107                 src/defines.h src/globals.h src/screen.h
108         $(CC) $(CFLAGS) src/title.c -c -o obj/title.o
109
110 obj/gameloop.o: src/gameloop.c src/gameloop.h \
111                 src/defines.h src/globals.h src/screen.h src/sound.h \
112                 src/setup.h
113         $(CC) $(CFLAGS) src/gameloop.c -c -o obj/gameloop.o
114
115 obj/screen.o:   src/screen.c src/defines.h src/globals.h src/screen.h
116         $(CC) $(CFLAGS) src/screen.c -c -o obj/screen.o
117
118 obj/sound.o:    src/sound.c src/defines.h src/globals.h src/sound.h
119         $(CC) $(CFLAGS) src/sound.c -c -o obj/sound.o
120
121 obj/high_scores.o:      src/high_scores.c src/defines.h src/globals.h \
122                         src/sound.h
123         $(CC) $(CFLAGS) src/high_scores.c -c -o obj/high_scores.o
124