ball/util: clean up duplicate code
[neverball] / Makefile
index c995d91..1811809 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -31,16 +31,19 @@ endif
 SSE_CFLAGS := $(shell env CC="$(CC)" sh scripts/get-sse-cflags.sh)
 
 ifeq ($(ENABLE_WII),1)
-    # libwiimote is NOT ANSI compliant (TODO, check if this is necessary.  GCC
-    # is supposed to suppress warnings from system headers.)
-    ALL_CFLAGS := $(SSE_CFLAGS) $(CFLAGS)
+    # -std=c99 because we need isnormal and -fms-extensions because
+    # libwiimote headers make heavy use of the "unnamed fields" GCC
+    # extension.
+
+    ALL_CFLAGS := -Wall -std=c99 -pedantic -fms-extensions \
+       $(SSE_CFLAGS) $(CFLAGS)
 else
-    ALL_CFLAGS := -Wall -ansi -pedantic $(SSE_FLAGS) $(CFLAGS)
+    ALL_CFLAGS := -Wall -ansi -pedantic $(SSE_CFLAGS) $(CFLAGS)
 endif
 
 # Preprocessor...
 
-SDL_CPPFLAGS := $(shell sdl-config --cflags)
+SDL_CPPFLAGS := $(shell sdl-config --cflags) -U_GNU_SOURCE
 PNG_CPPFLAGS := $(shell libpng-config --cflags)
 
 ALL_CPPFLAGS := $(SDL_CPPFLAGS) $(PNG_CPPFLAGS) -Ishare \
@@ -67,6 +70,7 @@ ALL_CPPFLAGS += $(CPPFLAGS)
 
 SDL_LIBS := $(shell sdl-config --libs)
 PNG_LIBS := $(shell libpng-config --libs)
+FS_LIBS := -lphysfs
 
 # The  non-conditionalised values  below  are specific  to the  native
 # system. The native system of this Makefile is Linux (or GNU+Linux if
@@ -83,7 +87,7 @@ OGL_LIBS := -lGL -lm
 
 ifdef MINGW
     ifneq ($(ENABLE_NLS),0)
-        INTL_LIBS := -lintl -liconv
+        INTL_LIBS := -lintl
     endif
 
     TILT_LIBS :=
@@ -92,14 +96,14 @@ endif
 
 ifdef DARWIN
     ifneq ($(ENABLE_NLS),0)
-        INTL_LIBS := -lintl -liconv
+        INTL_LIBS := -lintl
     endif
 
     TILT_LIBS :=
     OGL_LIBS  := -framework OpenGL
 endif
 
-BASE_LIBS := -ljpeg $(PNG_LIBS)
+BASE_LIBS := -ljpeg $(PNG_LIBS) $(FS_LIBS)
 
 ifdef DARWIN
     BASE_LIBS += -L/opt/local/lib
@@ -133,6 +137,12 @@ MAPC_OBJS := \
        share/solid.o       \
        share/binary.o      \
        share/base_config.o \
+       share/common.o      \
+       share/fs.o          \
+       share/fs_png.o      \
+       share/fs_jpg.o      \
+       share/dir.o         \
+       share/array.o       \
        share/mapc.o
 BALL_OBJS := \
        share/lang.o        \
@@ -142,6 +152,7 @@ BALL_OBJS := \
        share/image.o       \
        share/solid.o       \
        share/solid_gl.o    \
+       share/solid_phys.o  \
        share/part.o        \
        share/back.o        \
        share/geom.o        \
@@ -150,22 +161,36 @@ BALL_OBJS := \
        share/gui.o         \
        share/base_config.o \
        share/config.o      \
+       share/video.o       \
        share/binary.o      \
        share/state.o       \
        share/audio.o       \
        share/text.o        \
-       share/sync.o        \
        share/tilt.o        \
        share/common.o      \
        share/keynames.o    \
        share/syswm.o       \
