1# GNU Makefile for hexen2 dhcc tool 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 32BINARY:=dhcc$(exe_ext) 33 34# Compiler flags 35 36# Overrides for the default CPUFLAGS 37ifeq ($(MACH_TYPE),x86) 38CPU_X86=-march=i586 39endif 40CPUFLAGS=$(CPU_X86) 41 42CFLAGS += -Wall 43CFLAGS += $(CPUFLAGS) 44ifndef DEBUG 45CFLAGS += -O2 -DNDEBUG=1 46else 47CFLAGS += -g 48endif 49 50LDFLAGS = 51LDLIBS = 52INCLUDES= -I. -I$(COMMONDIR) -I$(UHEXEN2_SHARED) 53 54# Other build flags 55 56ifeq ($(TARGET_OS),dos) 57INCLUDES+= -I$(OSLIBS)/dos 58LDFLAGS += $(OSLIBS)/dos/djtime/djtime.a -lc 59endif 60ifeq ($(TARGET_OS),os2) 61INCLUDES+= -I$(OSLIBS)/os2/emx/include 62CFLAGS += -Zmt 63ifndef DEBUG 64LDFLAGS += -s 65endif 66LDFLAGS += -Zmt 67endif 68ifeq ($(TARGET_OS),win32) 69CFLAGS += -DWIN32_LEAN_AND_MEAN 70INCLUDES+= -I$(OSLIBS)/windows/misc/include 71CFLAGS += -m32 72LDFLAGS += -m32 -mconsole 73endif 74ifeq ($(TARGET_OS),win64) 75CFLAGS += -DWIN32_LEAN_AND_MEAN 76INCLUDES+= -I$(OSLIBS)/windows/misc/include 77CFLAGS += -m64 78LDFLAGS += -m64 -mconsole 79endif 80ifeq ($(TARGET_OS),aros) 81# nothing extra is needed 82endif 83ifeq ($(TARGET_OS),morphos) 84CFLAGS += -noixemul 85LDFLAGS += -noixemul 86endif 87ifeq ($(TARGET_OS),amigaos) 88# crt: libnix or clib2: 89USE_CLIB2=yes 90ifeq ($(USE_CLIB2),yes) 91CRT_FLAGS=-mcrt=clib2 92else 93CRT_FLAGS=-noixemul 94endif 95CFLAGS += $(CRT_FLAGS) -m68020-60 -m68881 96LDFLAGS += $(CRT_FLAGS) -m68020 -m68881 97# -lm is needed for atof() 98LDLIBS += -lm 99ifndef DEBUG 100CFLAGS += -fno-omit-frame-pointer 101endif 102# for extra missing headers 103INCLUDES += -I$(OSLIBS)/amigaos/include 104endif 105ifeq ($(TARGET_OS),darwin) 106CPUFLAGS= 107# require 10.5 for 64 bit builds 108ifeq ($(MACH_TYPE),x86_64) 109CFLAGS +=-mmacosx-version-min=10.5 110LDFLAGS +=-mmacosx-version-min=10.5 111endif 112ifeq ($(MACH_TYPE),ppc64) 113CFLAGS +=-mmacosx-version-min=10.5 114LDFLAGS +=-mmacosx-version-min=10.5 115endif 116endif 117ifeq ($(TARGET_OS),unix) 118# nothing extra is needed 119endif 120 121# Targets 122all : $(BINARY) 123 124# Rules for turning source files into .o files 125%.o: %.c 126 $(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $< 127%.o: $(COMMONDIR)/%.c 128 $(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $< 129%.o: $(UHEXEN2_SHARED)/%.c 130 $(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $< 131 132# Objects 133OBJECTS= qsnprint.o \ 134 strlcat.o \ 135 strlcpy.o \ 136 cmdlib.o \ 137 util_io.o \ 138 q_endian.o \ 139 byteordr.o \ 140 crc.o \ 141 dcc.o \ 142 hcc.o \ 143 pr_comp.o \ 144 pr_lex.o 145 146$(BINARY): $(OBJECTS) 147 $(LINKER) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@ 148 149clean: 150 rm -f *.o core 151distclean: clean 152 rm -f $(BINARY) 153 154