diff options
author | Mattias Andrée <maandree@kth.se> | 2022-02-19 22:39:08 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-02-19 22:39:08 +0100 |
commit | c2257da4845de8ccfcccd4309c4a2c489addb14c (patch) | |
tree | 153f13b442eff6e87a63303aef1993073cd01f00 | |
parent | Use c99 instead of cc -std=c99 (diff) | |
download | libskrift-c2257da4845de8ccfcccd4309c4a2c489addb14c.tar.gz libskrift-c2257da4845de8ccfcccd4309c4a2c489addb14c.tar.bz2 libskrift-c2257da4845de8ccfcccd4309c4a2c489addb14c.tar.xz |
Makefile: add support for shared library
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r-- | Makefile | 45 | ||||
-rw-r--r-- | mk/linux.mk | 7 | ||||
-rw-r--r-- | mk/macos.mk | 7 | ||||
-rw-r--r-- | mk/windows.mk | 7 |
4 files changed, 59 insertions, 7 deletions
@@ -3,6 +3,18 @@ CONFIGFILE = config.mk include $(CONFIGFILE) +OS = linux +# Linux: linux +# Mac OS: macos +# Windows: windows +include mk/$(OS).mk + + +LIB_MAJOR = 1 +LIB_MINOR = 0 +LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR) + + OBJ =\ libskrift_add_180_degree_rotation.o\ libskrift_add_270_degree_rotation.o\ @@ -48,34 +60,53 @@ HDR =\ srgb-gamma.h\ $(LIB_HDR) -all: libskrift.a demo -$(OBJ): $(@:.o=.c) $(HDR) +LOBJ = $(OBJ:.o=.lo) + + +all: libskrift.a libskrift.$(LIBEXT) demo +$(OBJ): $(HDR) +$(LOBJ): $(HDR) demo.o: demo.c $(LIB_HDR) +.c.o: + $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) + +.c.lo: + $(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS) + +libskrift.$(LIBEXT): $(LOBJ) + $(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS) + libskrift.a: $(OBJ) + -rm -f -- $@ $(AR) rc $@ $(OBJ) $(AR) ts $@ > /dev/null -.c.o: - $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) - demo: demo.o libskrift.a $(CC) -o $@ $@.o libskrift.a $(LDFLAGS) -install: libskrift.a +install: libskrift.a libskrift.$(LIBEXT) mkdir -p -- "$(DESTDIR)$(PREFIX)/lib" mkdir -p -- "$(DESTDIR)$(PREFIX)/include" cp -- libskrift.a "$(DESTDIR)$(PREFIX)/lib" + cp -- libskrift.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBMINOREXT)" + $(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBMINOREXT)" + ln -sf -- "libskrift.$(LIBMINOREXT)" "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBMAJOREXT)" + ln -sf -- "libskrift.$(LIBMAJOREXT)" "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBEXT)" + cp -- libskrift.a "$(DESTDIR)$(PREFIX)/lib" cp -- libskrift.h "$(DESTDIR)$(PREFIX)/include" uninstall: -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libskrift.a" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBEXT)" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBMAJOREXT)" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libskrift.$(LIBMINOREXT)" -rm -f -- "$(DESTDIR)$(PREFIX)/include/libskrift.h" clean: -rm -f -- *.o *.lo *.su *.a *.so *.so.* demo .SUFFIXES: -.SUFFIXES: .c .o +.SUFFIXES: .c .o .lo .PHONY: all install uninstall clean diff --git a/mk/linux.mk b/mk/linux.mk new file mode 100644 index 0000000..10a9461 --- /dev/null +++ b/mk/linux.mk @@ -0,0 +1,7 @@ +LIBEXT = so +LIBFLAGS = -shared -Wl,-soname,libskrift.$(LIBEXT).$(LIB_MAJOR) + +LIBMAJOREXT = $(LIBEXT).$(LIB_MAJOR) +LIBMINOREXT = $(LIBEXT).$(LIB_MAJOR).$(LIB_MINOR) + +FIX_INSTALL_NAME = : diff --git a/mk/macos.mk b/mk/macos.mk new file mode 100644 index 0000000..d10e427 --- /dev/null +++ b/mk/macos.mk @@ -0,0 +1,7 @@ +LIBEXT = dylib +LIBFLAGS = -dynamiclib -Wl,-compatibility_version,$(LIB_MAJOR) -Wl,-current_version,$(LIB_VERSION) + +LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT) +LIBMINOREXT = $(LIB_MAJOR).$(LIB_MINOR).$(LIBEXT) + +FIX_INSTALL_NAME = install_name_tool -id "$(PREFIX)/lib/libskrift.$(LIBMAJOREXT)" diff --git a/mk/windows.mk b/mk/windows.mk new file mode 100644 index 0000000..304b6be --- /dev/null +++ b/mk/windows.mk @@ -0,0 +1,7 @@ +LIBEXT = dll +LIBFLAGS = -shared + +LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT) +LIBMINOREXT = $(LIB_MAJOR).$(LIB_MINOR).$(LIBEXT) + +FIX_INSTALL_NAME = : |