-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
197 lines (165 loc) · 5.91 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# Copyright (c) 2008, 2017 Stephen Checkoway
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
CPPFLAGS += -I. -Iinclude
CFLAGS += -O3
package := zel
version := 0.1
distname := lib$(package)-$(version)
prefix := /usr/local
exec_prefix := $(prefix)
includedir := $(prefix)/include
datarootdir := $(prefix)/share
datadir := $(datarootdir)
docdir := $(datarootdir)/doc/$(package)
htmldir := $(docdir)
pdfdir := $(docdir)
libdir := $(exec_prefix)/lib
mandir := $(datarootdir)/man
man3dir := $(mandir)/man3
INSTALL := install
INSTALL_PROGRAM := $(INSTALL) -m 0755
INSTALL_DATA := $(INSTALL) -m 0644
spec := $(wildcard tables/*.spec)
itables := $(spec:.spec=.tab)
here := $(shell pwd)
dist_source := z80.c \
z80_instructions.c \
z80_types.h \
include/zel/z80.h \
include/zel/z80_instructions.h \
include/zel/z80_instruction_types.h \
tables/gen.pl \
$(spec) \
$(itables) \
Makefile \
Doxyfile \
LICENSE \
tests/Makefile \
$(wildcard tests/*.c) \
doc/$(distname).pdf
.PHONY: all check clean distclean mostlyclean maintainer-clean dist distcheck doc-clean \
install install-html install-pdf html pdf uninstall uninstall-doc install-doc installcheck
all: libzel.a
libzel.a: z80.o z80_instructions.o
$(AR) -cr $@ $?
ranlib $@
tables/%.tab: tables/%.spec tables/gen.pl
perl tables/gen.pl $< > $@
include/zel/z80_instruction_types.h: $(itables)
sed -e '1s,^,/* ,;2,$$s,^, * ,' LICENSE >$@
echo ' */' >>$@
echo >>$@
echo '/*! \\file' >>$@
echo ' *' >>$@
echo ' * z80 instruction types.' >>$@
echo ' * \\author Stephen Checkoway' >>$@
echo ' * \\version 0.1' >>$@
echo ' * \\date 2008, 2017' >>$@
echo ' */' >>$@
echo '#ifndef ZEL_Z80_INSTRUCTION_TYPES_H' >>$@
echo '#define ZEL_Z80_INSTRUCTION_TYPES_H' >>$@
echo >>$@
echo '#ifdef __cplusplus' >>$@
echo 'extern "C" {' >>$@
echo '#endif' >>$@
echo >>$@
echo 'typedef enum' >>$@
echo '{' >>$@
awk '{ split($$2,a,/_/); sub(/,/,"",a[1]); printf "\t%s //!< %s\n", $$2, tolower(a[1]) }' \
$(itables) |sort|uniq >>$@
echo '} InstructionType;' >>$@
echo >>$@
echo '#ifdef __cplusplus' >>$@
echo '}' >>$@
echo '#endif' >>$@
echo >>$@
echo '#endif' >>$@
z80.o: z80.c z80_types.h include/zel/z80.h include/zel/z80_instructions.h include/zel/z80_instruction_types.h
z80_instructions.o: z80_instructions.c z80_types.h include/zel/z80_instructions.h include/zel/z80.h include/zel/z80_instruction_types.h $(itables)
check: all
$(MAKE) -C tests check
installcheck:
$(MAKE) -C tests LDFLAGS='-L$(DESTDIR)$(libdir)' CPPFLAGS='-I$(DESTDIR)$(includedir)' check
doc-clean:
$(RM) -r doc
clean: doc-clean
$(MAKE) -C tests clean
$(RM) libzel.a z80.o z80_instructions.o *~
doc: Doxyfile $(wildcard include/zel/*.h) include/zel/z80_instruction_types.h
doxygen
pdf: doc/$(distname).pdf
doc/$(distname).pdf: doc
$(MAKE) -C doc/latex -j1
cp doc/latex/refman.pdf doc/$(distname).pdf
html: doc
man: doc
# XXX: Install the man pages once those get sorted out
install:
$(INSTALL) -d $(DESTDIR)$(libdir)
$(INSTALL_PROGRAM) libzel.a $(DESTDIR)$(libdir)
$(INSTALL) -d $(DESTDIR)$(includedir)/zel
$(INSTALL_DATA) include/zel/z80.h $(DESTDIR)$(includedir)/zel
$(INSTALL_DATA) include/zel/z80_instructions.h $(DESTDIR)$(includedir)/zel
$(INSTALL_DATA) include/zel/z80_instruction_types.h $(DESTDIR)$(includedir)/zel
uninstall: uninstall-doc
$(RM) $(DESTDIR)$(libdir)/libzel.a
$(RM) $(DESTDIR)$(includedir)/zel/z80.h
$(RM) $(DESTDIR)$(includedir)/zel/z80_instructions.h
$(RM) $(DESTDIR)$(includedir)/zel/z80_instruction_types.h
rmdir $(DESTDIR)$(includedir)/zel
install-doc: install-html install-pdf
uninstall-doc:
$(RM) -r $(DESTDIR)$(htmldir)/html
$(RM) $(DESTDIR)$(pdfdir)/$(distname).pdf
rmdir $(DESTDIR)$(htmldir)
if [ x$(DESTDIR)$(htmldir) != x$(DESTDIR)$(pdfdir) ]; then \
rmdir $(DESTDIR)$(pdfdir); \
fi
install-html:
$(INSTALL) -d $(DESTDIR)$(htmldir)/html
$(INSTALL_DATA) doc/html/* $(DESTDIR)$(htmldir)/html
install-pdf:
$(INSTALL) -d $(DESTDIR)$(pdfdir)
$(INSTALL_DATA) doc/$(distname).pdf $(DESTDIR)$(pdfdir)
dist: $(distname).tar.gz
$(distname).tar.gz: $(dist_source)
mkdir $(distname)
for i in $(dist_source); do \
d=`dirname $$i`; \
mkdir -p $(distname)/$$d; \
cp $$i $(distname)/$$i; \
done
cp -r doc/html $(distname)/doc
cp -r doc/man $(distname)/doc
tar zcf $(distname).tar.gz $(distname)
$(RM) -r $(distname)
distcheck: $(distname).tar.gz
tar zxf $(distname).tar.gz
$(MAKE) -C $(distname) prefix=$(here)/$(distname)/_inst check
$(MAKE) -C $(distname) prefix=$(here)/$(distname)/_inst doc
$(MAKE) -C $(distname) prefix=$(here)/$(distname)/_inst install
$(MAKE) -C $(distname) prefix=$(here)/$(distname)/_inst install-doc
$(MAKE) -C $(distname) prefix=$(here)/$(distname)/_inst installcheck
$(MAKE) -C $(distname) prefix=$(here)/$(distname)/_inst uninstall
$(RM) -r $(distname)
distclean: clean
mostlyclean: clean
maintainer-clean: clean
$(RM) include/zel/z80_instruction_types.h $(itables)