-#
-# A simple makefile to compile Neverball, Neverputt and mapc Windows binaries,
-# with mingw32. You must have wine installed to compile maps. You need to use
-# a script which defines the variables of your Linux mingw32 cross-compilation
-# environment (PATH, PREFIX, TARGET, CC, CXX, ...) to run this makefile. This
-# scripts is usually named "cross-make.sh". Currently you need to have SDL,
-# SDL_ttf and SDL_image DLLs in the makefile directory to compile maps.
-#
-# Mehdi.
+export EXT= .exe
+
+#-----------------------------------------------------------------------------
include Makefile
-OGL_LIBS := -lm -lopengl32 -lglu32
+#-----------------------------------------------------------------------------
+
+WINE= wine
+
+OGL_LIBS= -lm -lopengl32
+BASE_LIBS= -lSDL -lSDL_image -lintl
+
+LIBS= \
+ $(SDL_LIBS) -lSDL_image -lSDL_mixer -lSDL_ttf \
+ $(OGL_LIBS) $(PNG_LIBS) -lintl
+
+#-----------------------------------------------------------------------------
+
+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)
+
+$(INSTALLER): install-dlls convert-text-files all tools
+ $(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) {} \;
+ cd tools && $(MAKE) clean
+
+#-----------------------------------------------------------------------------
+
+.PHONY: install-dlls
+install-dlls: install-dlls.sh
+ sh $<
+
+install-dlls.sh:
+ if ! sh scripts/gen-install-dlls.sh > $@; then \
+ $(RM) $@; \
+ exit 1; \
+ fi
+ @echo --------------------------------------------------------
+ @echo You can probably ignore any file-not-found errors above.
+ @echo Now edit $@ to your needs before restarting make.
+ @echo --------------------------------------------------------
+ @exit 1
+
+#-----------------------------------------------------------------------------
+
+.PHONY: convert-text-files
+convert-text-files: $(TXT_DOCS)
+ find data -name "*.txt" -exec $(TODOS) {} \;
+
+%.txt: %
+ $(CP) $< $@
+ $(TODOS) $@
+
+#-----------------------------------------------------------------------------
-MAPC_TARG := mapc.exe
-MAPC_EXEC := wine mapc.exe
-BALL_TARG := neverball.exe
-PUTT_TARG := neverputt.exe
+.PHONY: tools
+tools:
+ cd tools && $(MAKE)
-LIBS := $(X11_PATH) -lSDL_mixer $(SDL_LIBS) -lSDL_ttf -lSDL_image \
- $(FT2_LIBS) $(OGL_LIBS) -lintl -lpng -lz -ljpeg
+#-----------------------------------------------------------------------------