improved
[supertux.git] / Makefile
index c66631e..6c89f70 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,29 +1,41 @@
 # Makefile for supertux
 
-# by Bill Kendrick
+# by Bill Kendrick & Tobias Glaesser
 # bill@newbreedsoftware.com
+# tobi.web@gmx.de
 # http://www.newbreedsoftware.com/
 
 # Version 0.0.5
 
-# April 11, 2000 - December 9, 2003
+# April 11, 2000 - December 26, 2000
 
 
 # User-definable stuff:
 
-PREFIX=/usr/local/
-DATA_PREFIX=$(PREFIX)supertux/
+ifeq ($(PREFIX),)
+ifeq ($(USERNAME),root)
+PREFIX=/usr/local
+else
+PREFIX=$(PWD)
+endif
+DATA_PREFIX=$(PWD)/data/
+else
+DATA_PREFIX=$(PREFIX)/share/games/supertux/data/
+endif
 JOY=YES
 
 
+#undefine this for non debugging compilation
+
+DEBUG_FLAG=-DDEBUG
+
 # Defaults for Linux:
 
 TARGET=supertux
 TARGET_DEF=LINUX
 
-
 CFLAGS=-Wall -O2 $(SDL_CFLAGS) -DDATA_PREFIX=\"$(DATA_PREFIX)\" \
-       -D$(NOSOUNDFLAG) -D$(TARGET_DEF) -DJOY_$(JOY)
+       -D$(NOSOUNDFLAG) -D$(TARGET_DEF) -DJOY_$(JOY) $(DEBUG_FLAG)
 
 
 # Other definitions:
@@ -34,40 +46,44 @@ NOSOUNDFLAG=__SOUND
 SDL_LIB=$(SDL_LDFLAGS) $(SDL_MIXER) $(SDL_IMAGE)
 SDL_CFLAGS := $(shell sdl-config --cflags)
 SDL_LDFLAGS := $(shell sdl-config --libs)
-installbin = install -g root -o root -m 755 
-installdat = install -g root -o root -m 644
+installbin = install -g $(USERNAME) -o $(USERNAME) -m 755 
+installdat = install -g $(USERNAME) -o $(USERNAME) -m 644
 
 
 OBJECTS=obj/supertux.o obj/setup.o obj/intro.o obj/title.o obj/gameloop.o \
-       obj/screen.o obj/sound.o
+       obj/screen.o obj/sound.o obj/high_scores.o obj/menu.o
 
 # Make commands:
 
 all:   $(TARGET)
 
 install: $(TARGET)
-       -mkdir -p $(DATA_PREFIX)
-       cp -R data/* $(DATA_PREFIX)
-       chown -R root.root $(DATA_PREFIX)
-       chmod -R a+rX $(DATA_PREFIX)
-       cp $(TARGET) $(PREFIX)bin/
-       chown root.root $(PREFIX)bin/$(TARGET)
-       chmod a+rx $(PREFIX)bin/$(TARGET)
-
+       mkdir -p $(PREFIX)/games/$(TARGET)
+       mkdir -p $(PREFIX)/share/games/$(TARGET)
+       mkdir -p $(PREFIX)/bin/
+       cp -r data $(PREFIX)/share/games/$(TARGET)/
+       chmod -R 0755 $(PREFIX)/share/games/$(TARGET)/data/
+       -$(installbin) $(TARGET) $(PREFIX)/games/$(TARGET)/$(TARGET)
+       ln -sf $(PREFIX)/games/$(TARGET)/$(TARGET) $(PREFIX)/bin/$(TARGET)
+
+uninstall:
+       rm -r $(PREFIX)/games/$(TARGET)
+       rm -r $(PREFIX)/share/games/$(TARGET)
+       rm $(PREFIX)/bin/$(TARGET)
 
 nosound:
        make supertux SDL_MIXER= NOSOUNDFLAG=NOSOUND
 
 win32:
        make TARGET_DEF=WIN32 TARGET=supertux.exe \
-               DATA_PREFIX=data
+               DATA_PREFIX=data/
        cp /usr/local/cross-tools/i386-mingw32/lib/SDL*.dll .
        chmod 644 SDL*.dll
 
 clean:
-       -rm supertux supertux.exe
-       -rm obj/*.o
-       -rm SDL*.dll
+       -rm -f supertux supertux.exe
+       -rm -f obj/*.o
+       -rm -f SDL*.dll
 
 
 # Main executable:
@@ -75,7 +91,6 @@ clean:
 $(TARGET):     $(OBJECTS)
        $(CC) $(CFLAGS) $(OBJECTS) -o $(TARGET) $(SDL_LIB)
 
-
 # Objects:
 
 obj/supertux.o:        src/supertux.c src/defines.h src/globals.h \
@@ -105,3 +120,11 @@ obj/screen.o:      src/screen.c src/defines.h src/globals.h src/screen.h
 
 obj/sound.o:   src/sound.c src/defines.h src/globals.h src/sound.h
        $(CC) $(CFLAGS) src/sound.c -c -o obj/sound.o
+
+obj/high_scores.o:     src/high_scores.c src/defines.h src/globals.h \
+                       src/sound.h
+       $(CC) $(CFLAGS) src/high_scores.c -c -o obj/high_scores.o
+
+obj/menu.o:    src/menu.c src/defines.h src/globals.h \
+                       src/sound.h
+       $(CC) $(CFLAGS) src/menu.c -c -o obj/menu.o
\ No newline at end of file