Makefile 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. #
  2. # "$Id: Makefile.in 459 2014-10-19 17:21:48Z msweet $"
  3. #
  4. # Makefile for Mini-XML, a small XML-like file parsing library.
  5. #
  6. # Copyright 2003-2014 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.msweet.org/projects.php/Mini-XML
  15. #
  16. #
  17. # Compiler tools definitions...
  18. #
  19. AR = /usr/bin/ar
  20. ARFLAGS = crvs
  21. ARCHFLAGS =
  22. CC = gcc
  23. CFLAGS = $(OPTIM) $(ARCHFLAGS) -Wall -D_THREAD_SAFE -D_REENTRANT
  24. CP = /bin/cp
  25. DSO = $(CC)
  26. DSOFLAGS = -Wl,-soname,libmxml.so.1,-rpath,$(libdir) -shared $(OPTIM)
  27. LDFLAGS = $(OPTIM) $(ARCHFLAGS) -Wl,-rpath,$(libdir)
  28. INSTALL = /usr/bin/install -c
  29. LIBMXML = libmxml.so.1.5
  30. LIBS = -lpthread
  31. LN = /bin/ln -s
  32. MKDIR = /bin/mkdir
  33. OPTIM = -fPIC -Os -g
  34. RANLIB = ranlib
  35. RM = /bin/rm -f
  36. SHELL = /bin/sh
  37. #
  38. # Configured directories...
  39. #
  40. prefix = /usr/local
  41. exec_prefix = /usr/local
  42. bindir = ${exec_prefix}/bin
  43. datarootdir = ${prefix}/share
  44. includedir = ${prefix}/include
  45. libdir = ${exec_prefix}/lib
  46. mandir = ${datarootdir}/man
  47. docdir = ${datarootdir}/doc/mxml
  48. BUILDROOT = $(DSTROOT)
  49. #
  50. # Install commands...
  51. #
  52. INSTALL_BIN = $(LIBTOOL) $(INSTALL) -m 755 -s
  53. INSTALL_DATA = $(INSTALL) -m 644
  54. INSTALL_DIR = $(INSTALL) -d
  55. INSTALL_LIB = $(LIBTOOL) $(INSTALL) -m 755
  56. INSTALL_MAN = $(INSTALL) -m 644
  57. INSTALL_SCRIPT = $(INSTALL) -m 755
  58. #
  59. # Rules...
  60. #
  61. .SILENT:
  62. .SUFFIXES: .c .man .o
  63. .c.o:
  64. echo Compiling $<
  65. $(CC) $(CFLAGS) -c -o $@ $<
  66. #
  67. # Targets...
  68. #
  69. DOCFILES = doc/0.gif doc/1.gif doc/2.gif doc/3.gif doc/4.gif \
  70. doc/A.gif doc/B.gif doc/C.gif doc/D.gif \
  71. doc/mxml.html doc/mxmldoc.xsd \
  72. README COPYING CHANGES
  73. PUBLIBOBJS = mxml-attr.o mxml-entity.o mxml-file.o mxml-get.o \
  74. mxml-index.o mxml-node.o mxml-search.o mxml-set.o
  75. LIBOBJS = $(PUBLIBOBJS) mxml-private.o mxml-string.o
  76. OBJS = mxmldoc.o testmxml.o $(LIBOBJS)
  77. TARGETS = $(LIBMXML) mxmldoc testmxml mxml.xml doc/mxml.man
  78. #
  79. # Make everything...
  80. #
  81. all: Makefile config.h $(TARGETS)
  82. #
  83. # Clean everything...
  84. #
  85. clean:
  86. echo Cleaning build files...
  87. $(RM) $(OBJS) $(TARGETS)
  88. $(RM) mxmldoc-static libmxml.a libmxml.so.1.5 libmxml.sl.1 libmxml.1.dylib
  89. #
  90. # Really clean everything...
  91. #
  92. distclean: clean
  93. echo Cleaning distribution files...
  94. $(RM) config.cache config.log config.status
  95. $(RM) Makefile config.h
  96. $(RM) -r autom4te*.cache
  97. $(RM) *.bck *.bak
  98. $(RM) -r clang
  99. #
  100. # Run the clang.llvm.org static code analysis tool on the C sources.
  101. #
  102. .PHONY: clang clang-changes
  103. clang:
  104. echo Doing static code analysis of all code using CLANG...
  105. $(RM) -r clang
  106. scan-build -V -k -o `pwd`/clang $(MAKE) $(MFLAGS) clean all
  107. clang-changes:
  108. echo Doing static code analysis of changed code using CLANG...
  109. scan-build -V -k -o `pwd`/clang $(MAKE) $(MFLAGS) all
  110. #
  111. # Install everything...
  112. #
  113. install: $(TARGETS) install-$(LIBMXML) install-libmxml.a
  114. echo Installing mxmldoc in $(BUILDROOT)$(bindir)...
  115. $(INSTALL_DIR) $(BUILDROOT)$(bindir)
  116. $(INSTALL_BIN) mxmldoc $(BUILDROOT)$(bindir)
  117. echo Installing documentation in $(BUILDROOT)$(docdir)...
  118. $(INSTALL_DIR) $(BUILDROOT)$(docdir)
  119. for file in $(DOCFILES); do \
  120. $(INSTALL_MAN) $$file $(BUILDROOT)$(docdir); \
  121. done
  122. echo Installing header files in $(BUILDROOT)$(includedir)...
  123. $(INSTALL_DIR) $(BUILDROOT)$(includedir)
  124. $(INSTALL_DATA) mxml.h $(BUILDROOT)$(includedir)
  125. echo Installing pkgconfig files in $(BUILDROOT)$(libdir)/pkgconfig...
  126. $(INSTALL_DIR) $(BUILDROOT)$(libdir)/pkgconfig
  127. $(INSTALL_DATA) mxml.pc $(BUILDROOT)$(libdir)/pkgconfig
  128. echo Installing man pages in $(BUILDROOT)$(mandir)...
  129. $(INSTALL_DIR) $(BUILDROOT)$(mandir)/man1
  130. $(INSTALL_MAN) doc/mxmldoc.man $(BUILDROOT)$(mandir)/man1/mxmldoc.1
  131. $(INSTALL_DIR) $(BUILDROOT)$(mandir)/man3
  132. $(INSTALL_MAN) doc/mxml.man $(BUILDROOT)$(mandir)/man3/mxml.3
  133. install-libmxml.a:
  134. echo Installing libmxml.a to $(BUILDROOT)$(libdir)...
  135. $(INSTALL_DIR) $(BUILDROOT)$(libdir)
  136. $(INSTALL_LIB) libmxml.a $(BUILDROOT)$(libdir)
  137. $(RANLIB) $(BUILDROOT)$(libdir)/libmxml.a
  138. install-libmxml.so.1.5:
  139. echo Installing libmxml.so to $(BUILDROOT)$(libdir)...
  140. $(INSTALL_DIR) $(BUILDROOT)$(libdir)
  141. $(INSTALL_LIB) libmxml.so.1.5 $(BUILDROOT)$(libdir)
  142. $(RM) $(BUILDROOT)$(libdir)/libmxml.so
  143. $(LN) libmxml.so.1.5 $(BUILDROOT)$(libdir)/libmxml.so
  144. $(RM) $(BUILDROOT)$(libdir)/libmxml.so.1
  145. $(LN) libmxml.so.1.5 $(BUILDROOT)$(libdir)/libmxml.so.1
  146. install-libmxml.sl.1:
  147. echo Installing libmxml.sl to $(BUILDROOT)$(libdir)...
  148. $(INSTALL_DIR) $(BUILDROOT)$(libdir)
  149. $(INSTALL_LIB) libmxml.sl.1 $(BUILDROOT)$(libdir)
  150. $(RM) $(BUILDROOT)$(libdir)/libmxml.so
  151. $(LN) libmxml.sl.1 $(BUILDROOT)$(libdir)/libmxml.sl
  152. install-libmxml.1.dylib:
  153. echo Installing libmxml.dylib to $(BUILDROOT)$(libdir)...
  154. $(INSTALL_DIR) $(BUILDROOT)$(libdir)
  155. $(INSTALL_LIB) libmxml.1.dylib $(BUILDROOT)$(libdir)
  156. $(RM) $(BUILDROOT)$(libdir)/libmxml.dylib
  157. $(LN) libmxml.1.dylib $(BUILDROOT)$(libdir)/libmxml.dylib
  158. #
  159. # Uninstall everything...
  160. #
  161. uninstall: uninstall-$(LIBMXML) uninstall-libmxml.a
  162. echo Uninstalling mxmldoc from $(BUILDROOT)$(bindir)...
  163. $(RM) $(BUILDROOT)$(bindir)/mxmldoc
  164. echo Uninstalling documentation from $(BUILDROOT)$(docdir)...
  165. $(RM) -r $(BUILDROOT)$(docdir)
  166. echo Uninstalling headers from $(BUILDROOT)$(includedir)...
  167. $(RM) $(BUILDROOT)$(includedir)/mxml.h
  168. echo Uninstalling pkgconfig files from $(BUILDROOT)$(libdir)/pkgconfig...
  169. $(RM) $(BUILDROOT)$(libdir)/pkgconfig/mxml.pc
  170. echo Uninstalling man pages from $(BUILDROOT)$(mandir)...
  171. $(RM) $(BUILDROOT)$(mandir)/man1/mxmldoc.1
  172. $(RM) $(BUILDROOT)$(mandir)/man3/mxml.3
  173. uninstall-libmxml.a:
  174. echo Uninstalling libmxml.a from $(BUILDROOT)$(libdir)...
  175. $(RM) $(BUILDROOT)$(libdir)/libmxml.a
  176. uninstall-libmxml.so.1.5:
  177. echo Uninstalling libmxml.so from $(BUILDROOT)$(libdir)...
  178. $(RM) $(BUILDROOT)$(libdir)/libmxml.so
  179. $(RM) $(BUILDROOT)$(libdir)/libmxml.so.1
  180. $(RM) $(BUILDROOT)$(libdir)/libmxml.so.1.4
  181. uninstall-libmxml.sl.1:
  182. echo Uninstalling libmxml.sl from $(BUILDROOT)$(libdir)...
  183. $(RM) $(BUILDROOT)$(libdir)/libmxml.sl
  184. $(RM) $(BUILDROOT)$(libdir)/libmxml.sl.1
  185. uninstall-libmxml.1.dylib:
  186. echo Uninstalling libmxml.dylib from $(BUILDROOT)$(libdir)...
  187. $(RM) $(BUILDROOT)$(libdir)/libmxml.dylib
  188. $(RM) $(BUILDROOT)$(libdir)/libmxml.1.dylib
  189. #
  190. # Make packages using EPM (http://www.epmhome.org/)
  191. #
  192. epm: all
  193. echo Creating distribution packages...
  194. epm --output-dir dist -v -f native mxml
  195. epm --output-dir dist -v -f portable mxml
  196. #
  197. # autoconf stuff...
  198. #
  199. Makefile: configure Makefile.in
  200. echo Updating makefile...
  201. if test -f config.status; then \
  202. ./config.status --recheck; \
  203. ./config.status; \
  204. else \
  205. ./configure; \
  206. fi
  207. touch config.h
  208. config.h: configure config.h.in
  209. echo Updating config.h...
  210. autoconf
  211. if test -f config.status; then \
  212. ./config.status --recheck; \
  213. ./config.status; \
  214. else \
  215. ./configure; \
  216. fi
  217. touch config.h
  218. #
  219. # Figure out lines-of-code...
  220. #
  221. .PHONY: sloc
  222. sloc:
  223. echo "libmxml: \c"
  224. sloccount $(LIBOBJS:.o=.c) mxml-private.c mxml.h 2>/dev/null | \
  225. grep "Total Physical" | awk '{print $$9}'
  226. #
  227. # libmxml.a
  228. #
  229. libmxml.a: $(LIBOBJS)
  230. echo Creating $@...
  231. $(RM) $@
  232. $(AR) $(ARFLAGS) $@ $(LIBOBJS)
  233. $(RANLIB) $@
  234. $(LIBOBJS): mxml.h
  235. mxml-entity.o mxml-file.o mxml-private.o: mxml-private.h
  236. #
  237. # libmxml.so.1.5
  238. #
  239. libmxml.so.1.5: $(LIBOBJS)
  240. echo Creating $@...
  241. $(DSO) $(DSOFLAGS) -o libmxml.so.1.5 $(LIBOBJS)
  242. $(RM) libmxml.so libmxml.so.1
  243. $(LN) libmxml.so.1.5 libmxml.so
  244. $(LN) libmxml.so.1.5 libmxml.so.1
  245. #
  246. # libmxml.sl.1
  247. #
  248. libmxml.sl.1: $(LIBOBJS)
  249. echo Creating $@...
  250. $(DSO) $(DSOFLAGS) -o libmxml.sl.1 $(LIBOBJS)
  251. $(RM) libmxml.sl
  252. $(LN) libmxml.sl.1 libmxml.sl
  253. #
  254. # libmxml.1.dylib
  255. #
  256. libmxml.1.dylib: $(LIBOBJS)
  257. echo Creating $@...
  258. $(DSO) $(DSOFLAGS) -o libmxml.1.dylib \
  259. -install_name $(libdir)/libmxml.dylib \
  260. -current_version 1.5.0 \
  261. -compatibility_version 1.0.0 \
  262. $(LIBOBJS)
  263. $(RM) libmxml.dylib
  264. $(LN) libmxml.1.dylib libmxml.dylib
  265. #
  266. # mxmldoc
  267. #
  268. mxmldoc: $(LIBMXML) mxmldoc.o
  269. echo Linking $@...
  270. $(CC) -L. $(LDFLAGS) -o $@ mxmldoc.o -lmxml $(LIBS)
  271. mxmldoc-static: libmxml.a mxmldoc.o
  272. echo Linking $@...
  273. $(CC) $(LDFLAGS) -o $@ mxmldoc.o libmxml.a $(LIBS)
  274. mxmldoc.o: mxml.h
  275. #
  276. # testmxml
  277. #
  278. testmxml: libmxml.a testmxml.o
  279. echo Linking $@...
  280. $(CC) $(LDFLAGS) -o $@ testmxml.o libmxml.a $(LIBS)
  281. @echo Testing library...
  282. ./testmxml test.xml temp1s.xml >temp1.xml
  283. ./testmxml temp1.xml temp2s.xml >temp2.xml
  284. @if cmp temp1.xml temp2.xml; then \
  285. echo Stdio file test passed!; \
  286. $(RM) temp2.xml temp2s.xml; \
  287. else \
  288. echo Stdio file test failed!; \
  289. fi
  290. @if cmp temp1.xml temp1s.xml; then \
  291. echo String test passed!; \
  292. $(RM) temp1.xml temp1s.xml; \
  293. else \
  294. echo String test failed!; \
  295. fi
  296. @if cmp test.xml test.xmlfd; then \
  297. echo File descriptor test passed!; \
  298. $(RM) test.xmlfd; \
  299. else \
  300. echo File descriptor test failed!; \
  301. fi
  302. testmxml-vg: $(LIBOBJS) testmxml.o
  303. echo Linking $@...
  304. $(CC) $(LDFLAGS) -o $@ testmxml.o $(LIBOBJS) $(LIBS)
  305. testmxml.o: mxml.h
  306. #
  307. # mxml.xml
  308. #
  309. mxml.xml: mxmldoc-static mxml.h $(PUBLIBOBJS:.o=.c)
  310. echo Generating API documentation...
  311. $(RM) mxml.xml
  312. ./mxmldoc-static --header doc/reference.heading mxml.xml mxml.h $(PUBLIBOBJS:.o=.c) >doc/reference.html
  313. if test "x`uname`" = xDarwin; then \
  314. ./mxmldoc-static --docset org.minixml.docset \
  315. --docversion 2.10 --feedname minixml.org \
  316. --feedurl http://www.minixml.org/org.minixml.atom \
  317. --header doc/docset.header --intro doc/docset.intro \
  318. --css doc/docset.css --title "Mini-XML API Reference" \
  319. mxml.xml || exit 1; \
  320. $(RM) org.minixml.atom; \
  321. xcrun docsetutil package --output org.minixml.xar \
  322. --atom org.minixml.atom \
  323. --download-url http://www.minixml.org/org.minixml.xar \
  324. org.minixml.docset || exit 1; \
  325. fi
  326. valgrind: mxmldoc-static
  327. echo Doing dynamic code analysis using Valgrind...
  328. $(RM) valgrind.xml
  329. valgrind --tool=memcheck --leak-check=yes ./mxmldoc-static \
  330. valgrind.xml mxml.h $(PUBLIBOBJS:.o=.c) \
  331. >valgrind.html 2>valgrind.out
  332. #
  333. # doc/mxml.man
  334. #
  335. doc/mxml.man: mxmldoc-static mxml.xml
  336. echo "Generating mxml(3) man page..."
  337. $(RM) doc/mxml.man
  338. ./mxmldoc-static --man mxml --title "Mini-XML API" \
  339. --intro doc/intro.man --footer doc/footer.man \
  340. mxml.xml >doc/mxml.man
  341. #
  342. # All object files depend on the makefile...
  343. #
  344. $(OBJS): Makefile config.h
  345. #
  346. # End of "$Id: Makefile.in 459 2014-10-19 17:21:48Z msweet $".
  347. #