summaryrefslogtreecommitdiff
path: root/Makefile.am
blob: 977b23d17bedbe9a650fca82b9918797fd768d6f (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
EXTRA_DIST = contrib

lib_LTLIBRARIES = libamounts.la libledger.la

libamounts_la_CPPFLAGS = -I$(srcdir)/src
libamounts_la_SOURCES  = \
	src/utils.cc       \
	src/times.cc       \
	src/mask.cc        \
	src/binary.cc      \
			   \
	src/amount.cc      \
	src/commodity.cc   \
	src/balance.cc     \
	src/value.cc       \
			   \
	src/token.cc       \
	src/parser.cc      \
	src/op.cc          \
	src/expr.cc        \
	src/scope.cc       \
	src/format.cc      \
	src/option.cc

if HAVE_EXPAT
libamounts_la_CPPFLAGS += -DHAVE_EXPAT=1
else
if HAVE_XMLPARSE
libamounts_la_CPPFLAGS += -DHAVE_XMLPARSE=1
endif
endif
if HAVE_LIBOFX
libamounts_la_CPPFLAGS += -DHAVE_LIBOFX=1
endif
if HAVE_BOOST_PYTHON
endif
if DEBUG
libamounts_la_CPPFLAGS += -DDEBUG_MODE
endif

libledger_la_CPPFLAGS = $(libamounts_la_CPPFLAGS)
libledger_la_LDFLAGS  = -release 3.0.0
libledger_la_SOURCES  = \
	src/journal.cc     \
	src/entry.cc       \
	src/xact.cc        \
	src/account.cc     \
	src/iterators.cc   \
	src/compare.cc     \
			   \
	src/textual.cc     \
	src/cache.cc       \
	src/emacs.cc       \
	src/qif.cc	   \
	src/xml.cc	   \
	src/csv.cc         \
			   \
	src/session.cc     \
	src/report.cc      \
	src/filters.cc     \
	src/output.cc      \
	src/help.cc        \
			   \
	src/derive.cc      \
	src/reconcile.cc   \
	src/quotes.cc

if HAVE_BOOST_PYTHON
Python_ledger_SRC = \
	python/pyledger.cc	   \
	python/pyinterp.cc	   \
	python/py_amount.cc	   \
	python/py_commodity.cc \
	python/py_times.cc	   \
	python/py_utils.cc

libledger_la_SOURCES += $(Python_ledger_SRC)
libledger_la_CPPFLAGS += -DUSE_BOOST_PYTHON=1 -I$(srcdir)/python
endif

if HAVE_EXPAT
libledger_la_SOURCES += src/gnucash.cc
else
if HAVE_XMLPARSE
libledger_la_SOURCES += src/gnucash.cc
endif
endif
if HAVE_LIBOFX
libledger_la_SOURCES += src/ofx.cc
endif

pkginclude_HEADERS =     \
	acconf.h         \
	src/system.hh    \
	src/fdstream.h   \
	src/utils.h	 \
	src/flags.h      \
	src/hooks.h      \
	src/pushvar.h    \
	src/error.h      \
	src/times.h	 \
	src/mask.h       \
	src/binary.h     \
			 \
	src/amount.h     \
	src/commodity.h  \
	src/balance.h    \
	src/balpair.h    \
	src/value.h      \
			 \
	src/token.h      \
	src/parser.h     \
	src/op.h         \
	src/expr.h       \
	src/scope.h      \
	src/predicate.h  \
	src/format.h     \
	src/option.h     \
			 \
	src/journal.h    \
	src/entry.h      \
	src/xact.h       \
	src/account.h    \
	src/iterators.h  \
	src/compare.h    \
			 \
	src/textual.h    \
	src/cache.h      \
	src/emacs.h      \
	src/qif.h	 \
	src/xml.h	 \
	src/csv.h        \
	src/gnucash.h    \
	src/ofx.h	 \
			 \
	src/session.h    \
	src/report.h     \
	src/handler.h    \
	src/filters.h    \
	src/output.h     \
	src/help.h       \
			 \
	src/derive.h     \
	src/reconcile.h  \
	src/quotes.h     \
			 \
	src/ledger.h

CLEANFILES =

if USE_PCH
nodist_libledger_la_SOURCES = src/system.hh.gch

BUILT_SOURCES = src/system.hh.gch
CLEANFILES    += src/system.hh.gch

$(srcdir)/src/system.hh.gch: $(srcdir)/src/system.hh $(top_builddir)/acconf.h
	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
	    $(libledger_la_CPPFLAGS) \
	    $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) \
	    -g -o $@ $(srcdir)/src/system.hh
