aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-04-08 21:45:55 +0200
committerMattias Andrée <maandree@kth.se>2021-04-08 21:45:55 +0200
commit3c1973e9ef647cafbffb42760a905e79966f43bd (patch)
tree996fd9eb9ebcfc276184098a32ca42a9203ad8f5 /Makefile
parentAdd more sequences and remove pause key as it conflicts with F1 (diff)
downloadlibterminput-3c1973e9ef647cafbffb42760a905e79966f43bd.tar.gz
libterminput-3c1973e9ef647cafbffb42760a905e79966f43bd.tar.bz2
libterminput-3c1973e9ef647cafbffb42760a905e79966f43bd.tar.xz
Add build of dynamically linked library
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile47
1 files changed, 38 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index b6913f6..59cd5b4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,44 +1,73 @@
.POSIX:
+LIB_MAJOR = 1
+LIB_MINOR = 0
+LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
+
+
CONFIGFILE = config.mk
include $(CONFIGFILE)
+OS = linux
+# Linux: linux
+# Mac OS: macos
+# Windows: windows
+include mk/$(OS).mk
-OBJ =\
- interactive-test.o\
- libterminput.o
+
+
+LOBJ =\
+ libterminput.lo
HDR =\
libterminput.h
+OBJ =\
+ interactive-test.o\
+ $(LOBJ:.lo=.o)
+
-all: libterminput.a interactive-test
+all: libterminput.a libterminput.$(LIBEXT) interactive-test
$(OBJ): $(@:.o=.c) $(HDR)
+$(LOBJ): $(@:.lo=.c) $(HDR)
.c.o:
$(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
+.c.lo:
+ $(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
+
.o.a:
+ -rm -f -- $@
$(AR) rc $@ $<
$(AR) -s $@
+.lo.$(LIBEXT):
+ $(CC) $(LIBFLAGS) $(LDFLAGS_METHODS) -o $@ $< $(LDFLAGS)
+
interactive-test: interactive-test.o libterminput.a
$(CC) -o $@ interactive-test.o libterminput.a $(LDFLAGS)
-install: libterminput.a
+install: libterminput.a libterminput.$(LIBEXT)
mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
cp -- libterminput.a "$(DESTDIR)$(PREFIX)/lib/"
cp -- libterminput.h "$(DESTDIR)$(PREFIX)/include/"
+ cp -- libterminput.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libterminput.$(LIBMINOREXT)"
+ ln -sf -- libterminput.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libterminput.$(LIBMAJOREXT)"
+ ln -sf -- libterminput.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libterminput.$(LIBEXT)"
uninstall:
- rm -- "$(DESTDIR)$(PREFIX)/lib/libterminput.a"
- rm -- "$(DESTDIR)$(PREFIX)/include/libterminput.h"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libterminput.$(LIBMAJOREXT)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libterminput.$(LIBMINOREXT)"
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libterminput.$(LIBEXT)"
+ -rm -rf -- "$(DESTDIR)$(PREFIX)/lib/libterminput.a"
+ -rm -rf -- "$(DESTDIR)$(PREFIX)/include/libterminput.h"
clean:
- -rm -f -- *.o *.a interactive-test
+ -rm -f -- *.o *.a *.lo *.so *.su *.dll *.dylib interactive-test
.SUFFIXES:
-.SUFFIXES: .a .o .c
+.SUFFIXES: .a .o .lo .c .$(LIBEXT)
.PHONY: all install uninstall clean