Complete reworking of build system to use libtool

This commit is contained in:
Paul LeoNerd Evans 2009-11-25 02:30:24 +00:00
parent d1842f8a00
commit f2f2c03b56
2 changed files with 24 additions and 14 deletions

View File

@ -3,3 +3,6 @@ demo
demo-async demo-async
termkey_getkey.3 termkey_getkey.3
termkey_waitkey.3 termkey_waitkey.3
*.lo
*.la
.libs

View File

@ -1,4 +1,5 @@
CC?=gcc LIBTOOL=libtool
CFLAGS?= CFLAGS?=
CFLAGS_DEBUG= CFLAGS_DEBUG=
@ -6,7 +7,9 @@ CFLAGS_DEBUG=
VERSION_MAJOR=0 VERSION_MAJOR=0
VERSION_MINOR=3 VERSION_MINOR=3
SONAME=libtermkey.so.$(VERSION_MAJOR) VERSION_CURRENT=0
VERSION_REVISION=0
VERSION_AGE=0
PREFIX=/usr/local PREFIX=/usr/local
LIBDIR=$(PREFIX)/lib LIBDIR=$(PREFIX)/lib
@ -20,24 +23,30 @@ endif
all: termkey.h demo demo-async all: termkey.h demo demo-async
demo: libtermkey.so demo.c OBJECTS=termkey.lo driver-csi.lo driver-ti.lo
$(CC) $(CFLAGS) $(CFLAGS_DEBUG) -o $@ $^ LIBRARY=libtermkey.la
demo-async: libtermkey.so demo-async.c %.lo: %.c termkey.h termkey-internal.h
$(CC) $(CFLAGS) $(CFLAGS_DEBUG) -o $@ $^ $(LIBTOOL) --mode=compile gcc $(CFLAGS) $(CFLAGS_DEBUG) -Wall -std=c99 -o $@ -c $<
libtermkey.so: termkey.o driver-csi.o driver-ti.o $(LIBRARY): $(OBJECTS)
$(LD) -shared -soname=$(SONAME) -o $@ $^ -lncurses $(LIBTOOL) --mode=link gcc -rpath $(LIBDIR) -version-info $(VERSION_CURRENT):$(VERSION_REVISION):$(VERSION_AGE) -lncurses -o $@ $^
%.o: %.c termkey.h termkey-internal.h demo: $(LIBRARY) demo.lo
$(CC) $(CFLAGS) $(CFLAGS_DEBUG) -Wall -std=c99 -fPIC -o $@ -c $< $(LIBTOOL) --mode=link gcc -o $@ $^
demo-async: $(LIBRARY) demo-async.lo
$(LIBTOOL) --mode=link gcc -o $@ $^
.PHONY: clean .PHONY: clean
clean: clean:
rm -f *.o libtermkey.so demo demo-async $(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
.PHONY: install .PHONY: install
install: install-inc install-lib install-man install: install-inc install-lib install-man
$(LIBTOOL) --mode=finish $(DESTDIR)$(LIBDIR)
install-inc: install-inc:
install -d $(DESTDIR)$(INCDIR) install -d $(DESTDIR)$(INCDIR)
@ -47,9 +56,7 @@ install-inc:
install-lib: install-lib:
install -d $(DESTDIR)$(LIBDIR) install -d $(DESTDIR)$(LIBDIR)
install libtermkey.so $(DESTDIR)$(LIBDIR)/$(SONAME).$(VERSION_MINOR) $(LIBTOOL) --mode=install cp libtermkey.la $(DESTDIR)$(LIBDIR)/libtermkey.la
ln -sf $(SONAME).$(VERSION_MINOR) $(DESTDIR)$(LIBDIR)/$(SONAME)
ln -sf $(SONAME) $(DESTDIR)$(LIBDIR)/libtermkey.so
install-man: install-man:
install -d $(DESTDIR)$(MAN3DIR) install -d $(DESTDIR)$(MAN3DIR)