endif

######################################################################

bin_PROGRAMS	= ledger

ledger_CPPFLAGS = $(libledger_la_CPPFLAGS)
ledger_SOURCES	= src/main.cc
ledger_LDADD	= $(LIBOBJS) libamounts.la libledger.la
ledger_LDFLAGS	= -static

info_TEXINFOS   = doc/ledger.texi

dist_lisp_LISP  = lisp/ledger.el lisp/timeclock.el

DISTCLEANFILES  = ledger.elc timeclock.elc

######################################################################

if HAVE_BOOST_PYTHON

noinst_PROGRAMS = ledger.so

CLEANFILES += ledger.so

clean-local:
	rm -fr build

ledger_so_SOURCES      = $(Python_ledger_SRC)
ledger_so_DEPENDENCIES = $(lib_LTLIBRARIES)

PYLIBS  = amounts ledger gmp \
	  boost_date_time$(BOOST_SUFFIX)  \
          boost_filesystem$(BOOST_SUFFIX) \
          boost_regex$(BOOST_SUFFIX)	  \
          boost_python$(BOOST_SUFFIX)

if HAVE_LIBOFX
PYLIBS += ofx
endif

ledger.so: $(ledger_so_SOURCES) $(ledger_so_DEPENDENCIES)
	CFLAGS="$(CPPFLAGS) -I$(srcdir) $(libledger_la_CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)" \
	LDFLAGS="$(LDFLAGS) -L$(top_builddir) -L$(top_builddir)/.libs" \
	ARCHFLAGS="$(ARCHFLAGS)" PYLIBS="$(PYLIBS)" SRCDIR="$(srcdir)" \
	    python $(srcdir)/python/setup.py build --build-lib=$(top_builddir)

install-exec-hook:
	CFLAGS="$(CPPFLAGS) -I$(srcdir) $(libledger_la_CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)" \
	LDFLAGS="$(LDFLAGS) -L$(top_builddir) -L$(top_builddir)/.libs" \
	ARCHFLAGS="$(ARCHFLAGS)" PYLIBS="$(PYLIBS)" SRCDIR="$(srcdir)" \
	    python $(srcdir)/python/setup.py install --prefix=$(prefix)

endif

######################################################################

TESTS = RegressionTests
XFAIL_TESTS = RegressionTests	# jww (2008-08-07): for now

if HAVE_CPPUNIT
TESTS += UnitTests
endif

if HAVE_BOOST_PYTHON
TESTS += PyUnitTests
endif

check_PROGRAMS = $(TESTS)

UnitTests_SOURCES =		 \
	test/UnitTests.cc	 \
	test/UnitTests.h	 \
	test/unit/t_utils.cc	 \
	test/unit/t_utils.h	 \
	test/unit/t_times.cc	 \
	test/unit/t_times.h	 \
	test/unit/t_commodity.cc \
	test/unit/t_commodity.h	 \
	test/unit/t_amount.cc	 \
	test/unit/t_amount.h	 \
	test/unit/t_balance.cc	 \
	test/unit/t_balance.h	 \
	test/unit/t_expr.cc	 \
	test/unit/t_expr.h

UnitTests_CPPFLAGS = -I$(srcdir)/test $(libledger_la_CPPFLAGS)
UnitTests_LDFLAGS  = $(LIBADD_DL)
UnitTests_LDADD    = $(lib_LTLIBRARIES) -lcppunit

