X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=Makefile;h=1811809c8c20de394c4e327c90526705cdb3770c;hb=f4a95afcaadfb89fb8ba62b221d3d2bcda7abdb0;hp=4d632431569b71de74db7b095f25a76b4af8df90;hpb=6e07bc2171f82f6e85d91224bbe54f80db7f13de;p=neverball diff --git a/Makefile b/Makefile index 4d63243..1811809 100644 --- a/Makefile +++ b/Makefile @@ -1,207 +1,403 @@ -#------------------------------------------------------------------------------- +#------------------------------------------------------------------------------ + +VERSION := $(shell sh scripts/version.sh) +ifeq ($(VERSION),unknown) + $(warning Failed to obtain sane version for this build.) +endif -#VERSION=1.5.0 -VERSION= $(shell sh scripts/version.sh) +# Provide a target system hint for the Makefile. -ifeq ($(VERSION),) - $(error Failed to obtain version for this build) +ifeq ($(shell uname), Darwin) + DARWIN := 1 endif #------------------------------------------------------------------------------ +# Optional flags (CFLAGS, CPPFLAGS, ...) + +ifeq ($(DEBUG),1) + CFLAGS := -g + CPPFLAGS := +else + CFLAGS := -O2 + CPPFLAGS := -DNDEBUG +endif -# Maybe you need one of these. Maybe you don't. +#------------------------------------------------------------------------------ +# Mandatory flags -#X11_PATH= -L/usr/X11/lib -#X11_PATH= -L/usr/X11R6/lib +# Compiler... -OGL_LIBS= -lGL -lm -#OGL_LIBS= -lm # Think Different +SSE_CFLAGS := $(shell env CC="$(CC)" sh scripts/get-sse-cflags.sh) -CFLAGS= -Wall -g -O3 -ansi -pedantic $(shell sdl-config --cflags) -#CFLAGS= -Wall -g -O1 -ansi -pedantic $(shell sdl-config --cflags) -#CFLAGS= -Wall -pg -ansi $(shell sdl-config --cflags) +ifeq ($(ENABLE_WII),1) + # -std=c99 because we need isnormal and -fms-extensions because + # libwiimote headers make heavy use of the "unnamed fields" GCC + # extension. -CPPFLAGS := -DVERSION=\"$(VERSION)\" -Ishare $(CPPFLAGS) + ALL_CFLAGS := -Wall -std=c99 -pedantic -fms-extensions \ + $(SSE_CFLAGS) $(CFLAGS) +else + ALL_CFLAGS := -Wall -ansi -pedantic $(SSE_CFLAGS) $(CFLAGS) +endif -SDL_LIBS= $(shell sdl-config --libs) -PNG_LIBS= $(shell libpng-config --libs) +# Preprocessor... -MAPC_TARG= mapc$(EXT) -BALL_TARG= neverball$(EXT) -PUTT_TARG= neverputt$(EXT) +SDL_CPPFLAGS := $(shell sdl-config --cflags) -U_GNU_SOURCE +PNG_CPPFLAGS := $(shell libpng-config --cflags) -MAPC_EXEC= ./$(MAPC_TARG) +ALL_CPPFLAGS := $(SDL_CPPFLAGS) $(PNG_CPPFLAGS) -Ishare \ + -DVERSION=\"$(VERSION)\" -LOCALEDIR= locale -LOCALEDOM= neverball +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 -POTFILE= po/neverball.pot +ALL_CPPFLAGS += $(CPPFLAGS) -#------------------------------------------------------------------------------- +#------------------------------------------------------------------------------ +# Libraries + +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 +# 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 + endif + + TILT_LIBS := + OGL_LIBS := -lopengl32 -lm +endif -MAPC_OBJS= \ - share/vec3.o \ +ifdef DARWIN + ifneq ($(ENABLE_NLS),0) + INTL_LIBS := -lintl + endif + + TILT_LIBS := + OGL_LIBS := -framework OpenGL +endif + +BASE_LIBS := -ljpeg $(PNG_LIBS) $(FS_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 := \ + share/vec3.o \ share/base_image.o \ - share/solid.o \ - share/binary.o \ + 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/i18n.o \ - share/st_lang.o \ - share/st_resol.o \ - share/vec3.o \ - share/base_image.o \ - share/image.o \ - share/solid.o \ - share/solid_gl.o\ - share/part.o \ - share/back.o \ - share/geom.o \ - share/gui.o \ - share/base_config.o \ - share/config.o \ - share/binary.o \ - share/state.o \ - share/audio.o \ - ball/hud.o \ - ball/game.o \ - ball/level.o \ - ball/levels.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_done.o \ - ball/st_level.o \ - ball/st_over.o \ - ball/st_play.o \ - ball/st_set.o \ - ball/st_start.o \ - ball/st_title.o \ - ball/st_help.o \ - ball/st_name.o \ - ball/st_shared.o \ +BALL_OBJS := \ + share/lang.o \ + share/st_resol.o \ + share/vec3.o \ + share/base_image.o \ + share/image.o \ + share/solid.o \ + share/solid_gl.o \ + share/solid_phys.o \ + share/part.o \ + share/back.o \ + share/geom.o \ + share/item.o \ + share/ball.o \ + 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/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_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 \ + ball/st_save.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 \ + ball/st_play.o \ + ball/st_set.o \ + ball/st_start.o \ + ball/st_title.o \ + ball/st_help.o \ + ball/st_name.o \ + ball/st_shared.o \ + ball/st_pause.o \ + ball/st_ball.o \ ball/main.o -PUTT_OBJS= \ - share/i18n.o \ - share/st_lang.o \ - share/st_resol.o \ - share/vec3.o \ +PUTT_OBJS := \ + share/lang.o \ + share/st_resol.o \ + share/vec3.o \ share/base_image.o \ - share/image.o \ - share/solid.o \ - share/solid_gl.o \ - share/part.o \ - share/geom.o \ - share/back.o \ - share/base_config.o \ - share/config.o \ - share/binary.o \ - share/audio.o \ - share/state.o \ - share/gui.o \ - putt/hud.o \ - putt/game.o \ - putt/hole.o \ - putt/course.o \ - putt/st_all.o \ - putt/st_conf.o \ + 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/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 \ + putt/course.o \ + putt/st_all.o \ + putt/st_conf.o \ putt/main.o -BALL_DEPS= $(BALL_OBJS:.o=.d) -PUTT_DEPS= $(PUTT_OBJS:.o=.d) -MAPC_DEPS= $(MAPC_OBJS:.o=.d) - -BASE_LIBS= $(SDL_LIBS) -lSDL_image -LIBS= $(X11_PATH) $(BASE_LIBS) $(PNG_LIBS) -lSDL_ttf -lSDL_mixer $(OGL_LIBS) +ifdef MINGW +BALL_OBJS += neverball.ico.o +PUTT_OBJS += neverputt.ico.o +endif -MESSAGEPART= /LC_MESSAGES/$(LOCALEDOM).mo -MESSAGES= $(LINGUAS:%=$(LOCALEDIR)/%$(MESSAGEPART)) +BALL_DEPS := $(BALL_OBJS:.o=.d) +PUTT_DEPS := $(PUTT_OBJS:.o=.d) +MAPC_DEPS := $(MAPC_OBJS:.o=.d) -MAPS= $(shell find data/ -name '*.map') -SOLS= $(MAPS:%.map=%.sol) +MAPS := $(shell find data -name "*.map" \! -name "*.autosave.map") +SOLS := $(MAPS:%.map=%.sol) -POS= $(shell echo po/*.po) -LINGUAS= $(POS:po/%.po=%) +DESKTOPS := $(basename $(wildcard dist/*.desktop.in)) #------------------------------------------------------------------------------ -# Implicit rules -#------------------------------------------------------------------------------ - -%.d : %.c - $(CC) $(CFLAGS) $(CPPFLAGS) -MM -MF $@ -MT '$*.o $@' $< %.o : %.c - $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< + $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -MM -MP -MF $*.d -MT "$@" $< + $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -o $@ -c $< %.sol : %.map $(MAPC_TARG) - $(MAPC_EXEC) $< data + $(MAPC) $< data -$(LOCALEDIR)/%$(MESSAGEPART) : po/%.po - mkdir -p `dirname $@` - msgfmt -c -v -o $@ $< +%.desktop : %.desktop.in + sh scripts/translate-desktop.sh < $< > $@ + +%.ico.o: dist/ico/%.ico + echo "1 ICON \"$<\"" | $(WINDRES) -o $@ -#------------------------------------------------------------------------------ -# Main rules #------------------------------------------------------------------------------ -all : $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG) sols locales +all : $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG) sols locales desktops $(BALL_TARG) : $(BALL_OBJS) - $(CC) $(CFLAGS) -o $(BALL_TARG) $(BALL_OBJS) $(LIBS) + $(CC) $(ALL_CFLAGS) -o $(BALL_TARG) $(BALL_OBJS) $(LDFLAGS) $(ALL_LIBS) $(PUTT_TARG) : $(PUTT_OBJS) - $(CC) $(CFLAGS) -o $(PUTT_TARG) $(PUTT_OBJS) $(LIBS) + $(CC) $(ALL_CFLAGS) -o $(PUTT_TARG) $(PUTT_OBJS) $(LDFLAGS) $(ALL_LIBS) $(MAPC_TARG) : $(MAPC_OBJS) - $(CC) $(CFLAGS) -o $(MAPC_TARG) $(MAPC_OBJS) $(BASE_LIBS) + $(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 : $(MESSAGES) +locales : +ifneq ($(ENABLE_NLS),0) + $(MAKE) -C po +endif + +desktops : $(DESKTOPS) clean-src : - rm -f $(BALL_TARG) $(BALL_OBJS) $(BALL_DEPS) - rm -f $(PUTT_TARG) $(PUTT_OBJS) $(PUTT_DEPS) - rm -f $(MAPC_TARG) $(MAPC_OBJS) $(MAPC_DEPS) + $(RM) $(BALL_TARG) $(BALL_OBJS) $(BALL_DEPS) + $(RM) $(PUTT_TARG) $(PUTT_OBJS) $(PUTT_DEPS) + $(RM) $(MAPC_TARG) $(MAPC_OBJS) $(MAPC_DEPS) clean : clean-src - rm -f $(SOLS) - rm -rf $(LOCALEDIR) + $(RM) $(SOLS) + $(RM) $(DESKTOPS) + $(MAKE) -C po clean test : all ./neverball -tools : - cd tools && $(MAKE) +TAGS : + $(RM) $@ + find . -name '*.[ch]' | xargs etags -a + +#------------------------------------------------------------------------------ + +.PHONY : all sols locales clean-src clean test TAGS + +-include $(BALL_DEPS) $(PUTT_DEPS) $(MAPC_DEPS) + +#------------------------------------------------------------------------------ + +ifdef MINGW + +#------------------------------------------------------------------------------ + +INSTALLER := ../neverball-$(VERSION)-setup.exe + +MAKENSIS := makensis +MAKENSIS_FLAGS := -DVERSION=$(VERSION) -DOUTFILE=$(INSTALLER) + +TODOS := todos +FROMDOS := fromdos + +CP := cp + +TEXT_DOCS := \ + doc/AUTHORS \ + doc/MANUAL \ + CHANGES \ + COPYING \ + README + +TXT_DOCS := $(TEXT_DOCS:%=%.txt) + +#------------------------------------------------------------------------------ + +.PHONY: setup +setup: $(INSTALLER) -mingw-%: - $(MAKE) -f Makefile.mingw $* +$(INSTALLER): install-dlls convert-text-files all contrib + $(MAKENSIS) $(MAKENSIS_FLAGS) -nocd scripts/neverball.nsi + +$(INSTALLER): LDFLAGS := -s $(LDFLAGS) + +.PHONY: clean-setup +clean-setup: clean + $(RM) install-dlls.sh *.dll $(TXT_DOCS) + find data -name "*.txt" -exec $(FROMDOS) {} \; + $(MAKE) -C contrib EXT=$(EXT) clean #------------------------------------------------------------------------------ -# PO update rules + +.PHONY: install-dlls +install-dlls: install-dlls.sh + sh $< + +install-dlls.sh: $(MAPC_TARG) $(BALL_TARG) $(PUTT_TARG) + mingw-list-dlls --format=shell $^ > $@ + #------------------------------------------------------------------------------ -po/%.po : $(POTFILE) - msgmerge -U $@ $< - touch $@ - -po-update-extract : - sh scripts/extractpo.sh $(POTFILE) $(LOCALEDOM) +.PHONY: convert-text-files +convert-text-files: $(TXT_DOCS) + find data -name "*.txt" -exec $(TODOS) {} \; -po-update-merge : $(POS) +%.txt: % + $(CP) $< $@ + $(TODOS) $@ -po-update : po-update-extract po-update-merge +#------------------------------------------------------------------------------ + +.PHONY: contrib +contrib: + $(MAKE) -C contrib EXT=$(EXT) #------------------------------------------------------------------------------ -.PHONY : all sols locales clean-src clean test \ - po-update-extract po-update-merge po-update \ - tools +endif --include $(BALL_DEPS) $(PUTT_DEPS) $(MAPC_DEPS) +#------------------------------------------------------------------------------