-
Notifications
You must be signed in to change notification settings - Fork 3
/
MakefileO64
146 lines (120 loc) · 5.07 KB
/
MakefileO64
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# MakefileO64: Copyright 2019-2025 Valerio Messina [email protected]
#
# MakefileO64 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 cross-build 'Wilderland' for macOS on Linux using CLANG+GNUtoolchain
# To be used on: Linux=>macOS.bin64 (OSXCROSS)
# require OSX SDL_image in /opt/osxcross/target/macports/pkgs/opt/local/lib
# 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 and sanitize=address use: $ make debug
# Note: sanitize can be also $ make SAN=thread|memory debug
PKG = OSX64
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
# OHOST cross-compiler target
# OCROSS cross-toolchain prefix
# OSXROOT point to cross-compiler root path
# OSX point to cross-compiler tools path
MACOSX_DEPLOYMENT_TARGET=10.14
OHOST=x86_64-apple-darwin18
OCROSS = $(OHOST)-
OSXROOT = /opt/osxcross
OSX = $(OSXROOT)/target/bin
OSXDEPS = $OSXROOT/target/macports
PATH:=$(OSX):$(PATH)
OSXCROSS_PKG_CONFIG_USE_NATIVE_VARIABLES = 1
PKG_CONFIG_LIBDIR =
PKG_CONFIG_PATH = $(OSXDEPS)/pkgs/opt/local/lib/pkgconfig:$(OSXDEPS)/pkgs/opt/local/share/pkgconfig
CC = $(OCROSS)clang
LD = $(OCROSS)clang
STRIP = $(OCROSS)strip
PKG_CONFIG = $(OCROSS)pkg-config
CFLAGS = -std=c99 -Wall -O3 -DCPUEMUL=$(CPUEMUL) -fomit-frame-pointer # -I$(OSXDEPS)/pkgs/opt/local/include
SDLCFLAGS = $(shell OSXCROSS_PKG_CONFIG_USE_NATIVE_VARIABLES=1: PKG_CONFIG_PATH=$(PKG_CONFIG_PATH): $(OSX)/$(PKG_CONFIG) --cflags SDL2_image)
#SDLMINGWLDFLAGS = -mconsole # on MinGW + SDL force console for debug
LDFLAGS = $(shell OSXCROSS_PKG_CONFIG_USE_NATIVE_VARIABLES=1: PKG_CONFIG_PATH=$(PKG_CONFIG_PATH): $(OSX)/$(PKG_CONFIG) --libs SDL2_image) $(SDLMINGWLDFLAGS)
ifndef NODL
CFLAGS += $(shell OSXCROSS_PKG_CONFIG_USE_NATIVE_VARIABLES=1: PKG_CONFIG_PATH=$(PKG_CONFIG_PATH): $(OSX)/$(PKG_CONFIG) --cflags libcurl)
CFLAGS += $(shell OSXCROSS_PKG_CONFIG_USE_NATIVE_VARIABLES=1: PKG_CONFIG_PATH=$(PKG_CONFIG_PATH): $(OSX)/$(PKG_CONFIG) --cflags libzip)
LDFLAGS += $(shell OSXCROSS_PKG_CONFIG_USE_NATIVE_VARIABLES=1: PKG_CONFIG_PATH=$(PKG_CONFIG_PATH): $(OSX)/$(PKG_CONFIG) --libs libcurl)
LDFLAGS += $(shell OSXCROSS_PKG_CONFIG_USE_NATIVE_VARIABLES=1: PKG_CONFIG_PATH=$(PKG_CONFIG_PATH): $(OSX)/$(PKG_CONFIG) --libs libzip)
else
CFLAGS += -DNODL
endif
SAN?=address
CFLAGS_address = -fsanitize=address -fno-omit-frame-pointer
LDFLAGS_address = -fsanitize=address
CFLAGS_thread = -fsanitize=thread
LDFLAGS_thread = -fsanitize=thread
ifeq ($(CC),clang)
CFLAGS_memory = -fsanitize=memory -fPIE -fno-omit-frame-pointer -fsanitize-memory-track-origins
LDFLAGS_memory = -fsanitize=memory -fPIE -pie
endif
FILE = WL
SOURCE = $(FILE)
TARGET = $(FILE)osx
TAPCON = TapCon/TapConOsx
all: $(TARGET) $(TAPCON)
$(TARGET): $(SOURCE).o SDLTWE.o spectrum.o $(CPUOBJ)
$(OSX)/$(LD) $^ $(LDFLAGS) -o $@
$(SOURCE).o: $(SOURCE).c WL.h GlobalVars.h MapCoordinates.h SDLTWE.h Spectrum.h $(CPUIF)
$(OSX)/$(CC) $(CFLAGS) $(SDLCFLAGS) -c $< -o $@
SDLTWE.o: SDLTWE.c WL.h SDLTWE.h
$(OSX)/$(CC) $(CFLAGS) $(SDLCFLAGS) -c $< -o $@
spectrum.o: Spectrum.c GlobalVars.h Spectrum.h WL.h SDLTWE.h $(CPUIF)
$(OSX)/$(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
$(OSX)/$(CC) -I. $(CFLAGS) $(SDLCFLAGS) -c $< -o $@
$(TAPCON): TapCon/TapCon.c WL.h
$(OSX)/$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
strip:
$(OSX)/$(STRIP) $(TARGET) $(TAPCON)
cleanobj:
rm -f *.o
cleanbin:
rm -f $(TARGET) $(TAPCON)
clean: cleanobj cleanbin
debug: CFLAGS += -O2 -g -fsanitize=undefined $(CFLAGS_$(SAN))
debug: LDFLAGS += -fsanitize=undefined $(LDFLAGS_$(SAN))
debug: clean all cleanobj
bin: all cleanobj strip
force: clean bin
rm -f *.o
pkg:
@WLpkg.sh $(PKG) $(BIT)
rel: force pkg