diff options
author | Mattias Andrée <maandree@kth.se> | 2021-04-08 21:45:55 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-04-08 21:45:55 +0200 |
commit | 3c1973e9ef647cafbffb42760a905e79966f43bd (patch) | |
tree | 996fd9eb9ebcfc276184098a32ca42a9203ad8f5 | |
parent | Add more sequences and remove pause key as it conflicts with F1 (diff) | |
download | libterminput-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 '')
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 47 | ||||
-rw-r--r-- | mk/linux.mk | 4 | ||||
-rw-r--r-- | mk/macos.mk | 4 | ||||
-rw-r--r-- | mk/windows.mk | 4 |
5 files changed, 52 insertions, 9 deletions
@@ -6,5 +6,7 @@ *.so *.su *.out +*.dll +*.dylib /test /interactive-test @@ -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 diff --git a/mk/linux.mk b/mk/linux.mk new file mode 100644 index 0000000..71922e7 --- /dev/null +++ b/mk/linux.mk @@ -0,0 +1,4 @@ +LIBEXT = so +LIBFLAGS = -shared -Wl,-soname,libterminput.$(LIBEXT).$(LIB_MAJOR) +LIBMAJOREXT = $(LIBEXT).$(LIB_MAJOR) +LIBMINOREXT = $(LIBEXT).$(LIB_VERSION) diff --git a/mk/macos.mk b/mk/macos.mk new file mode 100644 index 0000000..bd92de6 --- /dev/null +++ b/mk/macos.mk @@ -0,0 +1,4 @@ +LIBEXT = dylib +LIBFLAGS = -dynamiclib +LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT) +LIBMINOREXT = $(LIB_VERSION).$(LIBEXT) diff --git a/mk/windows.mk b/mk/windows.mk new file mode 100644 index 0000000..e9602e1 --- /dev/null +++ b/mk/windows.mk @@ -0,0 +1,4 @@ +LIBEXT = dll +LIBFLAGS = -mdll +LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT) +LIBMINOREXT = $(LIB_VERSION).$(LIBEXT) |