test binaries are in the builddir, not the top_srcdir
[platform/upstream/glog.git] / Makefile.am
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
4 ACLOCAL_AMFLAGS = -I m4
5
6 # This is so we can #include <glog/foo>
7 AM_CPPFLAGS = -I$(top_srcdir)/src
8
9 # This is mostly based on configure options
10 AM_CXXFLAGS =
11
12 # These are good warnings to turn on by default
13 if GCC
14   AM_CXXFLAGS += -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
15 endif
16
17 # These are x86-specific, having to do with frame-pointers
18 if X86_64
19 if ENABLE_FRAME_POINTERS
20   AM_CXXFLAGS += -fno-omit-frame-pointer
21 else
22   # TODO(csilvers): check if -fomit-frame-pointer might be in $(CXXFLAGS),
23   #                 before setting this.
24   AM_CXXFLAGS += -DNO_FRAME_POINTER
25 endif
26 endif
27
28 glogincludedir = $(includedir)/glog
29 ## The .h files you want to install (that is, .h files that people
30 ## who install this package can include in their own applications.)
31 ## We have to include both the .h and .h.in forms.  The latter we
32 ## put in noinst_HEADERS.
33 gloginclude_HEADERS = src/glog/log_severity.h
34 nodist_gloginclude_HEADERS = src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h
35 noinst_HEADERS = src/glog/logging.h.in src/glog/raw_logging.h.in src/glog/vlog_is_on.h.in src/glog/stl_logging.h.in
36
37 docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
38 ## This is for HTML and other documentation you want to install.
39 ## Add your documentation files (in doc/) in addition to these
40 ## top-level boilerplate files.  Also add a TODO file if you have one.
41 dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README README.windows \
42                 doc/designstyle.css doc/glog.html
43
44 ## The libraries (.so's) you want to install
45 lib_LTLIBRARIES =
46
47 # The libraries libglog depends on.
48 COMMON_LIBS = $(PTHREAD_LIBS) $(GFLAGS_LIBS) $(UNWIND_LIBS)
49 # Compile switches for our unittest.
50 TEST_CFLAGS = $(GTEST_CFLAGS) $(GMOCK_CFLAGS) $(GFLAGS_CFLAGS) $(AM_CXXFLAGS)
51 # Libraries for our unittest.
52 TEST_LIBS = $(GTEST_LIBS) $(GMOCK_LIBS) $(GFLAGS_LIBS)
53
54 ## unittests you want to run when people type 'make check'.
55 ## TESTS is for binary unittests, check_SCRIPTS for script-based unittests.
56 ## TESTS_ENVIRONMENT sets environment variables for when you run unittest,
57 ## but it only seems to take effect for *binary* unittests (argh!)
58 TESTS =
59 TESTS_ENVIRONMENT =
60 check_SCRIPTS =
61 # Every time you add a unittest to check_SCRIPTS, add it here too
62 noinst_SCRIPTS =
63 # Binaries used for script-based unittests.
64 TEST_BINARIES =
65
66 TESTS += logging_unittest
67 logging_unittest_SOURCES = $(gloginclude_HEADERS) \
68                            src/logging_unittest.cc \
69                            src/config_for_unittests.h \
70                            src/mock-log.h
71 nodist_logging_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
72 logging_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
73 logging_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
74 logging_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
75
76 check_SCRIPTS += logging_striplog_test_sh
77 noinst_SCRIPTS += src/logging_striplog_test.sh
78 logging_striplog_test_sh: logging_striptest0 logging_striptest2 logging_striptest10
79         $(top_srcdir)/src/logging_striplog_test.sh
80
81 check_SCRIPTS += demangle_unittest_sh
82 noinst_SCRIPTS += src/demangle_unittest.sh
83 demangle_unittest_sh: demangle_unittest
84         $(builddir)/demangle_unittest  # force to create lt-demangle_unittest
85         $(top_srcdir)/src/demangle_unittest.sh
86
87 check_SCRIPTS += signalhandler_unittest_sh
88 noinst_SCRIPTS += src/signalhandler_unittest.sh
89 signalhandler_unittest_sh: signalhandler_unittest
90         $(builddir)/signalhandler_unittest  # force to create lt-signalhandler_unittest
91         $(top_srcdir)/src/signalhandler_unittest.sh
92
93 TEST_BINARIES += logging_striptest0
94 logging_striptest0_SOURCES = $(gloginclude_HEADERS) \
95                              src/logging_striptest_main.cc
96 nodist_logging_striptest0_SOURCES = $(nodist_gloginclude_HEADERS)
97 logging_striptest0_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
98 logging_striptest0_LDFLAGS = $(PTHREAD_CFLAGS)
99 logging_striptest0_LDADD = libglog.la $(COMMON_LIBS)
100
101 TEST_BINARIES += logging_striptest2
102 logging_striptest2_SOURCES = $(gloginclude_HEADERS) \
103                              src/logging_striptest2.cc
104 nodist_logging_striptest2_SOURCES = $(nodist_gloginclude_HEADERS)
105 logging_striptest2_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
106 logging_striptest2_LDFLAGS = $(PTHREAD_CFLAGS)
107 logging_striptest2_LDADD = libglog.la $(COMMON_LIBS)
108
109 TEST_BINARIES += logging_striptest10
110 logging_striptest10_SOURCES = $(gloginclude_HEADERS) \
111                               src/logging_striptest10.cc
112 nodist_logging_striptest10_SOURCES = $(nodist_gloginclude_HEADERS)
113 logging_striptest10_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
114 logging_striptest10_LDFLAGS = $(PTHREAD_CFLAGS)
115 logging_striptest10_LDADD = libglog.la $(COMMON_LIBS)
116
117 TESTS += demangle_unittest
118 demangle_unittest_SOURCES = $(gloginclude_HEADERS) \
119                             src/demangle_unittest.cc
120 nodist_demangle_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
121 demangle_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
122 demangle_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
123 demangle_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
124
125 TESTS += stacktrace_unittest
126 stacktrace_unittest_SOURCES = $(gloginclude_HEADERS) \
127                               src/stacktrace_unittest.cc
128 nodist_stacktrace_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
129 stacktrace_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
130 stacktrace_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
131 stacktrace_unittest_LDADD = libglog.la $(COMMON_LIBS)
132
133 TESTS += symbolize_unittest
134 symbolize_unittest_SOURCES = $(gloginclude_HEADERS) \
135                               src/symbolize_unittest.cc
136 nodist_symbolize_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
137 symbolize_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
138 symbolize_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
139 symbolize_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
140
141 TESTS += stl_logging_unittest
142 stl_logging_unittest_SOURCES = $(gloginclude_HEADERS) \
143                                src/stl_logging_unittest.cc
144 nodist_stl_logging_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
145 stl_logging_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
146 stl_logging_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
147 stl_logging_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
148
149 TEST_BINARIES += signalhandler_unittest
150 signalhandler_unittest_SOURCES = $(gloginclude_HEADERS) \
151                                src/signalhandler_unittest.cc
152 nodist_signalhandler_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
153 signalhandler_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
154 signalhandler_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
155 signalhandler_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
156
157 TESTS += utilities_unittest
158 utilities_unittest_SOURCES = $(gloginclude_HEADERS) \
159                              src/utilities_unittest.cc
160 nodist_utilities_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
161 utilities_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
162 utilities_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
163 utilities_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
164
165 if HAVE_GMOCK
166 TESTS += mock_log_test
167 mock_log_test_SOURCES = $(gloginclude_HEADERS) \
168                         src/mock-log_test.cc
169 nodist_mock_log_test_SOURCES = $(nodist_gloginclude_HEADERS)
170 mock_log_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
171 mock_log_test_LDFLAGS = $(PTHREAD_CFLAGS)
172 mock_log_test_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
173 endif
174
175 ## vvvv RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
176
177 lib_LTLIBRARIES += libglog.la
178 libglog_la_SOURCES = $(gloginclude_HEADERS) \
179                        src/logging.cc src/raw_logging.cc src/vlog_is_on.cc \
180                        src/utilities.cc src/utilities.h \
181                        src/demangle.cc src/demangle.h \
182                        src/stacktrace.h \
183                        src/stacktrace_generic-inl.h \
184                        src/stacktrace_libunwind-inl.h \
185                        src/stacktrace_powerpc-inl.h \
186                        src/stacktrace_x86-inl.h \
187                        src/stacktrace_x86_64-inl.h \
188                        src/symbolize.cc src/symbolize.h \
189                        src/signalhandler.cc \
190                        src/base/mutex.h src/base/googleinit.h \
191                        src/base/commandlineflags.h src/googletest.h
192 nodist_libglog_la_SOURCES = $(nodist_gloginclude_HEADERS)
193
194 libglog_la_CXXFLAGS = $(PTRHEAD_CFLAGS) $(GFLAGS_CFLAGS) $(AM_CXXFLAGS) -DNDEBUG
195 libglog_la_LDFLAGS = $(PTRHEAD_CFLAGS) $(GFLAGS_LDFLAGS)
196 libglog_la_LIBADD = $(COMMON_LIBS)
197
198 ## The location of the windows project file for each binary we make
199 WINDOWS_PROJECTS = google-glog.sln
200 WINDOWS_PROJECTS += vsprojects/libglog/libglog.vcproj
201 WINDOWS_PROJECTS += vsprojects/logging_unittest/logging_unittest.vcproj
202 WINDOWS_PROJECTS += vsprojects/libglog_static/libglog_static.vcproj
203 WINDOWS_PROJECTS += vsprojects/logging_unittest_static/logging_unittest_static.vcproj
204
205 ## ^^^^ END OF RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
206
207
208 ## This should always include $(TESTS), but may also include other
209 ## binaries that you compile but don't want automatically installed.
210 noinst_PROGRAMS = $(TESTS) $(TEST_BINARIES)
211
212 rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
213         @cd packages && ./rpm.sh ${PACKAGE} ${VERSION}
214
215 deb: dist-gzip packages/deb.sh packages/deb/*
216         @cd packages && ./deb.sh ${PACKAGE} ${VERSION}
217
218 # Windows wants write permission to .vcproj files and maybe even sln files.
219 dist-hook:
220         test -e "$(distdir)/vsprojects" \
221            && chmod -R u+w $(distdir)/*.sln $(distdir)/vsprojects/
222
223 libtool: $(LIBTOOL_DEPS)
224         $(SHELL) ./config.status --recheck
225
226 EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
227         $(SCRIPTS) src/logging_unittest.err src/demangle_unittest.txt \
228         src/windows/config.h src/windows/port.h src/windows/port.cc \
229         src/windows/preprocess.sh \
230         src/windows/glog/log_severity.h src/windows/glog/logging.h \
231         src/windows/glog/raw_logging.h src/windows/glog/stl_logging.h \
232         src/windows/glog/vlog_is_on.h \
233         $(WINDOWS_PROJECTS)
234
235 # Add pkgconfig file
236 pkgconfigdir = $(libdir)/pkgconfig
237 pkgconfig_DATA = libglog.pc