| 1 |
# |
| 2 |
# Makefile for Windows systems using gmake |
| 3 |
# |
| 4 |
# |
| 5 |
# Try "make" to do a default build, using cygwin. |
| 6 |
# |
| 7 |
# Try "make CONSOLE=yes" to use PDCurses, as long as you set |
| 8 |
# PDCURSES_INCLUDE_DIR and PDCURSES_LIB. |
| 9 |
# |
| 10 |
# For a better looking Windows console, follow the instructions at |
| 11 |
# https://trac.rephial.org/wiki/Compiling |
| 12 |
# |
| 13 |
# Other options: |
| 14 |
# OBJ_DIR=x will place .o files into directory 'x' |
| 15 |
# MINGW=yes will use the mingw compiler |
| 16 |
# |
| 17 |
|
| 18 |
# Executable name and default target |
| 19 |
EXE = angband.exe |
| 20 |
all: ../$(EXE) |
| 21 |
|
| 22 |
ifneq (,$(findstring \SYSTEM32,$(PATH))) |
| 23 |
dos = TRUE |
| 24 |
endif |
| 25 |
ifneq (,$(findstring \system32,$(PATH))) |
| 26 |
dos = TRUE |
| 27 |
endif |
| 28 |
|
| 29 |
ifdef dos |
| 30 |
CP = copy |
| 31 |
RM = del |
| 32 |
BAR = "\" |
| 33 |
else |
| 34 |
CP = -cp |
| 35 |
RM = -rm |
| 36 |
BAR = "/" |
| 37 |
endif |
| 38 |
|
| 39 |
|
| 40 |
ifndef MINGW |
| 41 |
CYGWIN=yes |
| 42 |
endif |
| 43 |
|
| 44 |
# Include list of object files and add system-specific ones |
| 45 |
include Makefile.inc |
| 46 |
MAINFILES="$(WINMAINFILES)" |
| 47 |
|
| 48 |
ifdef CONSOLE |
| 49 |
CFLAGS = -DUSE_GCU -DWIN32_CONSOLE_MODE -I$(PDCURSES_INC) |
| 50 |
LIBS = -s $(PDCURSES_LIB) |
| 51 |
IOBJS = $(BASEOBJS) main-gcu.o main.o |
| 52 |
|
| 53 |
#PDCURSES_INC = ../../pdcurses/include |
| 54 |
#PDCURSES_LIB = ../../pdcurses/lib/pdcurses.a |
| 55 |
else |
| 56 |
CFLAGS = -DWINDOWS -static |
| 57 |
|
| 58 |
CFLAGS += -Iwin/include -Lwin/lib |
| 59 |
LDFLAGS += -Lwin/lib |
| 60 |
|
| 61 |
IOBJS = $(BASEOBJS) win/$(PROGNAME).res $(SOUNDFILES) main-win.o win/readdib.o win/readpng.o win/scrnshot.o win/win-layout.o |
| 62 |
LIBS = -mwindows -lwinmm -lzlib -llibpng -lmsimg32 |
| 63 |
endif |
| 64 |
|
| 65 |
CC = $(CROSS)gcc |
| 66 |
WRES = $(CROSS)windres |
| 67 |
WARNINGS = -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers |
| 68 |
CFLAGS += $(WARNINGS) -std=c99 -DUSE_PRIVATE_PATHS -DSOUND -O2 -I. |
| 69 |
|
| 70 |
ifdef BUILD_ID |
| 71 |
CFLAGS += -DBUILD_ID="$(BUILD_ID)" |
| 72 |
endif |
| 73 |
|
| 74 |
ifdef CYGWIN |
| 75 |
|
| 76 |
LIBS += -mno-cygwin -e _mainCRTStartup |
| 77 |
CFLAGS += -mno-cygwin |
| 78 |
|
| 79 |
# Note the additional -DNEAR= flag to cope with the 'NEAR' |
| 80 |
# keyword used in readdib.c |
| 81 |
win/readdib.o: win/readdib.c win/readdib.h |
| 82 |
$(CC) $(CFLAGS) -DNEAR= $(INCDIRS) -c -o $@ $< |
| 83 |
|
| 84 |
win/readpng.o: win/readpng.c win/readdib.h |
| 85 |
$(CC) $(CFLAGS) -DNEAR= $(INCDIRS) -c -o $@ $< |
| 86 |
|
| 87 |
endif |
| 88 |
|
| 89 |
|
| 90 |
# Handle cross compiles |
| 91 |
ifdef CROSS |
| 92 |
CFLAGS += -DCROSS_COMPILE |
| 93 |
|
| 94 |
ifdef MINGW |
| 95 |
# This is an issue on mingw32 on linux |
| 96 |
CFLAGS += -D_stdcall= |
| 97 |
endif |
| 98 |
endif |
| 99 |
|
| 100 |
# Handle object output in a different directory |
| 101 |
ifdef OBJDIR |
| 102 |
OBJS = $(patsubst %.o, $(OBJDIR)%.o, $(IOBJS)) |
| 103 |
mkdirs:; -mkdir -p $(OBJDIR) $(OBJDIR)win |
| 104 |
$(EXE): mkdirs |
| 105 |
else |
| 106 |
OBJS = $(IOBJS) |
| 107 |
endif |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
# |
| 112 |
# Targets |
| 113 |
# |
| 114 |
|
| 115 |
../$(EXE): $(EXE) |
| 116 |
$(CP) $(EXE) .. |
| 117 |
$(CP) win$(BAR)dll$(BAR)libpng12.dll .. |
| 118 |
$(CP) win$(BAR)dll$(BAR)zlib1.dll .. |
| 119 |
|
| 120 |
$(EXE): $(OBJS) |
| 121 |
$(CC) $(CFLAGS) -o $(EXE) $(OBJS) $(LIBS) |
| 122 |
|
| 123 |
clean: |
| 124 |
$(RM) -f $(EXE) $(OBJS) |
| 125 |
$(RM) -f libpng12.dll |
| 126 |
$(RM) -f zlib1.dll |
| 127 |
|
| 128 |
|
| 129 |
# |
| 130 |
# Rules |
| 131 |
# |
| 132 |
|
| 133 |
win/$(PROGNAME).res: win/$(PROGNAME).rc |
| 134 |
$(WRES) $< -O coff -o $@ |
| 135 |
|
| 136 |
$(OBJDIR)%.o: %.c $(INCS) |
| 137 |
$(CC) $(CFLAGS) -c -o $@ $< |