summaryrefslogtreecommitdiff
path: root/Makefile
blob: 0ae93fc2e479dddf8f19f0eb7b02f60b55bf6007 (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
CODE   = account.cc  \
	 amount.cc   \
	 autoxact.cc \
	 balance.cc  \
	 binary.cc   \
	 datetime.cc \
	 debug.cc    \
	 error.cc    \
	 format.cc   \
	 ledger.cc   \
	 textual.cc  \
	 valexpr.cc  \
	 walk.cc

OBJS   = $(patsubst %.cc,%.o,$(CODE))

#CXX    = cc
CXX    = g++

CFLAGS = -Wall -ansi -pedantic
#DFLAGS = -O3 -fomit-frame-pointer -DRELEASE_LEVEL=0
DFLAGS = -g -DRELEASE_LEVEL=4
#DFLAGS = -g -DRELEASE_LEVEL=2 -pg

INCS   = -I/sw/include \
	 -I/usr/include/gcc/darwin/3.3/c++ \
	 -I/usr/include/gcc/darwin/3.3/c++/ppc-darwin
LIBS   = -L/sw/lib -lgmpxx -lgmp -lpcre

ifdef GNUCASH
CODE   := $(CODE)   gnucash.cc
OBJS   := $(OBJS)   gnucash.o
CFLAGS := $(CFLAGS) -DREAD_GNUCASH=1
INCS   := $(INCS)   -I/usr/include/httpd/xml
LIBS   := $(LIBS)   -L/sw/lib -lxmlparse
endif

all: make.deps ledger

docs: ledger.info ledger.pdf

install:
	make clean
	make DFLAGS="-O3 -fomit-frame-pointer"
	cp ledger $(HOME)/bin
	strip $(HOME)/bin/ledger

libledger.a: $(OBJS)
	ar rv $@ $?
	ranlib $@

ledger: libledger.a main.o
	$(CXX) $(CFLAGS) $(INCS) $(DFLAGS) -o $@ main.o -L. -lledger $(LIBS)

valexpr: libledger.a valexpr.cc
	$(CXX) $(CFLAGS) $(INCS) $(DFLAGS) -DTEST -o $@ valexpr.cc \
		-L. -lledger $(LIBS)

ledger.info: ledger.texi
	makeinfo $<

ledger.pdf: ledger.texi
	texi2pdf $<

%.o: %.cc
	$(CXX) $(CFLAGS) $(INCS) $(DFLAGS) -c -o $@ $<

clean:
	rm -f ledger valexpr libledger.a *.o *.elc *~ .\#*
	rm -f *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr
	rm -f .gdb_history gmon.out out

distclean fullclean: clean
	rm -f *.texi *.info *.html *.pdf *.elc make.deps TAGS

rebuild: clean deps all

deps: make.deps

make.deps: Makefile
	cc -M $(INCS) $(CODE) main.cc > $@

include make.deps

# These next rules are for my own use.

README.html: README
	(cd $(HOME)/src/muse && \
	 ./publish --html $(shell pwd)/README && \
	 mv README.html $(shell pwd))

ledger.texi: README
	(cd $(HOME)/src/muse && \
	 ./publish --texi $(shell pwd)/README && \
	 cat README.texi | sed 's/README\.info/ledger.info/g' \
	   > $(shell pwd)/ledger.texi && \
	 rm README.texi)

VERSION = $(shell scripts/version)

dist:
	rm -fr /tmp/ledger-$(VERSION)
	rsync -av --exclude=".*" --exclude="TAGS" --exclude="version" \
	  --exclude="_darcs/" --exclude="ledger.dat" \
	  $(shell pwd)/ /tmp/ledger-$(VERSION)
	(cd /tmp/ledger-$(VERSION) && \
	 make fullclean && \
	 make docs README.html && \
	 make clean && rm make.deps && \
	 cat Makefile | sed 's/\/sw\//\/usr\/local\//g' > t && \
	 mv t Makefile && \
	 cat Makefile | sed 's/ -I\/usr\/include\/gcc.*//' > t && \
	 mv t Makefile && \
	 perl -ne 'print if 1 .. /^include make.deps/;' Makefile > t && \
	 mv t Makefile && \
	 cd /tmp && \
	 tar cvzf $(HOME)/Sites/ledger/ledger-$(VERSION).tar.gz \
		  ledger-$(VERSION))