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		=	/usr/bin/ar
22ARFLAGS		=	crvs
23ARCHFLAGS	=	
24CC		=	arm-brcm-linux-uclibcgnueabi-gcc
25CFLAGS		=	$(OPTIM) $(ARCHFLAGS) -Wall -Os -O2 -DBCMWPA2 -DRESTART_ALL_PROCESSES -D__CONFIG_USBAP__ -DBCMQOS -DBCMWPS -D__CONFIG_EMF__ -DTRAFFIC_MGMT -DPHYMON -DSUPPORT_REMOTE_HTTPS -DINCLUDE_WPS_V20 -DINCLUDE_5G_AUTO_CHANNEL -DOPENDNS_PARENTAL_CONTROL -DINCLUDE_UCP -DU12H240 -DR6300v2 -DMULTIPLE_SSID -DENABLE_ML -DBCM53125 -DBCM5301X -DCONFIG_RUSSIA_IPTV -DDLNA -DHTTP_ACCESS_USB -DMAX_USB_ACCESS -DSAMBA_ENABLE -DUSB_NEW_SPEC -DINCLUDE_WIFI_BUTTON -DINCLUDE_USB_LED -DINCLUDE_DUAL_BAND -DSINGLE_FIRMWARE -DINCLUDE_GET_ST_CHKSUM -DUNIFIED_STR_TBL -DFIRST_MTD_ROTATION -DWIFI_ON_OFF_SCHE -DAUTO_CONN_24HR -DIGMP_PROXY -DAP_MODE -D__CONFIG_IGMP_SNOOPING__ -DLINUX26 -DINCLUDE_IPV6 -DPRESET_WL_SECURITY -DNEW_BCM_WPS_IPC -DSUPPORT_AC_MODE -DSTA_MODE -DPPP_RU_DESIGN -DEXT_ACS -D__CONFIG_PLC__ -D__CONFIG_URE__ -DPLC -DWPS_LONGPUSH_DISABLE -Os -DLINUX26 -DCONFIG_KERNEL_2_6_36 -I$(SRC_PATH)/build/usr/include -I$(SRC_PATH)/build/usr/include -D_THREAD_SAFE -D_REENTRANT
26CP		=	/bin/cp
27DSO		=	$(CC)
28DSOFLAGS	=	 -Wl,-soname,libmxml.so.1,-rpath,$(libdir) -shared $(OPTIM)
29LDFLAGS		=	$(OPTIM) $(ARCHFLAGS) -L$(SRC_PATH)/build/usr/lib -Wl,-rpath,$(libdir)
30INSTALL		=	/usr/bin/install -c
31LIBMXML		=	libmxml.so.1.5
32LIBS		=	 -lpthread
33LN		=	/bin/ln -s
34MKDIR		=	/bin/mkdir
35OPTIM		=	-fPIC -Os -g
36RANLIB		=	arm-brcm-linux-uclibcgnueabi-ranlib
37RM		=	/bin/rm -f
38SHELL		=	/bin/sh
39
40
41#
42# Configured directories...
43#
44
45prefix		=	../build/usr
46exec_prefix	=	../build/usr
47bindir		=	${exec_prefix}/bin
48datarootdir	=	${prefix}/share
49includedir	=	${prefix}/include
50libdir		=	${exec_prefix}/lib
51mandir		=	${datarootdir}/man
52docdir		=	${datarootdir}/doc/mxml
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)   
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 header files in $(BUILDROOT)$(includedir)...
144	$(INSTALL_DIR) $(BUILDROOT)$(includedir)
145	$(INSTALL_DATA) mxml.h $(BUILDROOT)$(includedir)
146	echo Installing pkgconfig files in $(BUILDROOT)$(libdir)/pkgconfig...
147	$(INSTALL_DIR) $(BUILDROOT)$(libdir)/pkgconfig
148	$(INSTALL_DATA) mxml.pc $(BUILDROOT)$(libdir)/pkgconfig
149
150install-libmxml.a:
151#	echo Installing libmxml.a to $(BUILDROOT)$(libdir)...
152#	$(INSTALL_DIR) $(BUILDROOT)$(libdir)
153#	$(INSTALL_LIB) libmxml.a $(BUILDROOT)$(libdir)
154#	$(RANLIB) $(BUILDROOT)$(libdir)/libmxml.a
155
156install-libmxml.so.1.5:
157	echo Installing libmxml.so to $(BUILDROOT)$(libdir)...
158	$(INSTALL_DIR) $(BUILDROOT)$(libdir)
159	$(INSTALL_LIB) libmxml.so.1.5 $(BUILDROOT)$(libdir)
160	$(RM) $(BUILDROOT)$(libdir)/libmxml.so
161	$(LN) libmxml.so.1.5 $(BUILDROOT)$(libdir)/libmxml.so
162	$(RM) $(BUILDROOT)$(libdir)/libmxml.so.1
163	$(LN) libmxml.so.1.5 $(BUILDROOT)$(libdir)/libmxml.so.1
164
165install-libmxml.sl.1:
166	echo Installing libmxml.sl to $(BUILDROOT)$(libdir)...
167	$(INSTALL_DIR) $(BUILDROOT)$(libdir)
168	$(INSTALL_LIB) libmxml.sl.1 $(BUILDROOT)$(libdir)
169	$(RM) $(BUILDROOT)$(libdir)/libmxml.so
170	$(LN) libmxml.sl.1 $(BUILDROOT)$(libdir)/libmxml.sl
171
172install-libmxml.1.dylib:
173	echo Installing libmxml.dylib to $(BUILDROOT)$(libdir)...
174	$(INSTALL_DIR) $(BUILDROOT)$(libdir)
175	$(INSTALL_LIB) libmxml.1.dylib $(BUILDROOT)$(libdir)
176	$(RM) $(BUILDROOT)$(libdir)/libmxml.dylib
177	$(LN) libmxml.1.dylib $(BUILDROOT)$(libdir)/libmxml.dylib
178
179
180#
181# Uninstall everything...
182#
183
184uninstall: uninstall-$(LIBMXML) uninstall-libmxml.a
185	echo Uninstalling mxmldoc from $(BUILDROOT)$(bindir)...
186	$(RM) $(BUILDROOT)$(bindir)/mxmldoc
187	echo Uninstalling documentation from $(BUILDROOT)$(docdir)...
188	$(RM) -r $(BUILDROOT)$(docdir)
189	echo Uninstalling headers from $(BUILDROOT)$(includedir)...
190	$(RM) $(BUILDROOT)$(includedir)/mxml.h
191	echo Uninstalling pkgconfig files from $(BUILDROOT)$(libdir)/pkgconfig...
192	$(RM) $(BUILDROOT)$(libdir)/pkgconfig/mxml.pc
193	echo Uninstalling man pages from $(BUILDROOT)$(mandir)...
194	$(RM) $(BUILDROOT)$(mandir)/man1/mxmldoc.1
195	$(RM) $(BUILDROOT)$(mandir)/man3/mxml.3
196
197uninstall-libmxml.a:
198	echo Uninstalling libmxml.a from $(BUILDROOT)$(libdir)...
199	$(RM) $(BUILDROOT)$(libdir)/libmxml.a
200
201uninstall-libmxml.so.1.5:
202	echo Uninstalling libmxml.so from $(BUILDROOT)$(libdir)...
203	$(RM) $(BUILDROOT)$(libdir)/libmxml.so
204	$(RM) $(BUILDROOT)$(libdir)/libmxml.so.1
205	$(RM) $(BUILDROOT)$(libdir)/libmxml.so.1.4
206
207uninstall-libmxml.sl.1:
208	echo Uninstalling libmxml.sl from $(BUILDROOT)$(libdir)...
209	$(RM) $(BUILDROOT)$(libdir)/libmxml.sl
210	$(RM) $(BUILDROOT)$(libdir)/libmxml.sl.1
211
212uninstall-libmxml.1.dylib:
213	echo Uninstalling libmxml.dylib from $(BUILDROOT)$(libdir)...
214	$(RM) $(BUILDROOT)$(libdir)/libmxml.dylib
215	$(RM) $(BUILDROOT)$(libdir)/libmxml.1.dylib
216
217
218#
219# Make packages using EPM (http://www.epmhome.org/)
220#
221
222epm:	all
223	echo Creating distribution packages...
224	epm --output-dir dist -v -f native mxml
225	epm --output-dir dist -v -f portable mxml
226
227
228#
229# autoconf stuff...
230#
231
232Makefile:	configure Makefile.in
233	echo Updating makefile...
234	if test -f config.status; then \
235		./config.status --recheck; \
236		./config.status; \
237	else \
238		./configure; \
239	fi
240	touch config.h
241
242
243config.h:	configure config.h.in
244	echo Updating config.h...
245	autoconf
246	if test -f config.status; then \
247		./config.status --recheck; \
248		./config.status; \
249	else \
250		./configure; \
251	fi
252	touch config.h
253
254
255#
256# Figure out lines-of-code...
257#
258
259.PHONY: sloc
260
261sloc:
262	echo "libmxml: \c"
263	sloccount $(LIBOBJS:.o=.c) mxml-private.c mxml.h 2>/dev/null | \
264		grep "Total Physical" | awk '{print $$9}'
265
266
267#
268# libmxml.a
269#
270
271libmxml.a:	$(LIBOBJS)
272	echo Creating $@...
273	$(RM) $@
274	$(AR) $(ARFLAGS) $@ $(LIBOBJS)
275	$(RANLIB) $@
276
277$(LIBOBJS):	mxml.h
278mxml-entity.o mxml-file.o mxml-private.o: mxml-private.h
279
280
281#
282# libmxml.so.1.5
283#
284
285libmxml.so.1.5:	$(LIBOBJS)
286	echo Creating $@...
287	$(DSO) $(DSOFLAGS) -o libmxml.so.1.5 $(LIBOBJS)
288	$(RM) libmxml.so libmxml.so.1
289	$(LN) libmxml.so.1.5 libmxml.so
290	$(LN) libmxml.so.1.5 libmxml.so.1
291
292
293#
294# libmxml.sl.1
295#
296
297libmxml.sl.1:	$(LIBOBJS)
298	echo Creating $@...
299	$(DSO) $(DSOFLAGS) -o libmxml.sl.1 $(LIBOBJS)
300	$(RM) libmxml.sl
301	$(LN) libmxml.sl.1 libmxml.sl
302
303
304#
305# libmxml.1.dylib
306#
307
308libmxml.1.dylib:	$(LIBOBJS)
309	echo Creating $@...
310	$(DSO) $(DSOFLAGS) -o libmxml.1.dylib \
311		-install_name $(libdir)/libmxml.dylib \
312		-current_version 1.5.0 \
313		-compatibility_version 1.0.0 \
314		$(LIBOBJS)
315	$(RM) libmxml.dylib
316	$(LN) libmxml.1.dylib libmxml.dylib
317
318
319#
320# mxmldoc
321#
322
323mxmldoc:	$(LIBMXML) mxmldoc.o
324	echo Linking $@...
325	$(CC) -L. $(LDFLAGS) -o $@ mxmldoc.o -lmxml $(LIBS)
326
327mxmldoc-static:	libmxml.a mxmldoc.o
328	echo Linking $@...
329	$(CC) $(LDFLAGS) -o $@ mxmldoc.o libmxml.a $(LIBS)
330
331mxmldoc.o:	mxml.h
332
333
334#
335# testmxml
336#
337
338testmxml:	libmxml.a testmxml.o
339	echo Linking $@...
340	$(CC) $(LDFLAGS) -o $@ testmxml.o libmxml.a $(LIBS)
341	@echo Testing library...
342	./testmxml test.xml >temp1.xml 2>temp1s.xml
343	./testmxml temp1.xml >temp2.xml 2>temp2s.xml
344	@if cmp temp1.xml temp2.xml; then \
345		echo Stdio file test passed!; \
346		$(RM) temp2.xml temp2s.xml; \
347	else \
348		echo Stdio file test failed!; \
349	fi
350	@if cmp temp1.xml temp1s.xml; then \
351		echo String test passed!; \
352		$(RM) temp1.xml temp1s.xml; \
353	else \
354		echo String test failed!; \
355	fi
356	@if cmp test.xml test.xmlfd; then \
357		echo File descriptor test passed!; \
358		$(RM) test.xmlfd; \
359	else \
360		echo File descriptor test failed!; \
361	fi
362
363testmxml-vg:	$(LIBOBJS) testmxml.o
364	echo Linking $@...
365	$(CC) $(LDFLAGS) -o $@ testmxml.o $(LIBOBJS) $(LIBS)
366
367testmxml.o:	mxml.h
368
369
370#
371# mxml.xml
372#
373
374mxml.xml:	mxmldoc-static mxml.h $(PUBLIBOBJS:.o=.c)
375	echo Generating API documentation...
376	$(RM) mxml.xml
377	./mxmldoc-static --header doc/reference.heading mxml.xml mxml.h $(PUBLIBOBJS:.o=.c) >doc/reference.html
378	if test "x`uname`" = xDarwin; then \
379		./mxmldoc-static --docset org.minixml.docset \
380			--docversion 2.7 --feedname minixml.org \
381			--feedurl http://www.minixml.org/org.minixml.atom \
382			--header doc/docset.header --intro doc/docset.intro \
383			--css doc/docset.css --title "Mini-XML API Reference" \
384			mxml.xml || exit 1; \
385		$(RM) org.minixml.atom; \
386		/Developer/usr/bin/docsetutil package --output org.minixml.xar \
387			--atom org.minixml.atom \
388			--download-url http://www.minixml.org/org.minixml.xar \
389			org.minixml.docset || exit 1; \
390	fi
391
392valgrind:	mxmldoc-static
393	echo Doing dynamic code analysis using Valgrind...
394	$(RM) valgrind.xml
395	valgrind --tool=memcheck --leak-check=yes ./mxmldoc-static \
396		valgrind.xml mxml.h $(PUBLIBOBJS:.o=.c) \
397		>valgrind.html 2>valgrind.out
398
399
400#
401# doc/mxml.man
402#
403
404doc/mxml.man: mxmldoc-static mxml.xml
405	echo "Generating mxml(3) man page..."
406	$(RM) doc/mxml.man
407	./mxmldoc-static --man mxml --title "Mini-XML API" \
408		--intro doc/intro.man --footer doc/footer.man \
409		mxml.xml >doc/mxml.man
410
411
412#
413# All object files depend on the makefile...
414#
415
416$(OBJS):	Makefile config.h
417
418
419#
420# End of "$Id: Makefile.in 439 2011-04-13 15:43:32Z mike $".
421#
422