1# GNU Makefile for hexen2 pak tools using GCC. 2# $Id: Makefile 6030 2018-04-17 12:10:32Z sezero $ 3# 4# To cross-compile for Win32 on Unix: either pass the W32BUILD=1 5# argument to make, or export it. Also see build_cross_win32.sh. 6# Requires: a mingw or mingw-w64 compiler toolchain. 7# 8# To cross-compile for Win64 on Unix: either pass the W64BUILD=1 9# argument to make, or export it. Also see build_cross_win64.sh. 10# Requires: a mingw-w64 compiler toolchain. 11# 12# To cross-compile for MacOSX on Unix: either pass the OSXBUILD=1 13# argument to make, or export it. You would also need to pass a 14# suitable MACH_TYPE=xxx (ppc, x86, x86_64, or ppc64) argument to 15# make. Also see build_cross_osx.sh. 16# 17# To build a debug version: make DEBUG=1 [other stuff] 18# 19 20# Path settings: 21UHEXEN2_TOP:=../.. 22UTILS_TOP:=.. 23COMMONDIR:=$(UTILS_TOP)/common 24UHEXEN2_SHARED:=$(UHEXEN2_TOP)/common 25LIBS_DIR:=$(UHEXEN2_TOP)/libs 26OSLIBS:=$(UHEXEN2_TOP)/oslibs 27 28# include the common dirty stuff 29include $(UHEXEN2_TOP)/scripts/makefile.inc 30 31# Names of the binaries 32PAKX:=pakx$(exe_ext) 33PAKLIST:=paklist$(exe_ext) 34 35# Compiler flags 36 37# Overrides for the default CPUFLAGS 38ifeq ($(MACH_TYPE),x86) 39CPU_X86=-march=i586 40endif 41CPUFLAGS=$(CPU_X86) 42 43CFLAGS += -Wall 44CFLAGS += $(CPUFLAGS) 45ifndef DEBUG 46CFLAGS += -O2 -DNDEBUG=1 47else 48CFLAGS += -g 49endif 50 51LDFLAGS = 52LDLIBS = 53INCLUDES= -I. -I$(COMMONDIR) -I$(UHEXEN2_SHARED) 54 55# Other build flags 56 57ifeq ($(TARGET_OS),dos) 58INCLUDES+= -I$(OSLIBS)/dos 59LDFLAGS += $(OSLIBS)/dos/djtime/djtime.a -lc 60endif 61ifeq ($(TARGET_OS),os2) 62INCLUDES+= -I$(OSLIBS)/os2/emx/include 63CFLAGS += -Zmt 64ifndef DEBUG 65LDFLAGS += -s 66endif 67LDFLAGS += -Zmt 68endif 69ifeq ($(TARGET_OS),win32) 70CFLAGS += -DWIN32_LEAN_AND_MEAN 71INCLUDES+= -I$(OSLIBS)/windows/misc/include 72CFLAGS += -m32 73LDFLAGS += -m32 -mconsole 74endif 75ifeq ($(TARGET_OS),win64) 76CFLAGS += -DWIN32_LEAN_AND_MEAN 77INCLUDES+= -I$(OSLIBS)/windows/misc/include 78CFLAGS += -m64 79LDFLAGS += -m64 -mconsole 80endif 81ifeq ($(TARGET_OS),aros) 82# nothing extra is needed 83endif 84ifeq ($(TARGET_OS),morphos) 85CFLAGS += -noixemul 86LDFLAGS += -noixemul 87endif 88ifeq ($(TARGET_OS),amigaos) 89# crt: libnix or clib2: 90USE_CLIB2=yes 91ifeq ($(USE_CLIB2),yes) 92CRT_FLAGS=-mcrt=clib2 93else 94CRT_FLAGS=-noixemul 95endif 96CFLAGS += $(CRT_FLAGS) -m68020-60 97LDFLAGS += $(CRT_FLAGS) -m68020 98ifndef DEBUG 99CFLAGS += -fno-omit-frame-pointer 100endif 101# for extra missing headers 102INCLUDES += -I$(OSLIBS)/amigaos/include 103endif 104ifeq ($(TARGET_OS),darwin) 105CPUFLAGS= 106# require 10.5 for 64 bit builds 107ifeq ($(MACH_TYPE),x86_64) 108CFLAGS +=-mmacosx-version-min=10.5 109LDFLAGS +=-mmacosx-version-min=10.5 110endif 111ifeq ($(MACH_TYPE),ppc64) 112CFLAGS +=-mmacosx-version-min=10.5 113LDFLAGS +=-mmacosx-version-min=10.5 114endif 115endif 116ifeq ($(TARGET_OS),unix) 117# nothing extra is needed 118endif 119 120# Targets 121all : $(PAKX) $(PAKLIST) 122 123# Rules for turning source files into .o files 124%.o: %.c 125 $(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $< 126%.o: $(COMMONDIR)/%.c 127 $(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $< 128%.o: $(UHEXEN2_SHARED)/%.c 129 $(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $< 130 131# Objects 132OBJ_COMMON= qsnprint.o \ 133 strlcat.o \ 134 strlcpy.o \ 135 cmdlib.o \ 136 util_io.o \ 137 crc.o \ 138 q_endian.o \ 139 byteordr.o \ 140 pakfile.o 141OBJ_PAKX= pakx.o 142OBJ_PAKL= paklist.o 143 144$(PAKX): $(OBJ_COMMON) $(OBJ_PAKX) 145 $(LINKER) $(OBJ_COMMON) $(OBJ_PAKX) $(LDFLAGS) $(LDLIBS) -o $@ 146 147$(PAKLIST): $(OBJ_COMMON) $(OBJ_PAKL) 148 $(LINKER) $(OBJ_COMMON) $(OBJ_PAKL) $(LDFLAGS) $(LDLIBS) -o $@ 149 150clean: 151 rm -f *.o core 152distclean: clean 153 rm -f $(PAKX) $(PAKLIST) 154 155