termo/Makefile

120 lines
2.8 KiB
Makefile
Raw Normal View History

LIBTOOL=libtool
2008-10-10 00:05:40 +02:00
CFLAGS?=
CFLAGS_DEBUG=
2008-02-07 01:58:41 +01:00
VERSION_MAJOR=0
2011-05-24 19:18:57 +02:00
VERSION_MINOR=8
2011-04-07 18:38:08 +02:00
VERSION_CURRENT=3
2011-05-24 19:18:57 +02:00
VERSION_REVISION=1
2011-04-07 18:38:08 +02:00
VERSION_AGE=2
2008-11-02 15:22:34 +01:00
PREFIX=/usr/local
LIBDIR=$(PREFIX)/lib
INCDIR=$(PREFIX)/include
MANDIR=$(PREFIX)/share/man
MAN3DIR=$(MANDIR)/man3
2008-11-02 15:22:34 +01:00
2008-10-07 00:24:54 +02:00
ifeq ($(DEBUG),1)
2008-10-10 00:05:40 +02:00
CFLAGS_DEBUG=-ggdb -DDEBUG
2008-10-07 00:24:54 +02:00
endif
all: termkey.h demo demo-async
2008-02-07 01:58:41 +01:00
OBJECTS=termkey.lo driver-csi.lo driver-ti.lo
LIBRARY=libtermkey.la
%.lo: %.c termkey.h termkey-internal.h
$(LIBTOOL) --mode=compile --tag=CC gcc $(CFLAGS) $(CFLAGS_DEBUG) -Wall -std=c99 -o $@ -c $<
$(LIBRARY): $(OBJECTS)
$(LIBTOOL) --mode=link --tag=CC gcc -rpath $(LIBDIR) -version-info $(VERSION_CURRENT):$(VERSION_REVISION):$(VERSION_AGE) -lncurses -o $@ $^
demo: $(LIBRARY) demo.lo
$(LIBTOOL) --mode=link --tag=CC gcc -o $@ $^
2008-02-07 01:58:41 +01:00
demo-async: $(LIBRARY) demo-async.lo
$(LIBTOOL) --mode=link --tag=CC gcc -o $@ $^
2008-02-07 01:58:41 +01:00
.PHONY: clean
clean:
$(LIBTOOL) --mode=clean rm -f $(OBJECTS) demo.lo demo-async.lo
$(LIBTOOL) --mode=clean rm -f $(LIBRARY)
$(LIBTOOL) --mode=clean rm -rf demo demo-async
2008-11-02 15:22:34 +01:00
.PHONY: install
install: install-inc install-lib install-man
$(LIBTOOL) --mode=finish $(DESTDIR)$(LIBDIR)
install-inc:
2008-11-02 15:22:34 +01:00
install -d $(DESTDIR)$(INCDIR)
install -m644 termkey.h $(DESTDIR)$(INCDIR)
install -d $(DESTDIR)$(LIBDIR)/pkgconfig
sed "s,@LIBDIR@,$(LIBDIR),;s,@INCDIR@,$(INCDIR)," <termkey.pc.in >$(DESTDIR)$(LIBDIR)/pkgconfig/termkey.pc
install-lib:
2008-11-02 15:22:34 +01:00
install -d $(DESTDIR)$(LIBDIR)
$(LIBTOOL) --mode=install cp libtermkey.la $(DESTDIR)$(LIBDIR)/libtermkey.la
install-man:
install -d $(DESTDIR)$(MAN3DIR)
for F in *.3; do \
gzip <$$F >$(DESTDIR)$(MAN3DIR)/$$F.gz; \
done
ln -sf termkey_new.3.gz $(DESTDIR)$(MAN3DIR)/termkey_destroy.3.gz
ln -sf termkey_getkey.3.gz $(DESTDIR)$(MAN3DIR)/termkey_getkey_force.3.gz
ln -sf termkey_set_waittime.3.gz $(DESTDIR)$(MAN3DIR)/termkey_get_waittime.3.gz
# DIST CUT
MANSOURCE=$(wildcard *.3.sh)
BUILTMAN=$(MANSOURCE:.3.sh=.3)
VERSION=$(VERSION_MAJOR).$(VERSION_MINOR)
all: doc
doc: $(BUILTMAN)
%.3: %.3.sh
sh $< >$@
TESTSOURCES=$(wildcard t/[0-9]*.c)
TESTFILES=$(TESTSOURCES:.c=.t)
t/%.t: t/%.c $(LIBRARY) t/taplib.lo
$(LIBTOOL) --mode=link --tag=CC gcc -o $@ $^
t/taplib.lo: t/taplib.c
$(LIBTOOL) --mode=compile --tag=CC gcc $(CFLAGS) -o $@ -c $^
test: $(TESTFILES)
prove -e ""
clean: clean-built
clean-built:
rm -f $(BUILTMAN) termkey.h
termkey.h: termkey.h.in Makefile
sed -e 's/@@VERSION_MAJOR@@/$(VERSION_MAJOR)/g' \
-e 's/@@VERSION_MINOR@@/$(VERSION_MINOR)/g' \
$< >$@
DISTDIR=libtermkey-$(VERSION_MAJOR).$(VERSION_MINOR)
distdir: all
mkdir __distdir
2011-07-01 18:05:35 +02:00
cp *.c *.h *.3 LICENSE __distdir
sed "s,@VERSION@,$(VERSION)," <termkey.pc.in >__distdir/termkey.pc.in
sed "/^# DIST CUT/Q" <Makefile >__distdir/Makefile
mv __distdir $(DISTDIR)
TARBALL=$(DISTDIR).tar.gz
dist: distdir
tar -czf $(TARBALL) $(DISTDIR)
rm -rf $(DISTDIR)