From d4b1cda08d71b36a513b432178394fec7cd3dda1 Mon Sep 17 00:00:00 2001 From: Niels Nesse Date: Tue, 24 Nov 2015 00:59:57 -0800 Subject: [PATCH] Build system improvements for windows - Add EXE extension correctly - Detect windows with _WIN32 macro and retire UNIX macro --- Makefile | 5 ++--- Makefile.win32 | 2 +- common.mk | 12 +++++++----- src/system/init.c | 6 +++++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 03a7315..83b1519 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,4 @@ -PROG = tbftss -CC = gcc -CXXFLAGS += -DUNIX +CC=gcc +EXEEXT= include common.mk diff --git a/Makefile.win32 b/Makefile.win32 index f4a1a00..b7aae0e 100644 --- a/Makefile.win32 +++ b/Makefile.win32 @@ -1,4 +1,4 @@ -PROG = tbftss.exe +EXEEXT=.exe CC=x86_64-w64-mingw32-gcc include common.mk diff --git a/common.mk b/common.mk index a0fa1cb..385a771 100644 --- a/common.mk +++ b/common.mk @@ -1,5 +1,7 @@ PROG = tbftss +TARGET=$(PROG)$(EXEEXT) + VERSION = 0.4 REVISION = $(shell date +"%y%m%d") DEBUG = 0 @@ -8,7 +10,7 @@ CXXFLAGS += `sdl2-config --cflags` -DVERSION=$(VERSION) -DREVISION=$(REVISION) - CXXFLAGS += -Wall -ansi -pedantic -Werror -Wstrict-prototypes CXXFLAGS += -g -lefence -LIBS = `sdl2-config --libs` -lSDL2_mixer -lSDL2_image -lSDL2_ttf -lm +LIBS := `sdl2-config --libs` -lSDL2_mixer -lSDL2_image -lSDL2_ttf -lm SEARCHPATH += src/ src/battle src/draw src/game src/galaxy src/json src/system src/test vpath %.c $(SEARCHPATH) @@ -38,15 +40,15 @@ OBJS += waypoints.o widgets.o DIST_FILES = data gfx manual music sound src LICENSE makefile README.md CHANGELOG # top-level rule to create the program. -all: $(PROG) +all: $(TARGET) # compiling other source files. %.o: %.c %.h $(DEPS) $(CC) $(CFLAGS) $(CXXFLAGS) -c $< # linking the program. -$(PROG): $(OBJS) - $(CC) -o $(PROG) $(OBJS) $(LIBS) +$(TARGET): $(OBJS) + $(CC) -o $@ $(OBJS) $(LIBS) # prepare an archive for the program dist: @@ -62,6 +64,6 @@ dist: # cleaning everything that can be automatically recreated with "make". clean: - $(RM) $(OBJS) $(PROG) + $(RM) $(OBJS) $(TARGET) .PHONY: dist diff --git a/src/system/init.c b/src/system/init.c index 2870687..b1aa5ea 100644 --- a/src/system/init.c +++ b/src/system/init.c @@ -20,6 +20,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "init.h" +#ifndef _WIN32 +#define UNIX 1 +#endif + #if UNIX static void createSaveFolder(void); @@ -97,7 +101,7 @@ void initSDL(void) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Game scale factor: %.2f,%.2f\n", app.scaleX, app.scaleY); } -#if UNIX +#ifdef UNIX static void createSaveFolder(void) { char *userHome;