+       share/list.o        \
+       share/queue.o       \
+       share/cmd.o         \
+       share/array.o       \
+       share/dir.o         \
+       share/fs.o          \
+       share/fs_png.o      \
+       share/fs_jpg.o      \
+       share/fs_rwops.o    \
+       share/fs_ov.o       \
        ball/hud.o          \
-       ball/game.o         \
+       ball/game_common.o  \
+       ball/game_client.o  \
+       ball/game_server.o  \
+       ball/game_proxy.o   \
        ball/score.o        \
        ball/level.o        \
        ball/progress.o     \
        ball/set.o          \
        ball/demo.o         \
+       ball/demo_dir.o     \
        ball/util.o         \
        ball/st_conf.o      \
        ball/st_demo.o      \
@@ -184,6 +209,7 @@ BALL_OBJS := \
        ball/st_name.o      \
        ball/st_shared.o    \
        ball/st_pause.o     \
+       ball/st_ball.o      \
        ball/main.o
 PUTT_OBJS := \
        share/lang.o        \
@@ -193,20 +219,29 @@ PUTT_OBJS := \
        share/image.o       \
        share/solid.o       \
        share/solid_gl.o    \
+       share/solid_phys.o  \
        share/part.o        \
        share/geom.o        \
        share/ball.o        \
        share/back.o        \
        share/base_config.o \
        share/config.o      \
+       share/video.o       \
        share/binary.o      \
        share/audio.o       \
        share/state.o       \
        share/gui.o         \
        share/text.o        \
-       share/sync.o        \
        share/common.o      \
        share/syswm.o       \
+       share/list.o        \
+       share/fs.o          \
+       share/fs_png.o      \
+       share/fs_jpg.o      \
+       share/fs_rwops.o    \
+       share/fs_ov.o       \
+       share/dir.o         \
+       share/array.o       \
        putt/hud.o          \
        putt/game.o         \
        putt/hole.o         \
@@ -215,6 +250,11 @@ PUTT_OBJS := \
        putt/st_conf.o      \
        putt/main.o
 
+ifdef MINGW
+BALL_OBJS += neverball.ico.o
+PUTT_OBJS += neverputt.ico.o
+endif
+
 BALL_DEPS := $(BALL_OBJS:.o=.d)
 PUTT_DEPS := $(PUTT_OBJS:.o=.d)
 MAPC_DEPS := $(MAPC_OBJS:.o=.d)
@@ -236,6 +276,9 @@ DESKTOPS := $(basename $(wildcard dist/*.desktop.in))
 %.desktop : %.desktop.in
        sh scripts/translate-desktop.sh < $< > $@
 
+%.ico.o: dist/ico/%.ico
+       echo "1 ICON \"$<\"" | $(WINDRES) -o $@
+
 #------------------------------------------------------------------------------
 
 all : $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG) sols locales desktops
@@ -277,9 +320,13 @@ clean : clean-src
 test : all
        ./neverball
 
+TAGS :
+       $(RM) $@
+       find . -name '*.[ch]' | xargs etags -a
+
 #------------------------------------------------------------------------------
 
-.PHONY : all sols locales clean-src clean test
+.PHONY : all sols locales clean-src clean test TAGS
 
 -include $(BALL_DEPS) $(PUTT_DEPS) $(MAPC_DEPS)
 
@@ -330,12 +377,8 @@ clean-setup: clean
 install-dlls: install-dlls.sh
        sh $<
 
-install-dlls.sh:
-       mingw-list-dlls --sh > $@
-       @echo --------------------------------------------------------
-       @echo Now edit $@ to your needs before restarting make.
-       @echo --------------------------------------------------------
-       @exit 1
+install-dlls.sh: $(MAPC_TARG) $(BALL_TARG) $(PUTT_TARG)
+       mingw-list-dlls --format=shell $^ > $@
 
 #------------------------------------------------------------------------------