EXTRA_DIST += test/python

PyUnitTests_SOURCES = test/__init__.py test/PyUnitTests.py

ESC_srcdir=`echo "$(srcdir)" | sed 's/\//\\\\\//g'`
ESC_builddir=`echo "$(top_builddir)" | sed 's/\//\\\\\//g'`
ESC_distdir=`echo "$(distdir)" | sed 's/\//\\\\\//g'`

# jww (2007-05-10): This rule will not be triggered on systems that
# define an EXEEXT.
PyUnitTests: $(srcdir)/test/PyUnitTests.py
	cat $(srcdir)/test/PyUnitTests.py \
	    | sed "s/%srcdir%/$(ESC_srcdir)/g" \
	    | sed "s/%builddir%/$(ESC_builddir)/g" > $@
	chmod 755 $@

RegressionTests_SOURCES = test/regress.py

EXTRA_DIST += test/regress

RegressionTests: $(srcdir)/test/regress.py
	echo "python $(srcdir)/test/regress.py $(top_builddir)/ledger$(EXEEXT) $(srcdir)/test/regress" > $@
	chmod 755 $@

if HAVE_VALGRIND
VALGRIND = valgrind
else
VALGRIND =
endif

fullcheck: check
	MallocGuardEdges=1	 \
	MallocScribble=1	 \
	MallocPreScribble=1	 \
	MallocCheckHeapStart=100 \
	MallocCheckHeapEach=100	 \
	DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib \
	$(VALGRIND) $(top_builddir)/UnitTests$(EXEEXT) --verify

######################################################################

EXTRA_DIST += doc/LICENSE doc/NEWS doc/README
EXTRA_DIST += doc/Doxyfile doc/ledger.pdf doc/refman.pdf

DISTCLEANFILES += doc/ledger.info doc/ledger.pdf \
		  Doxyfile.gen doc/Doxyfile.bak doc/refman.pdf

dist-hook:
	find $(distdir) -name .DS_Store -delete
	find $(distdir) -name .localized -delete
	find $(distdir)/doc -name .dirstamp -delete
	rm -fr $(distdir)/doc/latex \
	       $(distdir)/doc/Doxyfile.bak \
	       $(distdir)/doc/Doxyfile.gen
	cp -pR $(srcdir)/doc/html $(distdir)/doc

distclean-local:
	rm -fr doc/html doc/latex doc/refman.pdf

$(top_builddir)/Doxyfile.gen: $(srcdir)/doc/Doxyfile
	cat $(srcdir)/doc/Doxyfile \
	    | sed "s/%srcdir%/$(ESC_srcdir)/g" \
	    | sed "s/%builddir%/$(ESC_builddir)/g" > $@

$(top_builddir)/doc/html/index.html: $(top_builddir)/Doxyfile.gen
	doxygen $(top_builddir)/Doxyfile.gen

# The intention with the following rules is that all of the Doxygen
# documentation (both HTML and PDF) is built locally before distcheck is
# run, since it's quite possible that the user will not have a complete
# TeX + Doxygen + dot environment on their own system.

$(top_builddir)/doc/refman.pdf: $(top_builddir)/doc/html/index.html
	(cd $(top_builddir)/doc/latex && make)
	cp $(top_builddir)/doc/latex/refman.pdf $@

docs: pdf $(top_builddir)/doc/refman.pdf

######################################################################

copy-sources:
	-mkdir /tmp/ledger
	rsync -av --delete $(srcdir)/.git/ /tmp/ledger/.git/
	(cd /tmp/ledger; git reset --hard HEAD; git clean -x -d -f)

release: copy-sources
	(cd /tmp/ledger; ./acprep --release --build -j3)

release-distcheck: copy-sources
	(cd /tmp/ledger; ./acprep --release --build -j3 distcheck)

# Makefile.am ends here