summaryrefslogtreecommitdiff
path: root/Makefile.am
blob: 4844243bf3ae060a069281b61923cf053f84a680 (plain)
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
EXTRA_DIST = Copyright examples solaris tests
WIN32_DIST = README TODO Copyright COPYING AUTHORS ChangeLog INSTALL NEWS xml.exe
WIN32_doc_DIST = $(generated_docs) doc/html.css

ACLOCAL_AMFLAGS = -I m4
if GCC
AM_CFLAGS = -Wall -pedantic
endif

GIT_DESCRIBE = git describe --tags --dirty

# TODO: figure out why log removal is needed and/or make it completely automatic
dist-hook:
	@for log in $(srcdir)/examples/*.log ; do if [ -f "$$log" ] ; then \
	  rm $(srcdir)/examples/*.log ; \
	  echo 'ERROR: log files need to cleaned BEFORE making tarball, try again'; exit 1 ; fi ; done
	@ if [ -d .git ] ; then \
	    if [ $(VERSION) != `$(GIT_DESCRIBE)` ] ; then \
		echo 'ERROR: version mismatch, rerun autoconf -f' ; exit 1 ; fi ; \
	    $(SED) 's/\[m4_esyscmd_s(\[$(GIT_DESCRIBE)\])\]/[$(VERSION)]/' \
	      $(srcdir)/configure.ac > $(distdir)/configure.ac ; fi

cleantar:
	@(rm -f xmlstarlet*.tar.gz)

rpm: cleantar distdir xmlstarlet.spec
	cp xmlstarlet.spec $(distdir)
	$(AMTAR) -czf $(distdir).tar.gz $(distdir)
	rpmbuild -ta $(distdir).tar.gz

$(distdir)-win32.zip: xml.exe
	mkdir -p /tmp/$(distdir)/doc
	cp $(WIN32_DIST) /tmp/$(distdir)
	cp $(WIN32_doc_DIST) /tmp/$(distdir)/doc
	strip /tmp/$(distdir)/xml.exe
	cd /tmp && zip -9 --symlinks --recurse-paths --to-crlf --move \
	  $(distdir)-win32.zip $(distdir)
	mv /tmp/$(distdir)-win32.zip .

dist-win32: $(distdir)-win32.zip

version.h: VERSION
	@if [ -d .git ] ; then \
	    VERSION=`$(GIT_DESCRIBE)`; \
	else VERSION=$(VERSION) ; fi; \
	NEW_VERSION="#define VERSION \"$$VERSION\""; \
	OLD_VERSION=`cat version.h 2>/dev/null` ; \
	if [ "$$NEW_VERSION" != "$$OLD_VERSION" ] ; then \
	    echo "$$NEW_VERSION" > version.h ; \
	    echo "version.h: $$NEW_VERSION"; fi
VERSION:

# need to build version.h even if dependency files haven't been
# generated
src/xml.o : version.h



# testing
include examples/tests.mk

# building executable
bin_PROGRAMS = xml

include src/sources.mk
xml_SOURCES += version.h
nodist_xml_SOURCES = $(generated_usage_sources)
EXTRA_DIST += $(usage_texts) usage2c.awk

.txt.c:
	$(AM_V_GEN)$(AWK) -f $(srcdir)/usage2c.awk $< > $@
$(generated_usage_sources) : usage2c.awk


# doc
include doc/doc.mk

man_MANS = $(manpage)
dist_doc_DATA = $(userguide_gen) doc/html.css $(txtguide)
EXTRA_DIST += $(manpage_src) $(userguide_src) $(txtguide_src)
EXTRA_DIST += $(buildfiles_docs) $(manpage)


CLEANFILES = version.h $(generated_usage_sources)
MAINTAINERCLEANFILES = $(manpage) $(userguide_gen) $(txtguide)

.PHONY: cleantar rpm dist-win32 VERSION doc