1# Useful options you might want to put on the make command line:
2#
3#  - `SLANG=yes' to build against libslang instead of libncurses
4#    (libncurses is better and more reliable, but libslang might be
5#    all you have on a particular platform if you're unlucky).
6#
7#  - `XFLAGS=-DNO_LARGE_FILES' to leave out the 64-bit file access
8#    support (restricts Tweak to editing files under 2Gb, but
9#    should cause it to compile successfully on platforms without
10#    fseeko and ftello and/or long long support).
11#
12#  - `VERSION=X.XX' (for whatever X.XX you like) to cause the `make
13#    release' target to build a release tarball called
14#    `tweak-X.XX.tar.gz' which unpacks into a directory
15#    `tweak-X.XX'. Note that you also need to modify the version
16#    number in tweak.h, or else the resulting binary won't match
17#    the version number on the archive.
18
19CC ?= gcc
20CFLAGS ?= -g
21CFLAGS += -c -Wall $(XFLAGS)
22LINK ?= ${CC}
23LFLAGS ?=
24LIBS ?=
25
26PREFIX?=/usr/local
27BINDIR?=$(PREFIX)/bin
28MANDIR?=$(PREFIX)/man/man1
29
30TWEAK := main.o keytab.o actions.o search.o rcfile.o buffer.o btree.o
31
32ifeq ($(SLANG),yes)
33# INCLUDE += -I/path/to/slang/include
34# LIBS += -L/path/to/slang/lib
35LIBS += -lslang
36TWEAK += slang.o
37else
38LIBS += -lncurses
39TWEAK += curses.o
40endif
41
42.c.o:
43	$(CC) $(CFLAGS) $*.c
44
45all: tweak tweak.1 btree.html
46
47tweak:	$(TWEAK)
48	$(LINK) -o tweak $(TWEAK) $(LIBS)
49
50tweak.1:  manpage.but
51	halibut --man=$@ $<
52
53btree.html:  btree.but
54	halibut --html=$@ $<
55
56# Ensure tweak.h reflects this version number, and then run a
57# command like `make release VERSION=3.00'.
58release: tweak.1 btree.html
59	mkdir -p reltmp/tweak-$(VERSION)
60	for i in LICENCE *.c *.h *.but tweak.1 btree.html Makefile; do   \
61		ln -s ../../$$i reltmp/tweak-$(VERSION);         \
62	done
63	(cd reltmp; tar chzvf ../tweak-$(VERSION).tar.gz tweak-$(VERSION))
64	rm -rf reltmp
65
66install: tweak tweak.1
67	mkdir -p $(DESTDIR)$(BINDIR)
68	install tweak $(DESTDIR)$(BINDIR)/tweak
69	mkdir -p $(DESTDIR)$(MANDIR)
70	install -m 0644 tweak.1 $(DESTDIR)$(MANDIR)/tweak.1
71
72clean:
73	rm -f *.o tweak tweak.1 btree.html
74
75.PHONY: release clean install
76
77main.o: main.c tweak.h
78keytab.o: keytab.c tweak.h
79actions.o: actions.c tweak.h
80search.o: search.c tweak.h
81rcfile.o: rcfile.c tweak.h
82buffer.o: buffer.c tweak.h btree.h
83slang.o: slang.c tweak.h
84curses.o: curses.c tweak.h
85btree.o: btree.c btree.h
86