Yay, I'm in the AUTHORS file too!
[neverball] / Makefile
index fc86dd7..21d4ed6 100644 (file)
--- a/Makefile
+++ b/Makefile
-#-------------------------------------------------------------------------------
+
+#------------------------------------------------------------------------------
 
 VERSION := $(shell sh scripts/version.sh)
-ifeq ($(VERSION),)
-    $(error Failed to obtain version for this build)
+ifeq ($(VERSION),unknown)
+    $(warning Failed to obtain sane version for this build.)
+endif
+
+# Provide a target system hint for the Makefile.
+
+ifeq ($(shell uname), Darwin)
+    DARWIN := 1
 endif
 
 #------------------------------------------------------------------------------
+# Optional flags (CFLAGS, CPPFLAGS, ...)
 
-# Optional flags
-CFLAGS := -Wall -g -ansi -pedantic
+ifeq ($(ENABLE_WII),1)
+    # libwiimote is NOT ANSI compliant
+    CFLAGS := -O2
+else
+    #CFLAGS := -Wall -g -ansi -pedantic
+    CFLAGS := -Wall -O2 -ansi -pedantic
+endif
 
+#------------------------------------------------------------------------------
 # Mandatory flags
+
+# Compiler...
+
+ALL_CFLAGS := $(CFLAGS)
+
+# Preprocessor...
+
 SDL_CPPFLAGS := $(shell sdl-config --cflags)
 PNG_CPPFLAGS := $(shell libpng-config --cflags)
 
-ALL_CFLAGS   := $(CFLAGS)
 ALL_CPPFLAGS := $(SDL_CPPFLAGS) $(PNG_CPPFLAGS) -Ishare \
     -DVERSION=\"$(VERSION)\"
 
-ifdef DISABLE_NLS
-    ALL_CPPFLAGS += -DDISABLE_NLS=1
+ifeq ($(ENABLE_NLS),0)
+    ALL_CPPFLAGS += -DENABLE_NLS=0
+else
+    ALL_CPPFLAGS += -DENABLE_NLS=1
+endif
+
+ifeq ($(ENABLE_WII),1)
+    ALL_CPPFLAGS += -DENABLE_WII=1
+endif
+
+ifdef DARWIN
+    ALL_CPPFLAGS += -I/opt/local/include
 endif
 
 ALL_CPPFLAGS += $(CPPFLAGS)
 
 #------------------------------------------------------------------------------
+# Libraries
 
 SDL_LIBS := $(shell sdl-config --libs)
 PNG_LIBS := $(shell libpng-config --libs)
 
-ifdef MINGW
-ifndef DISABLE_NLS
-    INTL_LIBS := -lintl
-endif
+# The  non-conditionalised values  below  are specific  to the  native
+# system. The native system of this Makefile is Linux (or GNU+Linux if
+# you prefer). Please be sure to  override ALL of them for each target
+# system in the conditional parts below.
+
+INTL_LIBS :=
+
+ifeq ($(ENABLE_WII),1)
+    TILT_LIBS := -lcwiimote -lbluetooth
 endif
 
+OGL_LIBS := -lGL -lm
+
 ifdef MINGW
+    ifneq ($(ENABLE_NLS),0)
+        INTL_LIBS := -lintl -liconv
+    endif
+
+    TILT_LIBS :=
     OGL_LIBS  := -lopengl32 -lm
-    BASE_LIBS := -lSDL -lSDL_image $(INTL_LIBS)
-    ALL_LIBS  := $(SDL_LIBS) -lSDL_image $(INTL_LIBS) \
-       $(PNG_LIBS) -lSDL_ttf -lSDL_mixer $(OGL_LIBS)
-else
-    OGL_LIBS  := -lGL -lm
-    BASE_LIBS := $(SDL_LIBS) -lSDL_image
-    ALL_LIBS  := $(BASE_LIBS) $(PNG_LIBS) -lSDL_ttf -lSDL_mixer $(OGL_LIBS)
 endif
 
-#------------------------------------------------------------------------------
+ifdef DARWIN
+    ifneq ($(ENABLE_NLS),0)
+        INTL_LIBS := -lintl -liconv
+    endif
 
-ifdef MINGW
-    EXT  := .exe
-    WINE := wine
+    TILT_LIBS :=
+    OGL_LIBS  := -framework OpenGL
+endif
+
+BASE_LIBS := -ljpeg $(PNG_LIBS)
+
+ifdef DARWIN
+    BASE_LIBS += -L/opt/local/lib
 endif
 
+ALL_LIBS := $(SDL_LIBS) $(BASE_LIBS) $(TILT_LIBS) $(INTL_LIBS) -lSDL_ttf \
+    -lvorbisfile $(OGL_LIBS)
+
 #------------------------------------------------------------------------------
 
+ifdef MINGW
+    EXT := .exe
+endif
+
 MAPC_TARG := mapc$(EXT)
 BALL_TARG := neverball$(EXT)
 PUTT_TARG := neverputt$(EXT)
 
