aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile47
-rw-r--r--mk/linux.mk4
-rw-r--r--mk/macos.mk4
-rw-r--r--mk/windows.mk4
5 files changed, 52 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index f0ff639..dc724f5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,5 +6,7 @@
*.so
*.su
*.out
+*.dll
+*.dylib
/test
/interactive-test
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
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)