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
|
#
# Makefile for Mini-XML, a small XML-like file parsing library.
#
# https://www.msweet.org/mxml
#
# Copyright © 2003-2021 by Michael R Sweet.
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more
# information.
#
#
# Compiler tools definitions...
#
AR = @AR@
ARFLAGS = @ARFLAGS@
ARCHFLAGS = @ARCHFLAGS@
CC = @CC@
CFLAGS = $(OPTIM) $(ARCHFLAGS) @CFLAGS@ $(CPPFLAGS) $(WARNINGS)
CP = @CP@
CPPFLAGS = @CPPFLAGS@
DSO = @DSO@
DSOFLAGS = @DSOFLAGS@
LDFLAGS = $(OPTIM) $(ARCHFLAGS) @LDFLAGS@
INSTALL = @INSTALL@
LIBMXML = @LIBMXML@
LIBS = @LIBS@
LN = @LN@ -s
MKDIR = @MKDIR@
OPTIM = @OPTIM@
RANLIB = @RANLIB@
RM = @RM@ -f
SHELL = /bin/sh
WARNINGS = @WARNINGS@
#
# Configured directories...
#
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
datarootdir = @datarootdir@
includedir = @includedir@
libdir = @libdir@
mandir = @mandir@
docdir = @docdir@
BUILDROOT = $(DSTROOT)
#
# Install commands...
#
INSTALL_BIN = $(INSTALL) -m 755
INSTALL_DATA = $(INSTALL) -m 644
INSTALL_DIR = $(INSTALL) -d
INSTALL_LIB = $(INSTALL) -m 755
INSTALL_MAN = $(INSTALL) -m 644
INSTALL_SCRIPT = $(INSTALL) -m 755
#
# 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-entity.o mxml-file.o mxml-get.o \
mxml-index.o mxml-node.o mxml-search.o mxml-set.o
LIBOBJS = $(PUBLIBOBJS) mxml-private.o mxml-string.o
OBJS = testmxml.o $(LIBOBJS)
ALLTARGETS = $(LIBMXML) testmxml
CROSSTARGETS = $(LIBMXML) linmxml.a
TARGETS = $(@TARGETS@)
#
# Make everything...
#
all: $(TARGETS)
#
# Clean everything...
#
clean:
echo Cleaning build files...
$(RM) $(OBJS) $(ALLTARGETS)
$(RM) mxml1.dll
$(RM) mxml1.lib
$(RM) libmxml.a
$(RM) libmxml.so
$(RM) libmxml.so.1
$(RM) libmxml.so.1.6
$(RM) libmxml.1.dylib
$(RM) libmxml.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...
#
install: $(TARGETS) install-$(LIBMXML) install-libmxml.a
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) mxml.pc $(BUILDROOT)$(libdir)/pkgconfig
echo Installing man pages in $(BUILDROOT)$(mandir)...
$(INSTALL_DIR) $(BUILDROOT)$(mandir)/man3
$(INSTALL_MAN) doc/mxml.3 $(BUILDROOT)$(mandir)/man3/mxml.3
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.1.6: libmxml.so.1.6
echo Installing libmxml.so to $(BUILDROOT)$(libdir)...
$(INSTALL_DIR) $(BUILDROOT)$(libdir)
$(INSTALL_LIB) libmxml.so.1.6 $(BUILDROOT)$(libdir)
$(RM) $(BUILDROOT)$(libdir)/libmxml.so
$(LN) libmxml.so.1.6 $(BUILDROOT)$(libdir)/libmxml.so
$(RM) $(BUILDROOT)$(libdir)/libmxml.so.1
$(LN) libmxml.so.1.6 $(BUILDROOT)$(libdir)/libmxml.so.1
$(LDCONFIG)
install-libmxml.1.dylib: libmxml.1.dylib
echo Installing libmxml.dylib to $(BUILDROOT)$(libdir)...
$(INSTALL_DIR) $(BUILDROOT)$(libdir)
$(INSTALL_LIB) libmxml.1.dylib $(BUILDROOT)$(libdir)
$(RM) $(BUILDROOT)$(libdir)/libmxml.dylib
$(LN) libmxml.1.dylib $(BUILDROOT)$(libdir)/libmxml.dylib
#
# Uninstall everything...
#
uninstall: uninstall-$(LIBMXML) uninstall-libmxml.a
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.3
uninstall-libmxml.a:
echo Uninstalling libmxml.a from $(BUILDROOT)$(libdir)...
$(RM) $(BUILDROOT)$(libdir)/libmxml.a
uninstall-libmxml.so.1.6:
echo Uninstalling libmxml.so from $(BUILDROOT)$(libdir)...
$(RM) $(BUILDROOT)$(libdir)/libmxml.so
$(RM) $(BUILDROOT)$(libdir)/libmxml.so.1
$(RM) $(BUILDROOT)$(libdir)/libmxml.so.1.6
$(LDCONFIG)
uninstall-libmxml.1.dylib:
echo Uninstalling libmxml.dylib from $(BUILDROOT)$(libdir)...
$(RM) $(BUILDROOT)$(libdir)/libmxml.dylib
$(RM) $(BUILDROOT)$(libdir)/libmxml.1.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!; \
false ; \
fi
@if cmp temp1.xml temp1s.xml; then \
echo String test passed!; \
$(RM) temp1.xml temp1s.xml; \
else \
echo String test failed!; \
false ; \
fi
@if cmp test.xml test.xmlfd; then \
echo File descriptor test passed!; \
$(RM) test.xmlfd temp1.xmlfd; \
else \
echo File descriptor test failed!; \
false ; \
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: $(LIBOBJS)
echo Creating $@...
$(RM) $@
$(AR) $(ARFLAGS) $@ $(LIBOBJS)
$(RANLIB) $@
$(LIBOBJS): mxml.h
mxml-entity.o mxml-file.o mxml-private.o: mxml-private.h
#
# mxml1.dll
#
mxml1.dll: $(LIBOBJS)
echo Creating $@...
$(DSO) $(DSOFLAGS) $(LDFLAGS) -o $@ $(LIBOBJS) $(LIBS)
#
# libmxml.so.1.6
#
libmxml.so.1.6: $(LIBOBJS)
echo Creating $@...
$(DSO) $(DSOFLAGS) $(LDFLAGS) -o libmxml.so.1.6 $(LIBOBJS) $(LIBS) $(LDFLAGS)
$(RM) libmxml.so libmxml.so.1
$(LN) libmxml.so.1.6 libmxml.so
$(LN) libmxml.so.1.6 libmxml.so.1
#
# libmxml.1.dylib
#
libmxml.1.dylib: $(LIBOBJS)
echo Creating $@...
$(DSO) $(DSOFLAGS) $(LDFLAGS) -o libmxml.1.dylib \
-install_name $(libdir)/libmxml.dylib \
-current_version 1.6.0 \
-compatibility_version 1.0.0 \
$(LIBOBJS) $(LIBS)
$(RM) libmxml.dylib
$(LN) libmxml.1.dylib libmxml.dylib
#
# testmxml
#
testmxml: libmxml.a testmxml.o
echo Linking $@...
$(CC) $(LDFLAGS) -o $@ testmxml.o libmxml.a $(LIBS)
testmxml-vg: $(LIBOBJS) testmxml.o
echo Linking $@...
$(CC) $(LDFLAGS) -o $@ testmxml.o $(LIBOBJS) $(LIBS)
testmxml.o: mxml.h
#
# 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
|