1## Process this file with automake to produce Makefile.in
2
3# Make sure that when we re-make ./configure, we get the macros we need
4ACLOCAL_AMFLAGS = -I m4
5
6# This is so we can #include <sparsehash/foo>
7AM_CPPFLAGS = -I$(top_srcdir)/src
8
9# These are good warnings to turn on by default
10if GCC
11AM_CXXFLAGS = -Wall -W -Wwrite-strings -Woverloaded-virtual -Wshadow
12endif
13
14docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
15## This is for HTML and other documentation you want to install.
16## Add your documentation files (in doc/) in addition to these boilerplate
17## Also add a TODO file if you have one
18dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README README_windows.txt \
19   TODO \
20   doc/dense_hash_map.html			\
21   doc/dense_hash_set.html			\
22   doc/sparse_hash_map.html			\
23   doc/sparse_hash_set.html			\
24   doc/sparsetable.html                     	\
25   doc/implementation.html			\
26   doc/performance.html                         \
27   doc/index.html                               \
28   doc/designstyle.css
29
30## The libraries (.so's) you want to install
31lib_LTLIBRARIES =
32## The location of the windows project file for each binary we make
33WINDOWS_PROJECTS = sparsehash.sln
34
35## unittests you want to run when people type 'make check'.
36## TESTS is for binary unittests, check_SCRIPTS for script-based unittests.
37## TESTS_ENVIRONMENT sets environment variables for when you run unittest,
38## but it only seems to take effect for *binary* unittests (argh!)
39TESTS =
40check_SCRIPTS =
41TESTS_ENVIRONMENT =
42
43## This should always include $(TESTS), but may also include other
44## binaries that you compile but don't want automatically installed.
45noinst_PROGRAMS = $(TESTS) time_hash_map
46WINDOWS_PROJECTS += vsprojects/time_hash_map/time_hash_map.vcproj
47
48
49## vvvv RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
50
51# All our .h files need to read the config information in config.h.  The
52# autoheader config.h has too much info, including PACKAGENAME, that
53# might conflict with other config.h's an application might #include.
54# Thus, we create a "minimal" config.h, called sparseconfig.h, that
55# includes only the #defines we really need, and that are unlikely to
56# change from system to system.  NOTE: The awk command is equivalent to
57#  fgrep -B2 -f$(top_builddir)/src/config.h.include $(top_builddir)/src/config.h
58#  | fgrep -vx -e -- > _sparsehash_config
59# For correctness, it depends on the fact config.h.include does not have
60# any lines starting with #.
61src/sparsehash/internal/sparseconfig.h: $(top_builddir)/src/config.h \
62                                        $(top_srcdir)/src/config.h.include
63	[ -d $(@D) ] || mkdir -p $(@D)
64	echo "/*" > $(@D)/_sparsehash_config
65	echo " * NOTE: This file is for internal use only." >> $(@D)/_sparsehash_config
66	echo " *       Do not use these #defines in your own program!" >> $(@D)/_sparsehash_config
67	echo " */" >> $(@D)/_sparsehash_config
68	$(AWK) '{prevline=currline; currline=$$0;} \
69	        /^#/ {in_second_file = 1;} \
70	        !in_second_file {if (currline !~ /^ *$$/) {inc[currline]=0}}; \
71	       	in_second_file { for (i in inc) { \
72	       	                   if (index(currline, i) != 0) { \
73	       	                      print "\n"prevline"\n"currline; \
74	       	                      delete inc[i]; \
75	       	                   } \
76	       	                 } }' \
77	$(top_srcdir)/src/config.h.include $(top_builddir)/src/config.h \
78	>> $(@D)/_sparsehash_config
79	mv -f $(@D)/_sparsehash_config $@
80# This is how we tell automake about auto-generated .h files
81BUILT_SOURCES = src/sparsehash/internal/sparseconfig.h
82CLEANFILES = src/sparsehash/internal/sparseconfig.h
83
84sparsehashincludedir = $(includedir)/sparsehash
85## The .h files you want to install (that is, .h files that people
86## who install this package can include in their own applications.)
87sparsehashinclude_HEADERS =			\
88   src/sparsehash/dense_hash_map		\
89   src/sparsehash/dense_hash_set		\
90   src/sparsehash/sparse_hash_map		\
91   src/sparsehash/sparse_hash_set		\
92   src/sparsehash/sparsetable			\
93   src/sparsehash/template_util.h		\
94   src/sparsehash/type_traits.h
95
96internalincludedir = $(sparsehashincludedir)/internal
97internalinclude_HEADERS =					\
98   src/sparsehash/internal/densehashtable.h			\
99   src/sparsehash/internal/sparsehashtable.h			\
100   src/sparsehash/internal/hashtable-common.h			\
101   src/sparsehash/internal/libc_allocator_with_realloc.h
102nodist_internalinclude_HEADERS = src/sparsehash/internal/sparseconfig.h
103
104# This is for backwards compatibility only.
105googleincludedir = $(includedir)/google
106googleinclude_HEADERS =					\
107   src/google/dense_hash_map				\
108   src/google/dense_hash_set				\
109   src/google/sparse_hash_map				\
110   src/google/sparse_hash_set				\
111   src/google/sparsetable				\
112   src/google/template_util.h				\
113   src/google/type_traits.h
114
115googleinternalincludedir = $(includedir)/google/sparsehash
116googleinternalinclude_HEADERS=		\
117   src/google/sparsehash/densehashtable.h		\
118   src/google/sparsehash/sparsehashtable.h		\
119   src/google/sparsehash/hashtable-common.h		\
120   src/google/sparsehash/libc_allocator_with_realloc.h
121
122TESTS += template_util_unittest
123# TODO(csilvers): Update windows projects for template_util_unittest.
124# WINDOWS_PROJECTS += vsprojects/template_util_unittest/template_util_unittest.vcproj
125template_util_unittest_SOURCES =			\
126   src/template_util_unittest.cc		\
127   src/sparsehash/template_util.h
128nodist_template_util_unittest_SOURCES = $(nodist_internalinclude_HEADERS)
129
130TESTS += type_traits_unittest
131WINDOWS_PROJECTS += vsprojects/type_traits_unittest/type_traits_unittest.vcproj
132type_traits_unittest_SOURCES =			\
133   src/type_traits_unittest.cc			\
134   $(internalinclude_HEADERS)			\
135   src/sparsehash/type_traits.h
136nodist_type_traits_unittest_SOURCES = $(nodist_internalinclude_HEADERS)
137
138TESTS += libc_allocator_with_realloc_test
139WINDOWS_PROJECTS += vsprojects/libc_allocator_with_realloc_test/libc_allocator_with_realloc_test.vcproj
140libc_allocator_with_realloc_test_SOURCES =	\
141   src/libc_allocator_with_realloc_test.cc	\
142   $(internalinclude_HEADERS)			\
143   src/sparsehash/internal/libc_allocator_with_realloc.h
144
145
146TESTS += sparsetable_unittest
147WINDOWS_PROJECTS += vsprojects/sparsetable_unittest/sparsetable_unittest.vcproj
148sparsetable_unittest_SOURCES =			\
149   src/sparsetable_unittest.cc			\
150   $(internalinclude_HEADERS)			\
151   src/sparsehash/sparsetable
152nodist_sparsetable_unittest_SOURCES = $(nodist_internalinclude_HEADERS)
153
154TESTS += hashtable_test
155WINDOWS_PROJECTS += vsprojects/hashtable_test/hashtable_test.vcproj
156hashtable_test_SOURCES =			\
157   src/hashtable_test.cc			\
158   src/hash_test_interface.h			\
159   src/testutil.h				\
160   $(sparsehashinclude_HEADERS)			\
161   $(internalinclude_HEADERS)
162nodist_hashtable_test_SOURCES = $(nodist_internalinclude_HEADERS)
163
164TESTS += simple_test
165WINDOWS_PROJECTS += vsprojects/simple_test/simple_test.vcproj
166simple_test_SOURCES =	   		        \
167   src/simple_test.cc				\
168   $(internalinclude_HEADERS)
169nodist_simple_test_SOURCES = $(nodist_internalinclude_HEADERS)
170
171TESTS += simple_compat_test
172simple_compat_test_SOURCES =   		        \
173   src/simple_compat_test.cc			\
174   $(internalinclude_HEADERS)                   \
175   $(googleinclude_HEADERS)	\
176   $(googleinternalinclude_HEADERS)
177nodist_simple_compat_test_SOURCES = $(nodist_internalinclude_HEADERS)
178
179time_hash_map_SOURCES =				\
180   src/time_hash_map.cc				\
181   $(internalinclude_HEADERS)			\
182   $(sparsehashinclude_HEADERS)
183nodist_time_hash_map_SOURCES = $(nodist_internalinclude_HEADERS)
184
185# If tcmalloc is installed, use it with time_hash_map; it gives us
186# heap-usage statistics for the hash_map routines, which is very nice
187time_hash_map_CXXFLAGS = @tcmalloc_flags@ $(AM_CXXFLAGS)
188time_hash_map_LDFLAGS = @tcmalloc_flags@
189time_hash_map_LDADD = @tcmalloc_libs@
190
191## ^^^^ END OF RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
192
193
194rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
195	@cd packages && ./rpm.sh ${PACKAGE} ${VERSION}
196
197deb: dist-gzip packages/deb.sh packages/deb/*
198	@cd packages && ./deb.sh ${PACKAGE} ${VERSION}
199
200# http://linux.die.net/man/1/pkg-config, http://pkg-config.freedesktop.org/wiki
201pkgconfigdir = $(libdir)/pkgconfig
202pkgconfig_DATA = lib${PACKAGE}.pc
203CLEANFILES += $(pkgconfig_DATA)
204
205# I get the description and URL lines from the rpm spec. I use sed to
206# try to rewrite exec_prefix, libdir, and includedir in terms of
207# prefix, if possible.
208lib${PACKAGE}.pc: Makefile packages/rpm/rpm.spec
209	echo 'prefix=$(prefix)' > "$@".tmp
210	echo 'exec_prefix='`echo '$(exec_prefix)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
211	echo 'libdir='`echo '$(libdir)' | sed 's@^$(exec_prefix)@$${exec_prefix}@'` >> "$@".tmp
212	echo 'includedir='`echo '$(includedir)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
213	echo '' >> "$@".tmp
214	echo 'Name: $(PACKAGE)' >> "$@".tmp
215	echo 'Version: $(VERSION)' >> "$@".tmp
216	-grep '^Summary:' $(top_srcdir)/packages/rpm/rpm.spec | sed s/^Summary:/Description:/ | head -n1 >> "$@".tmp
217	-grep '^URL: ' $(top_srcdir)/packages/rpm/rpm.spec >> "$@".tmp
218	echo 'Requires:' >> "$@".tmp
219	echo 'Libs:' >> "$@".tmp
220	echo 'Cflags: -I$${includedir}' >> "$@".tmp
221	mv -f "$@".tmp "$@"
222
223# Windows wants write permission to .vcproj files and maybe even sln files.
224dist-hook:
225	test -e "$(distdir)/vsprojects" \
226	   && chmod -R u+w $(distdir)/*.sln $(distdir)/vsprojects/
227
228EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
229             src/config.h.include src/windows $(WINDOWS_PROJECTS) experimental
230