diff options
-rw-r--r-- | Makefile | 46 | ||||
-rw-r--r-- | config.mk | 4 | ||||
-rw-r--r-- | mk/linux.mk | 2 | ||||
-rw-r--r-- | mk/macos.mk | 4 | ||||
-rw-r--r-- | mk/windows.mk | 4 |
5 files changed, 34 insertions, 26 deletions
@@ -1,10 +1,5 @@ .POSIX: -LIB_MAJOR = 1 -LIB_MINOR = 0 -LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR) - - CONFIGFILE = config.mk include $(CONFIGFILE) @@ -15,22 +10,28 @@ OS = linux include mk/$(OS).mk +LIB_MAJOR = 1 +LIB_MINOR = 0 +LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR) -LOBJ =\ - libterminput.lo + +OBJ =\ + libterminput.o HDR =\ libterminput.h -OBJ =\ - interactive-test.o\ - test.o\ - $(LOBJ:.lo=.o) +TESTS =\ + interactive-test\ + test + +LOBJ = $(OBJ:.o=.lo) -all: libterminput.a libterminput.$(LIBEXT) interactive-test test +all: libterminput.a libterminput.$(LIBEXT) $(TESTS) $(OBJ): $(HDR) $(LOBJ): $(HDR) +$(TESTS:=.o): $(HDR) .c.o: $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) @@ -38,20 +39,20 @@ $(LOBJ): $(HDR) .c.lo: $(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -.o.a: - -rm -f -- $@ - $(AR) rc $@ $< - $(AR) -s $@ - -.lo.$(LIBEXT): - $(CC) $(LIBFLAGS) -o $@ $< $(LDFLAGS) - interactive-test: interactive-test.o libterminput.a $(CC) -o $@ interactive-test.o libterminput.a $(LDFLAGS) test: test.o libterminput.a $(CC) -o $@ test.o libterminput.a $(LDFLAGS) +libterminput.$(LIBEXT): $(LOBJ) + $(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS) + +libterminput.a: $(OBJ) + -rm -f -- $@ + $(AR) rc $@ $(OBJ) + $(AR) -s $@ + check: test ./test @@ -63,6 +64,7 @@ install: libterminput.a libterminput.$(LIBEXT) cp -- libterminput.a "$(DESTDIR)$(PREFIX)/lib/" cp -- libterminput.h "$(DESTDIR)$(PREFIX)/include/" cp -- libterminput.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libterminput.$(LIBMINOREXT)" + $(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libterminput.$(LIBMINOREXT)" ln -sf -- libterminput.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libterminput.$(LIBMAJOREXT)" ln -sf -- libterminput.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libterminput.$(LIBEXT)" cp -- libterminput_read.3 libterminput_set_flags.3 libterminput_is_ready.3 "$(DESTDIR)$(MANPREFIX)/man3" @@ -82,9 +84,9 @@ uninstall: -rm -f -- "$(DESTDIR)$(MANPREFIX)/man7/libterminput.7" clean: - -rm -f -- *.o *.a *.lo *.so *.su *.dll *.dylib interactive-test test + -rm -f -- *.o *.a *.lo *.so *.so.* *.su *.dll *.dylib interactive-test test .SUFFIXES: -.SUFFIXES: .a .o .lo .c .$(LIBEXT) +.SUFFIXES: .lo .o .c .PHONY: all check install uninstall clean @@ -1,8 +1,8 @@ PREFIX = /usr MANPREFIX = $(PREFIX)/share/man -CC = cc +CC = c99 CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -CFLAGS = -std=c99 -Wall -O2 +CFLAGS = -Wall -O2 LDFLAGS = -s diff --git a/mk/linux.mk b/mk/linux.mk index 71922e7..92dd7f5 100644 --- a/mk/linux.mk +++ b/mk/linux.mk @@ -2,3 +2,5 @@ LIBEXT = so LIBFLAGS = -shared -Wl,-soname,libterminput.$(LIBEXT).$(LIB_MAJOR) LIBMAJOREXT = $(LIBEXT).$(LIB_MAJOR) LIBMINOREXT = $(LIBEXT).$(LIB_VERSION) + +FIX_INSTALL_NAME = : diff --git a/mk/macos.mk b/mk/macos.mk index bd92de6..e3cd1a6 100644 --- a/mk/macos.mk +++ b/mk/macos.mk @@ -1,4 +1,6 @@ LIBEXT = dylib -LIBFLAGS = -dynamiclib +LIBFLAGS = -dynamiclib -Wl,-compatibility_version,$(LIB_MAJOR) -Wl,-current_version,$(LIB_VERSION) LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT) LIBMINOREXT = $(LIB_VERSION).$(LIBEXT) + +FIX_INSTALL_NAME = install_name_tool -id "$(PREFIX)/lib/libterminput.$(LIBMAJOREXT)" diff --git a/mk/windows.mk b/mk/windows.mk index e9602e1..ed5ec8d 100644 --- a/mk/windows.mk +++ b/mk/windows.mk @@ -1,4 +1,6 @@ LIBEXT = dll -LIBFLAGS = -mdll +LIBFLAGS = -shared LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT) LIBMINOREXT = $(LIB_VERSION).$(LIBEXT) + +FIX_INSTALL_NAME = : |