1# 2# "$Id: Makefile.in 439 2011-04-13 15:43:32Z mike $" 3# 4# Makefile for Mini-XML, a small XML-like file parsing library. 5# 6# Copyright 2003-2011 by Michael R Sweet. 7# 8# These coded instructions, statements, and computer programs are the 9# property of Michael R Sweet and are protected by Federal copyright 10# law. Distribution and use rights are outlined in the file "COPYING" 11# which should have been included with this file. If this file is 12# missing or damaged, see the license at: 13# 14# http://www.minixml.org/ 15# 16 17# 18# Compiler tools definitions... 19# 20 21AR = @AR@ 22ARFLAGS = @ARFLAGS@ 23ARCHFLAGS = @ARCHFLAGS@ 24CC = @CC@ 25CFLAGS = $(OPTIM) $(ARCHFLAGS) @CFLAGS@ @CPPFLAGS@ @PTHREAD_FLAGS@ 26CP = @CP@ 27DSO = @DSO@ 28DSOFLAGS = @DSOFLAGS@ 29LDFLAGS = $(OPTIM) $(ARCHFLAGS) @LDFLAGS@ 30INSTALL = @INSTALL@ 31LIBMXML = @LIBMXML@ 32LIBS = @LIBS@ @PTHREAD_LIBS@ 33LN = @LN@ -s 34MKDIR = @MKDIR@ 35OPTIM = @OPTIM@ 36RANLIB = @RANLIB@ 37RM = @RM@ -f 38SHELL = /bin/sh 39 40 41# 42# Configured directories... 43# 44 45prefix = @prefix@ 46exec_prefix = @exec_prefix@ 47bindir = @bindir@ 48datarootdir = @datarootdir@ 49includedir = @includedir@ 50libdir = @libdir@ 51mandir = @mandir@ 52docdir = @docdir@ 53BUILDROOT = $(DSTROOT) 54 55 56# 57# Install commands... 58# 59 60INSTALL_BIN = $(LIBTOOL) $(INSTALL) -m 755 -s 61INSTALL_DATA = $(INSTALL) -m 644 62INSTALL_DIR = $(INSTALL) -d 63INSTALL_LIB = $(LIBTOOL) $(INSTALL) -m 755 64INSTALL_MAN = $(INSTALL) -m 644 65INSTALL_SCRIPT = $(INSTALL) -m 755 66 67 68# 69# Rules... 70# 71 72.SILENT: 73.SUFFIXES: .c .man .o 74.c.o: 75 echo Compiling $< 76 $(CC) $(CFLAGS) -c -o $@ $< 77 78 79# 80# Targets... 81# 82 83DOCFILES = doc/0.gif doc/1.gif doc/2.gif doc/3.gif doc/4.gif \ 84 doc/A.gif doc/B.gif doc/C.gif doc/D.gif \ 85 doc/mxml.html doc/mxmldoc.xsd \ 86 README COPYING CHANGES 87PUBLIBOBJS = mxml-attr.o mxml-entity.o mxml-file.o mxml-get.o \ 88 mxml-index.o mxml-node.o mxml-search.o mxml-set.o 89LIBOBJS = $(PUBLIBOBJS) mxml-private.o mxml-string.o 90OBJS = mxmldoc.o testmxml.o $(LIBOBJS) 91TARGETS = $(LIBMXML) mxmldoc testmxml mxml.xml doc/mxml.man 92 93 94# 95# Make everything... 96# 97 98all: Makefile config.h $(TARGETS) 99 100 101# 102# Clean everything... 103# 104 105clean: 106 echo Cleaning build files... 107 $(RM) $(OBJS) $(TARGETS) 108 $(RM) mxmldoc-static libmxml.a libmxml.so.1.5 libmxml.sl.1 libmxml.1.dylib 109 110 111# 112# Really clean everything... 113# 114 115distclean: clean 116 echo Cleaning distribution files... 117 $(RM) config.cache config.log config.status 118 $(RM) Makefile config.h 119 $(RM) -r autom4te*.cache 120 $(RM) *.bck *.bak 121 $(RM) -r clang 122 123 124# 125# Run the clang.llvm.org static code analysis tool on the C sources. 126# 127 128.PHONY: clang clang-changes 129clang: 130 echo Doing static code analysis of all code using CLANG... 131 $(RM) -r clang 132 scan-build -V -k -o `pwd`/clang $(MAKE) $(MFLAGS) clean all 133clang-changes: 134 echo Doing static code analysis of changed code using CLANG... 135 scan-build -V -k -o `pwd`/clang $(MAKE) $(MFLAGS) all 136 137 138# 139# Install everything... 140# 141 142install: $(TARGETS) install-$(LIBMXML) install-libmxml.a 143 echo Installing mxmldoc in $(BUILDROOT)$(bindir)... 144 $(INSTALL_DIR) $(BUILDROOT)$(bindir) 145 $(INSTALL_BIN) mxmldoc $(BUILDROOT)$(bindir) 146 echo Installing documentation in $(BUILDROOT)$(docdir)... 147 $(INSTALL_DIR) $(BUILDROOT)$(docdir) 148 for file in $(DOCFILES); do \ 149 $(INSTALL_MAN) $$file $(BUILDROOT)$(docdir); \ 150 done 151 echo Installing header files in $(BUILDROOT)$(includedir)... 152 $(INSTALL_DIR) $(BUILDROOT)$(includedir) 153 $(INSTALL_DATA) mxml.h $(BUILDROOT)$(includedir) 154 echo Installing pkgconfig files in $(BUILDROOT)$(libdir)/pkgconfig... 155 $(INSTALL_DIR) $(BUILDROOT)$(libdir)/pkgconfig 156 $(INSTALL_DATA) mxml.pc $(BUILDROOT)$(libdir)/pkgconfig 157 echo Installing man pages in $(BUILDROOT)$(mandir)... 158 $(INSTALL_DIR) $(BUILDROOT)$(mandir)/man1 159 $(INSTALL_MAN) doc/mxmldoc.man $(BUILDROOT)$(mandir)/man1/mxmldoc.1 160 $(INSTALL_DIR) $(BUILDROOT)$(mandir)/man3 161 $(INSTALL_MAN) doc/mxml.man $(BUILDROOT)$(mandir)/man3/mxml.3 162 163install-libmxml.a: 164 echo Installing libmxml.a to $(BUILDROOT)$(libdir)... 165 $(INSTALL_DIR) $(BUILDROOT)$(libdir) 166 $(INSTALL_LIB) libmxml.a $(BUILDROOT)$(libdir) 167 $(RANLIB) $(BUILDROOT)$(libdir)/libmxml.a 168 169install-libmxml.so.1.5: 170 echo Installing libmxml.so to $(BUILDROOT)$(libdir)... 171 $(INSTALL_DIR) $(BUILDROOT)$(libdir) 172 $(INSTALL_LIB) libmxml.so.1.5 $(BUILDROOT)$(libdir) 173 $(RM) $(BUILDROOT)$(libdir)/libmxml.so 174 $(LN) libmxml.so.1.5 $(BUILDROOT)$(libdir)/libmxml.so 175 $(RM) $(BUILDROOT)$(libdir)/libmxml.so.1 176 $(LN) libmxml.so.1.5 $(BUILDROOT)$(libdir)/libmxml.so.1 177 178install-libmxml.sl.1: 179 echo Installing libmxml.sl to $(BUILDROOT)$(libdir)... 180 $(INSTALL_DIR) $(BUILDROOT)$(libdir) 181 $(INSTALL_LIB) libmxml.sl.1 $(BUILDROOT)$(libdir) 182 $(RM) $(BUILDROOT)$(libdir)/libmxml.so 183 $(LN) libmxml.sl.1 $(BUILDROOT)$(libdir)/libmxml.sl 184 185install-libmxml.1.dylib: 186 echo Installing libmxml.dylib to $(BUILDROOT)$(libdir)... 187 $(INSTALL_DIR) $(BUILDROOT)$(libdir) 188 $(INSTALL_LIB) libmxml.1.dylib $(BUILDROOT)$(libdir) 189 $(RM) $(BUILDROOT)$(libdir)/libmxml.dylib 190 $(LN) libmxml.1.dylib $(BUILDROOT)$(libdir)/libmxml.dylib 191 192 193# 194# Uninstall everything... 195# 196 197uninstall: uninstall-$(LIBMXML) uninstall-libmxml.a 198 echo Uninstalling mxmldoc from $(BUILDROOT)$(bindir)... 199 $(RM) $(BUILDROOT)$(bindir)/mxmldoc 200 echo Uninstalling documentation from $(BUILDROOT)$(docdir)... 201 $(RM) -r $(BUILDROOT)$(docdir) 202 echo Uninstalling headers from $(BUILDROOT)$(includedir)... 203 $(RM) $(BUILDROOT)$(includedir)/mxml.h 204 echo Uninstalling pkgconfig files from $(BUILDROOT)$(libdir)/pkgconfig... 205 $(RM) $(BUILDROOT)$(libdir)/pkgconfig/mxml.pc 206 echo Uninstalling man pages from $(BUILDROOT)$(mandir)... 207 $(RM) $(BUILDROOT)$(mandir)/man1/mxmldoc.1 208 $(RM) $(BUILDROOT)$(mandir)/man3/mxml.3 209 210uninstall-libmxml.a: 211 echo Uninstalling libmxml.a from $(BUILDROOT)$(libdir)... 212 $(RM) $(BUILDROOT)$(libdir)/libmxml.a 213 214uninstall-libmxml.so.1.5: 215 echo Uninstalling libmxml.so from $(BUILDROOT)$(libdir)... 216 $(RM) $(BUILDROOT)$(libdir)/libmxml.so 217 $(RM) $(BUILDROOT)$(libdir)/libmxml.so.1 218 $(RM) $(BUILDROOT)$(libdir)/libmxml.so.1.4 219 220uninstall-libmxml.sl.1: 221 echo Uninstalling libmxml.sl from $(BUILDROOT)$(libdir)... 222 $(RM) $(BUILDROOT)$(libdir)/libmxml.sl 223 $(RM) $(BUILDROOT)$(libdir)/libmxml.sl.1 224 225uninstall-libmxml.1.dylib: 226 echo Uninstalling libmxml.dylib from $(BUILDROOT)$(libdir)... 227 $(RM) $(BUILDROOT)$(libdir)/libmxml.dylib 228 $(RM) $(BUILDROOT)$(libdir)/libmxml.1.dylib 229 230 231# 232# Make packages using EPM (http://www.epmhome.org/) 233# 234 235epm: all 236 echo Creating distribution packages... 237 epm --output-dir dist -v -f native mxml 238 epm --output-dir dist -v -f portable mxml 239 240 241# 242# autoconf stuff... 243# 244 245Makefile: configure Makefile.in 246 echo Updating makefile... 247 if test -f config.status; then \ 248 ./config.status --recheck; \ 249 ./config.status; \ 250 else \ 251 ./configure; \ 252 fi 253 touch config.h 254 255 256config.h: configure config.h.in 257 echo Updating config.h... 258 autoconf 259 if test -f config.status; then \ 260 ./config.status --recheck; \ 261 ./config.status; \ 262 else \ 263 ./configure; \ 264 fi 265 touch config.h 266 267 268# 269# Figure out lines-of-code... 270# 271 272.PHONY: sloc 273 274sloc: 275 echo "libmxml: \c" 276 sloccount $(LIBOBJS:.o=.c) mxml-private.c mxml.h 2>/dev/null | \ 277 grep "Total Physical" | awk '{print $$9}' 278 279 280# 281# libmxml.a 282# 283 284libmxml.a: $(LIBOBJS) 285 echo Creating $@... 286 $(RM) $@ 287 $(AR) $(ARFLAGS) $@ $(LIBOBJS) 288 $(RANLIB) $@ 289 290$(LIBOBJS): mxml.h 291mxml-entity.o mxml-file.o mxml-private.o: mxml-private.h 292 293 294# 295# libmxml.so.1.5 296# 297 298libmxml.so.1.5: $(LIBOBJS) 299 echo Creating $@... 300 $(DSO) $(DSOFLAGS) -o libmxml.so.1.5 $(LIBOBJS) 301 $(RM) libmxml.so libmxml.so.1 302 $(LN) libmxml.so.1.5 libmxml.so 303 $(LN) libmxml.so.1.5 libmxml.so.1 304 305 306# 307# libmxml.sl.1 308# 309 310libmxml.sl.1: $(LIBOBJS) 311 echo Creating $@... 312 $(DSO) $(DSOFLAGS) -o libmxml.sl.1 $(LIBOBJS) 313 $(RM) libmxml.sl 314 $(LN) libmxml.sl.1 libmxml.sl 315 316 317# 318# libmxml.1.dylib 319# 320 321libmxml.1.dylib: $(LIBOBJS) 322 echo Creating $@... 323 $(DSO) $(DSOFLAGS) -o libmxml.1.dylib \ 324 -install_name $(libdir)/libmxml.dylib \ 325 -current_version 1.5.0 \ 326 -compatibility_version 1.0.0 \ 327 $(LIBOBJS) 328 $(RM) libmxml.dylib 329 $(LN) libmxml.1.dylib libmxml.dylib 330 331 332# 333# mxmldoc 334# 335 336mxmldoc: $(LIBMXML) mxmldoc.o 337 echo Linking $@... 338 $(CC) -L. $(LDFLAGS) -o $@ mxmldoc.o -lmxml $(LIBS) 339 340mxmldoc-static: libmxml.a mxmldoc.o 341 echo Linking $@... 342 $(CC) $(LDFLAGS) -o $@ mxmldoc.o libmxml.a $(LIBS) 343 344mxmldoc.o: mxml.h 345 346 347# 348# testmxml 349# 350 351testmxml: libmxml.a testmxml.o 352 echo Linking $@... 353 $(CC) $(LDFLAGS) -o $@ testmxml.o libmxml.a $(LIBS) 354 @echo Testing library... 355 ./testmxml test.xml >temp1.xml 2>temp1s.xml 356 ./testmxml temp1.xml >temp2.xml 2>temp2s.xml 357 @if cmp temp1.xml temp2.xml; then \ 358 echo Stdio file test passed!; \ 359 $(RM) temp2.xml temp2s.xml; \ 360 else \ 361 echo Stdio file test failed!; \ 362 fi 363 @if cmp temp1.xml temp1s.xml; then \ 364 echo String test passed!; \ 365 $(RM) temp1.xml temp1s.xml; \ 366 else \ 367 echo String test failed!; \ 368 fi 369 @if cmp test.xml test.xmlfd; then \ 370 echo File descriptor test passed!; \ 371 $(RM) test.xmlfd; \ 372 else \ 373 echo File descriptor test failed!; \ 374 fi 375 376testmxml-vg: $(LIBOBJS) testmxml.o 377 echo Linking $@... 378 $(CC) $(LDFLAGS) -o $@ testmxml.o $(LIBOBJS) $(LIBS) 379 380testmxml.o: mxml.h 381 382 383# 384# mxml.xml 385# 386 387mxml.xml: mxmldoc-static mxml.h $(PUBLIBOBJS:.o=.c) 388 echo Generating API documentation... 389 $(RM) mxml.xml 390 ./mxmldoc-static --header doc/reference.heading mxml.xml mxml.h $(PUBLIBOBJS:.o=.c) >doc/reference.html 391 if test "x`uname`" = xDarwin; then \ 392 ./mxmldoc-static --docset org.minixml.docset \ 393 --docversion @VERSION@ --feedname minixml.org \ 394 --feedurl http://www.minixml.org/org.minixml.atom \ 395 --header doc/docset.header --intro doc/docset.intro \ 396 --css doc/docset.css --title "Mini-XML API Reference" \ 397 mxml.xml || exit 1; \ 398 $(RM) org.minixml.atom; \ 399 /Developer/usr/bin/docsetutil package --output org.minixml.xar \ 400 --atom org.minixml.atom \ 401 --download-url http://www.minixml.org/org.minixml.xar \ 402 org.minixml.docset || exit 1; \ 403 fi 404 405valgrind: mxmldoc-static 406 echo Doing dynamic code analysis using Valgrind... 407 $(RM) valgrind.xml 408 valgrind --tool=memcheck --leak-check=yes ./mxmldoc-static \ 409 valgrind.xml mxml.h $(PUBLIBOBJS:.o=.c) \ 410 >valgrind.html 2>valgrind.out 411 412 413# 414# doc/mxml.man 415# 416 417doc/mxml.man: mxmldoc-static mxml.xml 418 echo "Generating mxml(3) man page..." 419 $(RM) doc/mxml.man 420 ./mxmldoc-static --man mxml --title "Mini-XML API" \ 421 --intro doc/intro.man --footer doc/footer.man \ 422 mxml.xml >doc/mxml.man 423 424 425# 426# All object files depend on the makefile... 427# 428 429$(OBJS): Makefile config.h 430 431 432# 433# End of "$Id: Makefile.in 439 2011-04-13 15:43:32Z mike $". 434# 435