From 313f261584bdbdf769d26bfb4d709ac2ff9bb2ba Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 19 Feb 2022 21:34:29 +0100 Subject: Improve makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index de56c1c..81f42ff 100644 --- a/Makefile +++ b/Makefile @@ -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 -- cgit v1.2.3-70-g09d2