This repository has been archived by the owner on Oct 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
170 lines (127 loc) · 5.03 KB
/
Makefile
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Xep128: Minimalistic Enterprise-128 emulator with focus on "exotic" hardware
# Copyright (C)2015,2016 LGB (Gábor Lénárt) <lgblgblgb@gmail.com>
# http://xep128.lgb.hu/
SRCS_COMMON = lodepng.c screen.c main.c cpu.c z180.c nick.c dave.c input.c exdos_wd.c sdext.c rtc.c printer.c zxemu.c primoemu.c emu_rom_interface.c w5300.c apu.c keyboard_mapping.c configuration.c roms.c console.c emu_monitor.c joystick.c fileio.c gui.c z80.c z80dasm.c snapshot.c
SDIMG = sdcard.img
SDURL = http://xep128.lgb.hu/files/sdcard.img
ROM = combined.rom
DLL = SDL2.dll
DLLURL = http://xep128.lgb.hu/files/SDL-2.0.4.dll
all:
$(MAKE) do-all
RELEASE_TAG =
ARCH = native
ARCHALL = native win32 win64
include build/Makefile.$(ARCH)
# -flto is for link time optimization, CHANGE it to -g for debug material, but do NOT mix -g and -flto !!
DEBUG =
DEBUG_RELEASE = -flto
CFLAGS = $(DEBUG) $(CFLAGS_ARCH)
LDFLAGS = $(DEBUG) $(LDFLAGS_ARCH)
LIBS = $(LIBS_ARCH)
SRCS = $(SRCS_COMMON) $(SRCS_ARCH)
OPREFIX = build/objs/$(ARCH)$(RELEASE_TAG)--
DEPFILE = $(OPREFIX)make.depend
OBJS = $(addprefix $(OPREFIX), $(SRCS:.c=.o))
ZIP = xep128-$(ARCH).zip
ifdef WINDRES
WRCSRC = arch/windres.rc
WRCOBJ = $(OPREFIX)windres.res
OBJS += $(WRCOBJ)
$(WRCOBJ): $(WRCSRC)
$(WINDRES) $< -O coff -o $@
endif
do-all:
@echo "Compiler: $(CC) $(CFLAGS)"
@echo "Linker: $(CC) $(LDFLAGS) $(LIBS)"
@echo "Architecture: $(ARCH) [$(ARCH_DESC)]"
$(MAKE) $(PRG)
build-dist:
#rm -f build/objs/*
for arch in $(ARCHALL) ; do $(MAKE) dep ARCH=$$arch RELEASE_TAG=-rel ; $(MAKE) ARCH=$$arch DEBUG=$(DEBUG_RELEASE) RELEASE_TAG=-rel ; $(MAKE) strip ARCH=$$arch DEBUG=$(DEBUG_RELEASE) RELEASE_TAG=-rel ; done
build-dist-test:
ARCHALL="$(ARCHALL)" RELEASE_TAG=-debug DEBUG=-g STRIP=no build/tester
build-dist-rel:
ARCHALL="$(ARCHALL)" RELEASE_TAG=-rel DEBUG=$(DEBUG_RELEASE) STRIP=yes build/tester
publish-dist-test:
$(MAKE) build-dist-test
$(MAKE) rom
cat xep128.zip | ssh download.lgb.hu ".download.lgb.hu-files/pump xep128-devel.zip-`date '+%Y%m%d%H%M%S'`"
deb:
@if [ x$(ARCH) != xnative ]; then echo "*** DEB package building is only allowed for ARCH=native" >&2 ; false ; fi
$(MAKE) ARCH=native RELEASE_TAG=-rel DEBUG=$(DEBUG_RELEASE)
$(MAKE) strip ARCH=native RELEASE_TAG=-rel DEBUG=$(DEBUG_RELEASE)
build/deb-build-simple
$(OPREFIX)%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
%.s: %.c
$(CC) -S $(CFLAGS) $< -o $@
install: $(PRG) $(ROM) $(SDIMG)
$(MAKE) strip
mkdir -p $(BINDIR) $(DATADIR)
cp $(PRG) $(BINDIR)/
cp $(ROM) $(SDIMG) $(DATADIR)/
buildinfo.c:
if [ -s .git/refs/heads/master ]; then cat .git/refs/heads/master > .git-commit-info ; fi
echo "const char *BUILDINFO_ON = \"`whoami`@`uname -n` on `uname -s` `uname -r`\";" > buildinfo.c
echo "const char *BUILDINFO_AT = \"`date`\";" >> buildinfo.c
echo "const char *BUILDINFO_GIT = \"`cat .git-commit-info`\";" >> buildinfo.c
echo "const char *BUILDINFO_CC = __VERSION__;" >> buildinfo.c
$(SDIMG):
@echo "**** Fetching SDcard image from $(SDURL) ..."
wget -O $(SDIMG) $(SDURL) || { rm -f $(SDIMG) ; false; }
rom/$(ROM):
$(MAKE) -C rom
$(ROM): rom/$(ROM)
cp rom/$(ROM) .
data: $(SDIMG) $(ROM)
rm -f buildinfo.c
$(PRG): $(DEPFILE) $(OBJS)
rm -f buildinfo.c
$(MAKE) $(OPREFIX)buildinfo.o
$(CC) -o $(PRG) $(OBJS) $(OPREFIX)buildinfo.o $(LDFLAGS) $(LIBS)
zip:
$(MAKE) $(ZIP)
$(ZIP): $(PRG) $(ROM) $(ZIP_FILES_ARCH)
$(STRIP) $(PRG)
zip $(ZIP) $(PRG) $(ROM) .git-commit-info $(ZIP_FILES_ARCH) README.md LICENSE CHANGES
@ls -l $(ZIP)
publish: $(ZIP)
test -f rom/$(ROM) && cp rom/$(ROM) www/files/ || true
test -f $(ZIP) && cp $(ZIP) www/files/ || true
@ls -l www/files/
strip: $(PRG)
$(STRIP) $(PRG)
clean:
rm -f $(OBJS) buildinfo.c $(OPREFIX)buildinfo.o print.out $(ZIP) .git-commit-info*
$(MAKE) -C data clean
$(MAKE) -C rom clean
distclean:
$(MAKE) clean
$(MAKE) -C rom distclean
rm -f $(SDIMG) $(DLL) $(ROM) $(PRG) xep128-*.zip xep128_*.deb xep128*.js xep128*.js.gz xep128*.mem xep128*.mem.gz xep128*.html
rm -f build/objs/*
help:
$(MAKE) $(PRG)
./$(PRG) -help | grep -Ev '^(PATH:|Platform:|GIT|LICENSE:) ' > doc/help-cli.txt
./$(PRG) -testparsing -config none | sed -e '1,/^--- /d' -e '/^--- /,$$d' > doc/help-config.txt
$(DEPFILE):
$(MAKE) depend
dep:
$(MAKE) depend
depend:
$(CC) -MM $(CFLAGS) $(SRCS) | awk '/^[^.:\t ]+\.o:/ { print "$(OPREFIX)" $$0 ; next } { print }' > $(DEPFILE)
valgrind:
@echo "*** valgrind is useful mainly if you built Xep128 with the -g flag ***"
valgrind --read-var-info=yes --leak-check=full --track-origins=yes ./$(PRG) -debug /tmp/xep128.debug > /tmp/xep128-valgrind.stdout 2> /tmp/xep128-valgrind.stderr
ls -l /tmp/xep128.debug /tmp/xep128-valgrind.stdout /tmp/xep128-valgrind.stderr
subrepos:
mkdir -p gh-pages wiki
test -d wiki/.git || git clone --depth=1 git@github.com:lgblgblgb/xep128.wiki.git wiki
test -d gh-pages/.git || git clone --branch=gh-pages --depth=1 git@github.com:lgblgblgb/xep128.git gh-pages
cd gh-pages && git pull
cd wiki && git pull
.PHONY: all clean distclean strip publish data install dep depend valgrind zip deb do-all subrepos
ifneq ($(wildcard $(DEPFILE)),)
include $(DEPFILE)
endif