changeset 712:3a3e4fc53ac7

Refactor the build system a bit.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 07 Dec 2022 13:19:25 +0200
parents 6b79b3438818
children 93d0e1547842
files Makefile Makefile.cross-mingw Makefile.w32
diffstat 3 files changed, 69 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Wed Dec 07 13:18:06 2022 +0200
+++ b/Makefile	Wed Dec 07 13:19:25 2022 +0200
@@ -4,10 +4,14 @@
 #
 
 # C-compiler, flags and linker flags
-CFLAGS = -DHAVE_STRING_H -DHAVE_STDINT_H -DUSE_XDG=1
-LDFLAGS = -lncurses
+#CFLAGS += -fsanitize=address
+#LDFLAGS +== -lasan
+LDFLAGS += -lncurses
 
-#CFLAGS += -DHAVE_STDINT_H
+CFLAGS += -DUSE_XDG=1
+
+CFLAGS += -DHAVE_STRING_H
+CFLAGS += -DHAVE_INTTYPES_H
 #CFLAGS += -DHAVE_SYS_TYPES_H
 
 include Makefile.unix
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile.cross-mingw	Wed Dec 07 13:19:25 2022 +0200
@@ -0,0 +1,62 @@
+###
+### For Win32/Win64 version cross-compilation via MinGW
+### compiler suite under Linux/Unix
+###
+#
+# This Makefile assumes that you have MinGW installed under /usr
+# the way Debian MinGW packages do. It also assumes that you have
+# built/installed SDL2 and PDCurses 3.9 (SDL2 variant) under
+# /usr/local (not /usr!) in similar fashion.
+#
+# For differing configurations you will have to either edit this
+# file or alternatively provide make parameters, e.g.
+#
+# make -f Makefile.cross-mingw MINGW=64 BINTOOL_PREFIX=foo-bar-zoo
+#
+ifeq ($(MINGW),64)
+BINTOOL_PREFIX ?= x86_64-w64-mingw32-
+MINGW_SYS_PATH ?= /usr/x86_64-w64-mingw32
+MINGW_LOCAL_PATH ?= /usr/local/x86_64-w64-mingw32
+OBJPATH ?= ./obj/win64/
+else
+BINTOOL_PREFIX ?= i686-w64-mingw32-
+MINGW_SYS_PATH ?= /usr/i686-w64-mingw32
+MINGW_LOCAL_PATH ?= /usr/local/i686-w64-mingw32
+OBJPATH ?= ./obj/win32/
+endif
+
+BINPATH ?= ./exe/
+BINEXT ?= .exe
+CC = $(BINTOOL_PREFIX)gcc
+AR = $(BINTOOL_PREFIX)ar
+RANLIB = $(BINTOOL_PREFIX)ranlib
+RM ?= rm
+DOC = $(BINPATH)/README.html
+WINDRES ?= $(BINTOOL_PREFIX)windres
+
+
+SDL_CFLAGS ?= $(shell $(MINGW_LOCAL_PATH)/bin/sdl2-config --cflags)
+SDL_LDFLAGS ?= $(shell $(MINGW_LOCAL_PATH)/bin/sdl2-config --libs)
+
+CFLAGS += -mwindows -DTH_BYTEORDER=TH_LITTLE_ENDIAN -I$(MINGW_LOCAL_PATH)/include $(SDL_CFLAGS)
+LDFLAGS += -lws2_32 -lole32 -mwindows $(MINGW_LOCAL_PATH)/lib/libpdcurses.a $(SDL_LDFLAGS)
+LDFLAGS += -s
+
+CFLAGS += -DHAVE_STRING_H
+CFLAGS += -DHAVE_INTTYPES_H
+
+
+###
+### Miscellaneous
+###
+EXTRAOBJS = $(OBJPATH)resource.o
+ICON = resource.ico
+
+include Makefile.gen
+
+$(OBJPATH)resource.rc: resource.rc.in $(ICON) VERSION
+	sed -e "s/@VERSION@/$(NN_VERSION)/g;s/@VERSION_COM@/$(NN_VERSION_COM)/g;s/@ICON@/$(ICON)/g;s#@EXE@#$(notdir $(NNCHAT_BIN))#g" < $< > $@
+
+$(OBJPATH)resource.o: $(OBJPATH)resource.rc
+	$(WINDRES) $< -O coff -o $@
+
--- a/Makefile.w32	Wed Dec 07 13:18:06 2022 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#
-# For win32 version cross-compilation with MinGW suite @ Linux
-#
-BINTOOL_PREFIX = i686-w64-mingw32-
-
-PREFIX  = ./win32/
-BINPATH = ./installer/
-OBJPATH = ./obj/win32/
-BINEXT  = .exe
-INSTALL = 
-DOC     = $(BINPATH)/README.html
-
-WINDRES ?= $(BINTOOL_PREFIX)windres
-
-CFLAGS += -DHAVE_STRING_H -Ipdcurses -mwindows -DTH_BYTEORDER=TH_LITTLE_ENDIAN -D_NO_BOOL_TYPEDEF
-LDFLAGS += -lws2_32 -lole32 -mwindows pdcurses/libpdcurses.a -s
-
-###
-### Miscellaneous
-###
-EXTRAOBJS = resource.o
-ICON = resource.ico
-
-include Makefile.gen
-
-resource.rc: resource.rc.in $(ICON) VERSION
-	sed -e "s/@VERSION@/$(NN_VERSION)/g;s/@VERSION_COM@/$(NN_VERSION_COM)/g;s/@ICON@/$(ICON)/g;s#@EXE@#$(notdir $(NNCHAT_BIN))#g" < $< > $@
-
-resource.o: resource.rc
-	$(WINDRES) $< -O coff -o $@
-