-#
-# 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.
+#-----------------------------------------------------------------------------
+
+EXT=.exe
include Makefile
-OGL_LIBS := -lm -lopengl32 -lglu32
+MAPC_EXEC= wine $(MAPC_TARG)
+
+OGL_LIBS= -lm -lopengl32
+BASE_LIBS= $(LDFLAGS) -lSDL -lSDL_image -lintl
+LIBS= $(LDFLAGS) $(SDL_LIBS) -lSDL_image -lSDL_mixer -lSDL_ttf \
+ $(OGL_LIBS) $(PNG_LIBS) -lintl
+
+.PHONY: native
+native:
+ $(MAKE) -f Makefile.mingw MAPC_EXEC=$(MAPC_TARG)
+
+#-----------------------------------------------------------------------------
+# NSIS setup stuff
+#-----------------------------------------------------------------------------
+
+MAKENSIS= makensis
+TODOS= todos
+CP= cp
+
+TEXT_DOCS= \
+ doc/AUTHORS \
+ doc/MANUAL \
+ CHANGES \
+ COPYING \
+ README
+
+TXT_DOCS= $(TEXT_DOCS:%=%.txt)
+
+#-----------------------------------------------------------------------------
+
+.PHONY: setup
+setup: install-dlls convert-text-files all
+ $(MAKENSIS) -DVERSION=$(VERSION) -nocd scripts/neverball.nsi
+
+#-----------------------------------------------------------------------------
+
+.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
+#-----------------------------------------------------------------------------
-LIBS := $(X11_PATH) -lSDL_mixer $(SDL_LIBS) -lSDL_ttf -lSDL_image \
- $(FT2_LIBS) $(OGL_LIBS) -lintl -lpng -lz -ljpeg