1# vim:ft=automake
2
3AM_CFLAGS="-D__STDC_LIMIT_MACROS"
4
5BUILT_SOURCES=
6doc_DATA=
7EXTRA_DIST=
8TESTS=
9bin_PROGRAMS=
10sbin_PROGRAMS=
11check_PROGRAMS=
12lib_LTLIBRARIES=
13man_MANS=
14noinst_HEADERS=
15noinst_LTLIBRARIES=
16noinst_PROGRAMS=
17
18if !TARGET_OSX
19# GNU style is "make check", this will make check and test work
20TESTS+= src/conf_unittest src/proxy-bio_unittest
21if TARGET_LINUX
22TESTS+= src/tlsdated_unittest
23endif
24test: check
25endif
26
27ACLOCAL_AMFLAGS= -I m4
28
29# Our Debian version
30DEBIAN_VERSION := $(shell if [ -e debian/changelog ]; then cat debian/changelog|head -n1|cut -d\- -f2| head -c 1; else echo "unknown"; fi)
31
32doc_DATA+= AUTHORS
33doc_DATA+= CHANGELOG
34doc_DATA+= LICENSE
35doc_DATA+= README
36doc_DATA+= TODO
37
38EXTRA_DIST+= $(doc_DATA)
39EXTRA_DIST+= apparmor-profile
40EXTRA_DIST+= autogen.sh
41EXTRA_DIST+= tlsdated.service
42
43include src/include.am
44
45# Cleanup individual files in order to preserve uninstall/etc order
46maintainer-clean-local:
47	@rm -r -f autom4te.cache
48	@rm Makefile.in
49	@rm aclocal.m4
50	@rm config.in
51	@rm config/config.guess
52	@rm config/config.sub
53	@rm config/depcomp
54	@rm config/install-sh
55	@rm config/ltmain.sh
56	@rm config/missing
57	@rm configure
58	@rmdir config
59	@rm dbus/org.torproject.tlsdate.conf
60	@rm m4/libtool.m4
61	@rm m4/ltoptions.m4
62	@rm m4/ltsugar.m4
63	@rm m4/ltversion.m4
64	@rm m4/lt~obsolete.m4
65	@rm -f tlsdate-*.tar.gz
66	-rm src/configmake.h
67	-rm dbus/org.torproject.tlsdate.conf
68	@find ./ | $(GREP) \~$$ | xargs rm -f
69
70certdir =  @TLSDATE_CA_ROOTS@
71cert_DATA = ca-roots/tlsdate-ca-roots.conf
72EXTRA_DIST+= $(cert_DATA)
73
74confdir = @TLSDATE_CONF_DIR@
75if TARGET_LINUX
76conf_DATA = etc/tlsdated.conf
77EXTRA_DIST+= $(conf_DATA)
78endif
79
80# Our documentation
81man_MANS+= man/tlsdate.1
82man_MANS+= man/tlsdate-helper.1
83
84if TARGET_LINUX
85man_MANS+= man/tlsdated.8
86man_MANS+= man/tlsdated.conf.5
87endif
88
89EXTRA_DIST+= $(man_MANS)
90
91.PHONY: debian_orig git-tag git-push git-tag-debian deb really-clean valgrind_test
92debian_orig:
93	$(MAKE) dist
94	mv tlsdate-$(VERSION).tar.gz ../tlsdate_$(VERSION).orig.tar.gz
95
96git-tag:
97	git tag -u 0x1801A819 -s tlsdate-$(VERSION)
98
99git-tag-debian:
100	git tag -u 0x1801A819 -s tlsdate-$(VERSION)-debian-${DEBIAN_VERSION}
101
102git-push:
103	git push --tags
104	git push
105
106deb: debian_orig
107	debuild -i'.*' -rfakeroot -uc -us -d
108
109# This generates code coverage data that is useful for continuous integration
110lcov:
111#  ./configure --enable-code-coverage-checks && make && # ... run everything and then...
112	lcov --directory src -b . --capture --output-file tlsdate.lcov && genhtml -o lcov/ tlsdate.lcov
113
114valgrind_test:
115	TESTS_ENVIRONMENT="./libtool --mode=execute valgrind  --trace-children=yes --leak-check=full" ./src/tlsdate -v -V -n -H encrypted.google.com
116
117# This allows us to parse the Mozilla NSS CA trusted root list and ensures we
118# respect the trust bits as they are set - using them directly without the
119# context is dangerous. This gives us a basic set of CA roots to trust for use
120# with tlsdate without relying on any system CA list.
121# You'll need agl's extract-nss-root-certs to recreate this file:
122# https://github.com/agl/extract-nss-root-certs
123update_ca_root_data:
124	curl https://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt\?raw\=1 -o ca-roots/certdata.txt
125	go run ~/Documents/code/git/extract-nss-root-certs/convert_mozilla_certdata.go ca-roots/certdata.txt > ca-roots/tlsdate-ca-roots.conf
126	rm ca-roots/certdata.txt
127
128test_run:
129	./src/tlsdate-helper google.com 443 tlsv1 racket verbose ca-roots/tlsdate-ca-roots.conf dont-set-clock showtime no-fun holdfast none
130
131BUILT_SOURCES+= src/configmake.h
132noinst_HEADERS+= src/configmake.h
133src/configmake.h: ${top_srcdir}/Makefile.in
134	@echo "Making $@"
135	@rm -f $@-t $@
136	@{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
137	  echo '#define TLSDATE_CONFIG "$(sysconfdir)/ca-roots/"'; \
138	  echo '#define TLSDATE_CERTFILE "$(sysconfdir)/tlsdate/ca-roots/tlsdate-ca-roots.conf"'; \
139	  echo '#define TLSDATE_CONF_DIR "$(sysconfdir)/tlsdate/"'; \
140	  echo '#define TLSDATE_HELPER "$(bindir)/tlsdate-helper"'; \
141	  echo '#define TLSDATE "$(bindir)/tlsdate"'; \
142	  echo '#define TLSDATED "$(bindir)/tlsdated"'; \
143	  } | sed '/""/d' > $@-t
144	@if diff $@-t $@ >/dev/null 2>&1 ; then \
145	  rm @-t ; \
146	  else \
147	  mv $@-t $@ ; \
148	  fi
149
150