2012-03-12 20:47:30 +01:00
|
|
|
ifeq ($(shell uname),Darwin)
|
|
|
|
LIBTOOL ?= glibtool
|
|
|
|
else
|
|
|
|
LIBTOOL ?= libtool
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(VERBOSE),1)
|
|
|
|
LIBTOOL +=--quiet
|
|
|
|
endif
|
|
|
|
|
|
|
|
CFLAGS +=-Wall -std=c99
|
2009-11-25 03:30:24 +01:00
|
|
|
|
2012-03-12 20:47:30 +01:00
|
|
|
ifeq ($(DEBUG),1)
|
|
|
|
CFLAGS +=-ggdb -DDEBUG
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(PROFILE),1)
|
|
|
|
CFLAGS +=-pg
|
|
|
|
LDFLAGS+=-pg
|
|
|
|
endif
|
2011-09-24 01:04:01 +02:00
|
|
|
|
|
|
|
ifeq ($(shell pkg-config --atleast-version=0.1.0 unibilium && echo 1),1)
|
|
|
|
CFLAGS +=$(shell pkg-config --cflags unibilium) -DHAVE_UNIBILIUM
|
|
|
|
LDFLAGS+=$(shell pkg-config --libs unibilium)
|
2014-03-04 15:04:11 +01:00
|
|
|
else ifeq ($(shell pkg-config tinfo && echo 1),1)
|
|
|
|
CFLAGS +=$(shell pkg-config --cflags tinfo)
|
|
|
|
LDFLAGS+=$(shell pkg-config --libs tinfo)
|
2012-03-08 13:05:27 +01:00
|
|
|
else ifeq ($(shell pkg-config ncursesw && echo 1),1)
|
|
|
|
CFLAGS +=$(shell pkg-config --cflags ncursesw)
|
|
|
|
LDFLAGS+=$(shell pkg-config --libs ncursesw)
|
2011-09-24 01:04:01 +02:00
|
|
|
else
|
|
|
|
LDFLAGS+=-lncurses
|
|
|
|
endif
|
2008-10-10 00:05:40 +02:00
|
|
|
|
2012-03-12 20:47:30 +01:00
|
|
|
OBJECTS=termkey.lo driver-csi.lo driver-ti.lo
|
|
|
|
LIBRARY=libtermkey.la
|
2008-02-07 01:58:41 +01:00
|
|
|
|
2012-04-01 21:04:01 +02:00
|
|
|
DEMOS=demo demo-async
|
|
|
|
|
|
|
|
ifeq ($(shell pkg-config glib-2.0 && echo 1),1)
|
|
|
|
DEMOS+=demo-glib
|
|
|
|
endif
|
|
|
|
|
2012-04-25 20:45:52 +02:00
|
|
|
DEMO_OBJECTS=$(DEMOS:=.lo)
|
|
|
|
|
2012-03-26 19:49:45 +02:00
|
|
|
TESTSOURCES=$(wildcard t/[0-9]*.c)
|
|
|
|
TESTFILES=$(TESTSOURCES:.c=.t)
|
|
|
|
|
2008-11-16 13:28:38 +01:00
|
|
|
VERSION_MAJOR=0
|
2014-01-06 19:02:48 +01:00
|
|
|
VERSION_MINOR=17
|
2008-11-16 13:28:38 +01:00
|
|
|
|
2014-01-06 19:02:48 +01:00
|
|
|
VERSION_CURRENT=12
|
2011-08-25 20:13:21 +02:00
|
|
|
VERSION_REVISION=0
|
2014-01-06 19:02:48 +01:00
|
|
|
VERSION_AGE=11
|
2008-11-02 15:18:16 +01:00
|
|
|
|
2008-11-02 15:22:34 +01:00
|
|
|
PREFIX=/usr/local
|
|
|
|
LIBDIR=$(PREFIX)/lib
|
|
|
|
INCDIR=$(PREFIX)/include
|
2008-11-06 01:02:41 +01:00
|
|
|
MANDIR=$(PREFIX)/share/man
|
|
|
|
MAN3DIR=$(MANDIR)/man3
|
2012-01-21 01:36:00 +01:00
|
|
|
MAN7DIR=$(MANDIR)/man7
|
2008-11-02 15:22:34 +01:00
|
|
|
|
2012-04-01 21:04:01 +02:00
|
|
|
all: $(LIBRARY) $(DEMOS)
|
2009-11-25 03:30:24 +01:00
|
|
|
|
|
|
|
%.lo: %.c termkey.h termkey-internal.h
|
2014-01-06 18:55:58 +01:00
|
|
|
$(LIBTOOL) --mode=compile --tag=CC $(CC) $(CFLAGS) -o $@ -c $<
|
2008-11-06 20:33:07 +01:00
|
|
|
|
2009-11-25 03:30:24 +01:00
|
|
|
$(LIBRARY): $(OBJECTS)
|
2014-01-06 18:55:58 +01:00
|
|
|
$(LIBTOOL) --mode=link --tag=CC $(CC) -rpath $(LIBDIR) -version-info $(VERSION_CURRENT):$(VERSION_REVISION):$(VERSION_AGE) $(LDFLAGS) -o $@ $^
|
2008-11-02 15:18:16 +01:00
|
|
|
|
2009-11-25 03:30:24 +01:00
|
|
|
demo: $(LIBRARY) demo.lo
|
2014-01-06 18:55:58 +01:00
|
|
|
$(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^
|
2008-02-07 01:58:41 +01:00
|
|
|
|
2009-11-25 03:30:24 +01:00
|
|
|
demo-async: $(LIBRARY) demo-async.lo
|
2014-01-06 18:55:58 +01:00
|
|
|
$(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^
|
2008-02-07 01:58:41 +01:00
|
|
|
|
2012-04-01 21:04:01 +02:00
|
|
|
demo-glib.lo: demo-glib.c termkey.h
|
2014-01-06 18:55:58 +01:00
|
|
|
$(LIBTOOL) --mode=compile --tag=CC $(CC) -o $@ -c $< $(shell pkg-config glib-2.0 --cflags)
|
2012-04-01 21:04:01 +02:00
|
|
|
|
|
|
|
demo-glib: $(LIBRARY) demo-glib.lo
|
2014-01-06 18:55:58 +01:00
|
|
|
$(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^ $(shell pkg-config glib-2.0 --libs)
|
2012-04-01 21:04:01 +02:00
|
|
|
|
2012-03-26 19:49:45 +02:00
|
|
|
t/%.t: t/%.c $(LIBRARY) t/taplib.lo
|
2014-01-06 18:55:58 +01:00
|
|
|
$(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^
|
2012-03-26 19:49:45 +02:00
|
|
|
|
|
|
|
t/taplib.lo: t/taplib.c
|
2014-01-06 18:55:58 +01:00
|
|
|
$(LIBTOOL) --mode=compile --tag=CC $(CC) $(CFLAGS) -o $@ -c $^
|
2012-03-26 19:49:45 +02:00
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test: $(TESTFILES)
|
|
|
|
prove -e ""
|
|
|
|
|
|
|
|
.PHONY: clean-test
|
|
|
|
clean-test:
|
|
|
|
$(LIBTOOL) --mode=clean rm -f $(TESTFILES) t/taplib.lo
|
|
|
|
|
2008-02-07 01:58:41 +01:00
|
|
|
.PHONY: clean
|
2012-03-26 19:49:45 +02:00
|
|
|
clean: clean-test
|
2012-04-25 20:45:52 +02:00
|
|
|
$(LIBTOOL) --mode=clean rm -f $(OBJECTS) $(DEMO_OBJECTS)
|
2009-11-25 03:30:24 +01:00
|
|
|
$(LIBTOOL) --mode=clean rm -f $(LIBRARY)
|
2012-04-25 20:45:52 +02:00
|
|
|
$(LIBTOOL) --mode=clean rm -rf $(DEMOS)
|
2008-11-02 15:22:34 +01:00
|
|
|
|
|
|
|
.PHONY: install
|
2008-11-06 01:02:41 +01:00
|
|
|
install: install-inc install-lib install-man
|
2009-11-25 03:30:24 +01:00
|
|
|
$(LIBTOOL) --mode=finish $(DESTDIR)$(LIBDIR)
|
2008-11-06 01:02:41 +01:00
|
|
|
|
2012-03-12 20:47:30 +01:00
|
|
|
install-inc: termkey.h
|
2008-11-02 15:22:34 +01:00
|
|
|
install -d $(DESTDIR)$(INCDIR)
|
|
|
|
install -m644 termkey.h $(DESTDIR)$(INCDIR)
|
2008-11-06 01:02:41 +01:00
|
|
|
install -d $(DESTDIR)$(LIBDIR)/pkgconfig
|
2011-07-01 18:04:12 +02:00
|
|
|
sed "s,@LIBDIR@,$(LIBDIR),;s,@INCDIR@,$(INCDIR)," <termkey.pc.in >$(DESTDIR)$(LIBDIR)/pkgconfig/termkey.pc
|
2008-11-06 01:02:41 +01:00
|
|
|
|
2012-03-12 20:47:30 +01:00
|
|
|
install-lib: $(LIBRARY)
|
2008-11-02 15:22:34 +01:00
|
|
|
install -d $(DESTDIR)$(LIBDIR)
|
2012-05-10 17:00:01 +02:00
|
|
|
$(LIBTOOL) --mode=install install libtermkey.la $(DESTDIR)$(LIBDIR)/libtermkey.la
|
2008-11-06 01:02:41 +01:00
|
|
|
|
|
|
|
install-man:
|
|
|
|
install -d $(DESTDIR)$(MAN3DIR)
|
2012-01-22 16:46:55 +01:00
|
|
|
install -d $(DESTDIR)$(MAN7DIR)
|
2012-01-18 13:01:38 +01:00
|
|
|
for F in man/*.3; do \
|
|
|
|
gzip <$$F >$(DESTDIR)$(MAN3DIR)/$${F#man/}.gz; \
|
2008-11-06 01:02:41 +01:00
|
|
|
done
|
2012-01-21 01:36:00 +01:00
|
|
|
for F in man/*.7; do \
|
|
|
|
gzip <$$F >$(DESTDIR)$(MAN7DIR)/$${F#man/}.gz; \
|
|
|
|
done
|
2012-03-08 22:51:42 +01:00
|
|
|
while read FROM EQ TO; do \
|
|
|
|
echo ln -sf $$TO.gz $(DESTDIR)$(MAN3DIR)/$$FROM.gz; \
|
|
|
|
done < man/also
|
2008-11-18 16:37:37 +01:00
|
|
|
|
|
|
|
# DIST CUT
|
|
|
|
|
2012-01-18 13:01:38 +01:00
|
|
|
MANSOURCE=$(wildcard man/*.3.sh)
|
2008-11-18 16:37:37 +01:00
|
|
|
BUILTMAN=$(MANSOURCE:.3.sh=.3)
|
|
|
|
|
2008-12-15 21:49:59 +01:00
|
|
|
VERSION=$(VERSION_MAJOR).$(VERSION_MINOR)
|
|
|
|
|
2008-11-18 16:37:37 +01:00
|
|
|
all: doc
|
|
|
|
|
|
|
|
doc: $(BUILTMAN)
|
|
|
|
|
|
|
|
%.3: %.3.sh
|
|
|
|
sh $< >$@
|
|
|
|
|
|
|
|
clean: clean-built
|
|
|
|
|
|
|
|
clean-built:
|
|
|
|
rm -f $(BUILTMAN) termkey.h
|
|
|
|
|
|
|
|
termkey.h: termkey.h.in Makefile
|
2012-11-30 16:00:21 +01:00
|
|
|
rm -f $@
|
2008-11-18 16:37:37 +01:00
|
|
|
sed -e 's/@@VERSION_MAJOR@@/$(VERSION_MAJOR)/g' \
|
|
|
|
-e 's/@@VERSION_MINOR@@/$(VERSION_MINOR)/g' \
|
|
|
|
$< >$@
|
2012-11-30 16:00:21 +01:00
|
|
|
chmod a-w $@
|
2008-11-18 16:37:37 +01:00
|
|
|
|
2011-09-05 14:52:58 +02:00
|
|
|
DISTDIR=libtermkey-$(VERSION)
|
2008-11-18 16:37:37 +01:00
|
|
|
|
|
|
|
distdir: all
|
2009-07-15 21:52:35 +02:00
|
|
|
mkdir __distdir
|
2012-01-22 16:52:19 +01:00
|
|
|
cp *.c *.h LICENSE __distdir
|
2012-03-26 19:49:45 +02:00
|
|
|
mkdir __distdir/t
|
|
|
|
cp t/*.c t/*.h __distdir/t
|
2012-01-22 16:52:19 +01:00
|
|
|
mkdir __distdir/man
|
2012-03-26 19:55:59 +02:00
|
|
|
cp man/*.[37] man/also __distdir/man
|
2009-07-15 21:52:35 +02:00
|
|
|
sed "s,@VERSION@,$(VERSION)," <termkey.pc.in >__distdir/termkey.pc.in
|
|
|
|
sed "/^# DIST CUT/Q" <Makefile >__distdir/Makefile
|
|
|
|
mv __distdir $(DISTDIR)
|
2008-11-18 16:46:29 +01:00
|
|
|
|
2008-11-24 22:47:18 +01:00
|
|
|
TARBALL=$(DISTDIR).tar.gz
|
2008-11-18 16:46:29 +01:00
|
|
|
|
|
|
|
dist: distdir
|
2008-11-24 22:47:18 +01:00
|
|
|
tar -czf $(TARBALL) $(DISTDIR)
|
2008-11-18 16:46:29 +01:00
|
|
|
rm -rf $(DISTDIR)
|
2012-01-18 14:39:50 +01:00
|
|
|
|
2012-01-18 15:11:05 +01:00
|
|
|
HTMLDIR=html
|
|
|
|
|
2012-01-21 02:06:48 +01:00
|
|
|
htmldocs: $(BUILTMAN)
|
2012-04-12 20:21:03 +02:00
|
|
|
perl $(HOME)/src/perl/Parse-Man/examples/man-to-html.pl -O $(HTMLDIR) --file-extension tmpl --link-extension html --template home_lou.tt2 --also man/also man/*.3 man/*.7 --index index.tmpl
|