-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Makefile.in
477 lines (367 loc) · 10.2 KB
/
Makefile.in
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
#
# Makefile for Mini-XML, a small XML-like file parsing library.
#
# https://www.msweet.org/mxml
#
# Copyright © 2003-2024 by Michael R Sweet.
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more
# information.
#
#
# This is a POSIX makefile
#
.POSIX:
#
# Mini-XML version...
#
MXML_VERSION = @MXML_VERSION@
#
# Programs...
#
AR = @AR@
CC = @CC@
DSO = @DSO@
INSTALL = @INSTALL@
LN = @LN@ -sf
MKDIR = @MKDIR@ -p
RANLIB = @RANLIB@
RM = @RM@ -f
RMDIR = @RMDIR@
SHELL = /bin/sh
#
# Installation programs...
#
INSTALL_BIN = $(INSTALL) -c -m 755
INSTALL_DATA = $(INSTALL) -c -m 444
INSTALL_DIR = $(INSTALL) -d -m 755
INSTALL_LIB = $(INSTALL) -c -m 755
INSTALL_MAN = $(INSTALL) -c -m 444
#
# Libraries...
#
LIBMXML = @LIBMXML@
LIBMXML_BASE = @LIBMXML_BASE@
LIBMXML_STATIC = @LIBMXML_STATIC@
MXML_MAN = @MXML_MAN@
MXML_PC = @MXML_PC@
#
# Install static libraries?
#
INSTALL_STATIC = @INSTALL_STATIC@
#
# Code signing...
#
CODE_SIGN = @CODE_SIGN@
CODESIGN_IDENTITY = -
CSFLAGS = -s "$(CODESIGN_IDENTITY)" @CSFLAGS@ --timestamp
#
# Library archiver...
#
ARFLAGS = @ARFLAGS@
#
# C compiler and preprocessor...
#
CFLAGS = @CFLAGS@ $(CPPFLAGS) $(OPTIM) $(WARNINGS)
CPPFLAGS = @CPPFLAGS@
WARNINGS = @WARNINGS@
#
# Linker options...
#
DSOFLAGS = @DSOFLAGS@ $(OPTIM)
LDFLAGS = @LDFLAGS@ $(OPTIM)
LIBS = @LIBS@ -lm
#
# Optimization and architecture options for both the compiler and linker.
#
OPTIM = @OPTIM@
#
# Directories...
#
bindir = @bindir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
exec_prefix = @exec_prefix@
includedir = @includedir@
infodir = @infodir@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
oldincludedir = @oldincludedir@
prefix = @prefix@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
top_srcdir = @top_srcdir@
BUILDROOT = $(DSTROOT)$(DESTDIR)
#
# Rules...
#
.SILENT:
.SUFFIXES: .c .man .o
.c.o:
echo Compiling $<
$(CC) $(CFLAGS) -c -o $@ $<
#
# Targets...
#
DOCFILES = doc/mxml.epub doc/mxml.html doc/mxml-cover.png \
CHANGES.md LICENSE NOTICE README.md
PUBLIBOBJS = mxml-attr.o mxml-file.o mxml-get.o mxml-index.o \
mxml-node.o mxml-options.o mxml-search.o mxml-set.o
LIBOBJS = $(PUBLIBOBJS) mxml-private.o
OBJS = testmxml.o $(LIBOBJS)
ALLTARGETS = $(LIBMXML) testmxml
CROSSTARGETS = $(LIBMXML)
TARGETS = $(@TARGETS@)
#
# Make everything...
#
all: $(TARGETS)
#
# Clean everything...
#
clean:
echo Cleaning build files...
$(RM) $(OBJS) $(ALLTARGETS)
$(RM) mxml4.dll
$(RM) mxml4.lib
$(RM) libmxml4.a
$(RM) libmxml4.so
$(RM) libmxml4.so.2
$(RM) libmxml4.2.dylib
$(RM) libmxml4.dylib
#
# Really clean everything...
#
distclean: clean
echo Cleaning distribution files...
$(RM) config.cache config.log config.status
$(RM) Makefile config.h mxml.pc
$(RM) test.xmlfd
$(RM) temp1.xml temp1.xmlfd temp1s.xml
$(RM) temp2.xml temp2s.xml
$(RM) -r autom4te*.cache
$(RM) *.bck *.bak
$(RM) -r clang
#
# Install everything...
#
.NOTPARALLEL: install install-$(LIBMXML) $(INSTALL_STATIC)
install: $(TARGETS) install-$(LIBMXML) $(INSTALL_STATIC)
echo Installing documentation in $(BUILDROOT)$(docdir)...
$(INSTALL_DIR) $(BUILDROOT)$(docdir)
for file in $(DOCFILES); do \
$(INSTALL_MAN) $$file $(BUILDROOT)$(docdir)/`basename $$file .md`; \
done
echo Installing header files in $(BUILDROOT)$(includedir)...
$(INSTALL_DIR) $(BUILDROOT)$(includedir)
$(INSTALL_DATA) mxml.h $(BUILDROOT)$(includedir)
echo Installing pkgconfig files in $(BUILDROOT)$(libdir)/pkgconfig...
$(INSTALL_DIR) $(BUILDROOT)$(libdir)/pkgconfig
$(INSTALL_DATA) mxml4.pc $(BUILDROOT)$(libdir)/pkgconfig/$(MXML_PC)
echo Installing man pages in $(BUILDROOT)$(mandir)...
$(INSTALL_DIR) $(BUILDROOT)$(mandir)/man3
$(INSTALL_MAN) doc/mxml.3 $(BUILDROOT)$(mandir)/man3/$(MXML_MAN)
install-libmxml.a: libmxml.a
echo Installing libmxml.a to $(BUILDROOT)$(libdir)...
$(INSTALL_DIR) $(BUILDROOT)$(libdir)
$(INSTALL_LIB) libmxml.a $(BUILDROOT)$(libdir)
$(RANLIB) $(BUILDROOT)$(libdir)/libmxml.a
install-libmxml.so.2: libmxml.so.2
echo Installing libmxml.so to $(BUILDROOT)$(libdir)...
$(INSTALL_DIR) $(BUILDROOT)$(libdir)
$(INSTALL_LIB) libmxml.so.2 $(BUILDROOT)$(libdir)
$(RM) $(BUILDROOT)$(libdir)/libmxml.so
$(LN) libmxml.so.2 $(BUILDROOT)$(libdir)/libmxml.so
$(LDCONFIG)
install-libmxml.2.dylib: libmxml.2.dylib
echo Installing libmxml.dylib to $(BUILDROOT)$(libdir)...
$(INSTALL_DIR) $(BUILDROOT)$(libdir)
$(INSTALL_LIB) libmxml.2.dylib $(BUILDROOT)$(libdir)
$(RM) $(BUILDROOT)$(libdir)/libmxml.dylib
$(LN) libmxml.2.dylib $(BUILDROOT)$(libdir)/libmxml.dylib
install-libmxml4.a: libmxml4.a
echo Installing libmxml4.a to $(BUILDROOT)$(libdir)...
$(INSTALL_DIR) $(BUILDROOT)$(libdir)
$(INSTALL_LIB) libmxml4.a $(BUILDROOT)$(libdir)
$(RANLIB) $(BUILDROOT)$(libdir)/libmxml4.a
install-libmxml4.so.2: libmxml4.so.2
echo Installing libmxml4.so to $(BUILDROOT)$(libdir)...
$(INSTALL_DIR) $(BUILDROOT)$(libdir)
$(INSTALL_LIB) libmxml4.so.2 $(BUILDROOT)$(libdir)
$(RM) $(BUILDROOT)$(libdir)/libmxml4.so
$(LN) libmxml4.so.2 $(BUILDROOT)$(libdir)/libmxml4.so
$(LDCONFIG)
install-libmxml4.2.dylib: libmxml4.2.dylib
echo Installing libmxml4.dylib to $(BUILDROOT)$(libdir)...
$(INSTALL_DIR) $(BUILDROOT)$(libdir)
$(INSTALL_LIB) libmxml4.2.dylib $(BUILDROOT)$(libdir)
$(RM) $(BUILDROOT)$(libdir)/libmxml4.dylib
$(LN) libmxml4.2.dylib $(BUILDROOT)$(libdir)/libmxml4.dylib
#
# Uninstall everything...
#
uninstall: uninstall-$(LIBMXML) @UNINSTALL_STATIC@
echo Uninstalling documentation from $(BUILDROOT)$(docdir)...
$(RM) -r $(BUILDROOT)$(docdir)
echo Uninstalling headers from $(BUILDROOT)$(includedir)...
$(RM) $(BUILDROOT)$(includedir)/mxml.h
echo Uninstalling pkgconfig files from $(BUILDROOT)$(libdir)/pkgconfig...
$(RM) $(BUILDROOT)$(libdir)/pkgconfig/$(MXML_PC)
echo Uninstalling man pages from $(BUILDROOT)$(mandir)...
$(RM) $(BUILDROOT)$(mandir)/man3/$(MXML_MAN)
uninstall-libmxml.a:
echo Uninstalling libmxml.a from $(BUILDROOT)$(libdir)...
$(RM) $(BUILDROOT)$(libdir)/libmxml.a
uninstall-libmxml.so.2:
echo Uninstalling libmxml.so from $(BUILDROOT)$(libdir)...
$(RM) $(BUILDROOT)$(libdir)/libmxml.so
$(RM) $(BUILDROOT)$(libdir)/libmxml.so.2
$(LDCONFIG)
uninstall-libmxml.2.dylib:
echo Uninstalling libmxml.dylib from $(BUILDROOT)$(libdir)...
$(RM) $(BUILDROOT)$(libdir)/libmxml.dylib
$(RM) $(BUILDROOT)$(libdir)/libmxml.2.dylib
uninstall-libmxml4.a:
echo Uninstalling libmxml4.a from $(BUILDROOT)$(libdir)...
$(RM) $(BUILDROOT)$(libdir)/libmxml4.a
uninstall-libmxml4.so.2:
echo Uninstalling libmxml4.so from $(BUILDROOT)$(libdir)...
$(RM) $(BUILDROOT)$(libdir)/libmxml4.so
$(RM) $(BUILDROOT)$(libdir)/libmxml4.so.2
$(LDCONFIG)
uninstall-libmxml4.2.dylib:
echo Uninstalling libmxml4.dylib from $(BUILDROOT)$(libdir)...
$(RM) $(BUILDROOT)$(libdir)/libmxml4.dylib
$(RM) $(BUILDROOT)$(libdir)/libmxml4.2.dylib
#
# Test everything...
#
test: testmxml
@echo Testing library...
./testmxml test.xml temp1s.xml >temp1.xml
./testmxml temp1.xml temp2s.xml >temp2.xml
@if cmp temp1.xml temp2.xml; then \
echo Stdio file test passed!; \
$(RM) temp2.xml temp2s.xml; \
else \
echo Stdio file test failed!; \
exit 1; \
fi
@if cmp temp1.xml temp1s.xml; then \
echo String test passed!; \
$(RM) temp1.xml temp1s.xml; \
else \
echo String test failed!; \
exit 1; \
fi
@if cmp test.xml test.xmlfd; then \
echo File descriptor test passed!; \
$(RM) test.xmlfd temp1.xmlfd; \
else \
echo File descriptor test failed!; \
exit 1; \
fi
#
# Figure out lines-of-code...
#
.PHONY: sloc
sloc:
echo "libmxml: \c"
sloccount $(LIBOBJS:.o=.c) mxml-private.c mxml.h 2>/dev/null | \
grep "Total Physical" | awk '{print $$9}'
#
# libmxml.a
#
libmxml.a libmxml4.a: $(LIBOBJS)
echo Creating $@...
$(RM) $@
$(AR) $(ARFLAGS) $@ $(LIBOBJS)
$(RANLIB) $@
$(LIBOBJS): mxml.h mxml-private.h
#
# libmxml2.dll
#
libmxml.dll libmxml4.dll: $(LIBOBJS)
echo Creating $@...
$(DSO) $(DSOFLAGS) -o $@ $(LIBOBJS) $(LIBS)
#
# libmxml.so.2
#
libmxml.so.2 libmxml4.so.2: $(LIBOBJS)
echo Creating $@...
$(DSO) $(DSOFLAGS) -o $@ $(LIBOBJS) $(LIBS)
$(RM) `basename $@ .2`
$(LN) $@ `basename $@ .2`
#
# libmxml.2.dylib
#
libmxml.2.dylib libmxml4.2.dylib: $(LIBOBJS)
echo Creating $@...
$(DSO) $(DSOFLAGS) -o $@ \
-install_name $(libdir)/`basename $@ .2.dylib`.dylib \
-current_version 2.0.0 \
-compatibility_version 2.0.0 \
$(LIBOBJS) $(LIBS)
$(RM) `basename $@ .2.dylib`.dylib
$(LN) $@ `basename $@ .2.dylib`.dylib
#
# testmxml
#
testmxml: $(LIBMXML_STATIC) testmxml.o
echo Linking $@...
$(CC) $(LDFLAGS) -o $@ testmxml.o $(LIBMXML_STATIC) $(LIBS)
testmxml-vg: $(LIBOBJS) testmxml.o
echo Linking $@...
$(CC) $(LDFLAGS) -o $@ testmxml.o $(LIBOBJS) $(LIBS)
testmxml.o: mxml.h
#
# Fuzz-test the library <>
#
.PHONY: afl
afl:
$(MAKE) -$(MAKEFLAGS) CC="afl-clang-fast" COMMONFLAGS="-g" clean all
test afl-output || rm -rf afl-output
afl-fuzz -x xml.dict -i afl-input -o afl-output -V 600 -e xml -t 5000 ./testmxml @@ temps.xml
#
# Analyze code with the Clang static analyzer <https://clang-analyzer.llvm.org>
#
.PHONY: clang
clang:
clang $(CPPFLAGS) --analyze $(OBJS:.o=.c) 2>clang.log
rm -rf $(OBJS:.o=.plist)
test -s clang.log && (echo "$(GHA_ERROR)Clang detected issues."; echo ""; cat clang.log; exit 1) || exit 0
#
# Analyze code using Cppcheck <http://cppcheck.sourceforge.net>
#
.PHONY: cppcheck
cppcheck:
cppcheck $(CPPFLAGS) --template=gcc --addon=cert.py --suppressions-list=.cppcheck $(OBJS:.o=.c) 2>cppcheck.log
test -s cppcheck.log && (echo "$(GHA_ERROR)Cppcheck detected issues."; echo ""; cat cppcheck.log; exit 1) || exit 0
#
# Documentation (depends on separate codedoc utility)
#
.PHONY: doc
doc: mxml.h $(PUBLIBOBJS:.o=.c) \
doc/body.md doc/body.man doc/footer.man \
doc/mxml-cover.png
echo Generating API documentation...
$(RM) mxml.xml
codedoc --body doc/body.md \
--coverimage doc/mxml-cover.png \
mxml.xml mxml.h $(PUBLIBOBJS:.o=.c) >doc/mxml.html
codedoc --body doc/body.md \
--coverimage doc/mxml-cover.png \
--epub doc/mxml.epub mxml.xml
codedoc --man mxml --title "Mini-XML API" \
--body doc/body.man --footer doc/footer.man \
mxml.xml >doc/mxml.3
$(RM) mxml.xml
#
# All object files depend on the makefile and config header...
#
$(OBJS): Makefile config.h