-
Notifications
You must be signed in to change notification settings - Fork 3
/
MakefileG64
131 lines (108 loc) · 3.64 KB
/
MakefileG64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Makefile: Copyright 2019-2023 Valerio Messina efa@iol.it
#
# Makefile is part of Wilderland - A Hobbit Environment
# Wilderland is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Wilderland is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Wilderland. If not, see <http://www.gnu.org/licenses/>.
# Makefile to build 'Wilderland' for Win on Win using GCC+GNUtoolchain
# To be used on: MinGw64=>bin64 (MinGW/MSYS2)
# require $ pacman
# To use z80emu emulator build with: $ make CPUEMUL=ez80emu OR $ make
# To use Z80 emulator build with: $ make CPUEMUL=eZ80
# To avoid include and link libcurl and libzip build with: $ make NODL=1
# To build for debug use: $ make BUILD=debug
PKG = MGW64
CPU = $(shell uname -m)
BIT = 64
OS = $(shell uname -o)
# select the CPU emulator, CPUEMUL must be: eZ80 or ez80emu
eZ80 = 1
ez80emu = 2
ifeq ($(CPUEMUL),) # default to ez80emu
CPUEMUL = ez80emu
endif
ifeq ($(CPUEMUL),eZ80)
CPUIF=Z80/Z80.h
CPUOBJ=Z80.o
endif
ifeq ($(CPUEMUL),ez80emu)
CPUIF=z80emu/z80emu.h
CPUOBJ=z80emu.o
endif
BUILD?=release
ifeq ($(BUILD),debug)
COPT=-O1 -g -fsanitize=address -fno-omit-frame-pointer
LOPT=-fsanitize=address
else
COPT=-O3
endif
CC = gcc
LD = $(CC)
STRIP = strip
CFLAGS = -std=c99 -Wall $(COPT) -D__USE_MINGW_ANSI_STDIO=1 -DCPUEMUL=$(CPUEMUL) -fomit-frame-pointer
SDLCFLAGS = $(shell pkg-config --cflags SDL2_image)
ifeq ($(OS),Msys) # on MINGW + SDL force console for debug
SDLMINGWLDFLAGS = -mconsole
endif
LDFLAGS = $(shell pkg-config --libs SDL2_image) $(SDLMINGWLDFLAGS) $(LOPT)
ifndef NODL
CFLAGS += $(shell pkg-config --cflags libcurl)
CFLAGS += $(shell pkg-config --cflags libzip)
LDFLAGS += $(shell pkg-config --libs libcurl)
LDFLAGS += $(shell pkg-config --libs libzip)
else
CFLAGS += -DNODL
endif
FILE = WL
SOURCE = $(FILE)
TARGET = $(FILE)
TAPCON = TapCon/TapCon
ifeq ($(MSYSTEM),MINGW64) # strip/rm require .exe in MINGW/MSYS2
STRIP = strip.exe
TARGET = $(FILE)mgw.exe
TAPCON = TapCon/TapConMgw.exe
endif
all: $(TARGET) $(TAPCON)
$(TARGET): $(SOURCE).o SDLTWE.o spectrum.o $(CPUOBJ)
$(LD) $^ $(LDFLAGS) -o $@
$(SOURCE).o: $(SOURCE).c WL.h GlobalVars.h MapCoordinates.h SDLTWE.h Spectrum.h $(CPUIF)
$(CC) $(CFLAGS) $(SDLCFLAGS) -c $< -o $@
SDLTWE.o: SDLTWE.c WL.h SDLTWE.h
$(CC) $(CFLAGS) $(SDLCFLAGS) -c $< -o $@
spectrum.o: Spectrum.c GlobalVars.h Spectrum.h WL.h SDLTWE.h $(CPUIF)
$(CC) $(CFLAGS) $(SDLCFLAGS) -c $< -o $@
z80emu/tables.h: z80emu/maketables.c
$(CC) -Wall $< -o z80emu/maketables
@echo "Generated 'maketables', now run it to output 'tables.h'"
./z80emu/maketables > $@
z80emu.o: z80emu/z80emu.c z80emu/z80emu.h z80emu/z80config.h z80emu/z80user.h \
z80emu/instructions.h z80emu/macros.h z80emu/tables.h Spectrum.h
$(CC) -I. $(CFLAGS) -c $<
Z80.o: Z80/Z80.c GlobalVars.h Spectrum.h Z80/Codes.h Z80/CodesCB.h \
Z80/CodesED.h Z80/CodesXCB.h Z80/CodesXX.h Z80/Tables.h Z80/Z80.h
$(CC) -I. $(CFLAGS) $(SDLCFLAGS) -c $< -o $@
$(TAPCON): TapCon/TapCon.c WL.h
$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
strip:
$(STRIP) $(TARGET) $(TAPCON)
cleanobj:
rm -f *.o
cleanbin:
rm -f $(TARGET) $(TAPCON)
clean: cleanobj cleanbin
debug: clean all cleanobj
bin: all cleanobj strip
force: clean bin
rm -f *.o
pkg:
@WLpkg.sh $(PKG) $(BIT)
rel: force pkg