+ifdef MINGW
+    MAPC := $(WINE) ./$(MAPC_TARG)
+else
+    MAPC := ./$(MAPC_TARG)
+endif
+
+
 #------------------------------------------------------------------------------
 
 MAPC_OBJS := \
@@ -79,23 +137,31 @@ BALL_OBJS := \
        share/part.o        \
        share/back.o        \
        share/geom.o        \
+       share/ball.o        \
        share/gui.o         \
        share/base_config.o \
        share/config.o      \
        share/binary.o      \
        share/state.o       \
        share/audio.o       \
+       share/text.o        \
+       share/sync.o        \
+       share/tilt.o        \
+       share/common.o      \
        ball/hud.o          \
        ball/game.o         \
+       ball/score.o        \
        ball/level.o        \
-       ball/levels.o       \
+       ball/progress.o     \
        ball/set.o          \
        ball/demo.o         \
        ball/util.o         \
        ball/st_conf.o      \
        ball/st_demo.o      \
        ball/st_save.o      \
-       ball/st_play_end.o  \
+       ball/st_goal.o      \
+       ball/st_fall_out.o  \
+       ball/st_time_out.o  \
        ball/st_done.o      \
        ball/st_level.o     \
        ball/st_over.o      \
@@ -118,6 +184,7 @@ PUTT_OBJS := \
        share/solid_gl.o    \
        share/part.o        \
        share/geom.o        \
+       share/ball.o        \
        share/back.o        \
        share/base_config.o \
        share/config.o      \
@@ -125,6 +192,8 @@ PUTT_OBJS := \
        share/audio.o       \
        share/state.o       \
        share/gui.o         \
+       share/text.o        \
+       share/sync.o        \
        putt/hud.o          \
        putt/game.o         \
        putt/hole.o         \
@@ -137,19 +206,17 @@ BALL_DEPS := $(BALL_OBJS:.o=.d)
 PUTT_DEPS := $(PUTT_OBJS:.o=.d)
 MAPC_DEPS := $(MAPC_OBJS:.o=.d)
 
-MAPS := $(shell find data -name "*.map")
+MAPS := $(shell find data -name "*.map" \! -name "*.autosave.map")
 SOLS := $(MAPS:%.map=%.sol)
 
 #------------------------------------------------------------------------------
 
-%.d : %.c
-       $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -MM -MF $@ -MT '$*.o $@' $<
-
 %.o : %.c
+       $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -MM -MP -MF $*.d -MT "$@" $<
        $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -o $@ -c $<
 
 %.sol : %.map $(MAPC_TARG)
-       $(WINE) ./$(MAPC_TARG) $< data
+       $(MAPC) $< data
 
 #------------------------------------------------------------------------------
 
@@ -164,10 +231,16 @@ $(PUTT_TARG) : $(PUTT_OBJS)
 $(MAPC_TARG) : $(MAPC_OBJS)
        $(CC) $(ALL_CFLAGS) -o $(MAPC_TARG) $(MAPC_OBJS) $(LDFLAGS) $(BASE_LIBS)
 
+# Work around some extremely helpful sdl-config scripts.
+
+ifdef MINGW
+$(MAPC_TARG) : ALL_CPPFLAGS := $(ALL_CPPFLAGS) -Umain
+endif
+
 sols : $(SOLS)
 
 locales :
-ifndef DISABLE_NLS
+ifneq ($(ENABLE_NLS),0)
        $(MAKE) -C po
 endif
 
@@ -214,12 +287,12 @@ TEXT_DOCS := \
 
 TXT_DOCS := $(TEXT_DOCS:%=%.txt)
 
-#-----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
 
 .PHONY: setup
 setup: $(INSTALLER)
 
-$(INSTALLER): install-dlls convert-text-files all tools
+$(INSTALLER): install-dlls convert-text-files all contrib
        $(MAKENSIS) $(MAKENSIS_FLAGS) -nocd scripts/neverball.nsi
 
 $(INSTALLER): LDFLAGS := -s $(LDFLAGS)
@@ -228,9 +301,9 @@ $(INSTALLER): LDFLAGS := -s $(LDFLAGS)
 clean-setup: clean
        $(RM) install-dlls.sh *.dll $(TXT_DOCS)
        find data -name "*.txt" -exec $(FROMDOS) {} \;
-       $(MAKE) -C tools EXT=$(EXT) clean
+       $(MAKE) -C contrib EXT=$(EXT) clean
 
-#-----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
 
 .PHONY: install-dlls
 install-dlls: install-dlls.sh
@@ -247,7 +320,7 @@ install-dlls.sh:
        @echo --------------------------------------------------------
        @exit 1
 
-#-----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
 
 .PHONY: convert-text-files
 convert-text-files: $(TXT_DOCS)
@@ -257,11 +330,11 @@ convert-text-files: $(TXT_DOCS)
        $(CP) $< $@
        $(TODOS) $@
 
-#-----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
 
-.PHONY: tools
-tools:
-       $(MAKE) -C tools EXT=$(EXT)
+.PHONY: contrib
+contrib:
+       $(MAKE) -C contrib EXT=$(EXT)
 
 #------------------------------------------------------------------------------