From dbad0c3027a170e51a4a33c381bc24ec2ec8b09b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 10 Feb 2019 18:09:37 +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 | 15 +++++++++------ config.mk | 3 --- linux.mk | 5 +++++ macos.mk | 5 +++++ 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 linux.mk create mode 100644 macos.mk diff --git a/Makefile b/Makefile index 14be91d..491e31c 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,15 @@ CONFIGFILE = config.mk +OSCONFIGFILE = linux.mk +# Change to macos.mk for Mac OS + LIB_MAJOR = 1 LIB_MINOR = 0 LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR) include $(CONFIGFILE) - +include $(OSCONFIGFILE) HDR =\ libsha2.h\ @@ -87,9 +90,9 @@ install: mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man0" mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man3" cp -- libsha2.a "$(DESTDIR)$(PREFIX)/lib" - cp -- libsha2.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libsha2.$(LIBEXT).$(LIB_MAJOR).$(LIB_MINOR)" - ln -sf -- "libsha2.$(LIBEXT).$(LIB_MAJOR).$(LIB_MINOR)" "$(DESTDIR)$(PREFIX)/lib/libsha2.$(LIBEXT).$(LIB_MAJOR)" - ln -sf -- "libsha2.$(LIBEXT).$(LIB_MAJOR)" "$(DESTDIR)$(PREFIX)/lib/libsha2.$(LIBEXT)" + cp -- libsha2.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libsha2.$(LIBMINOREXT)" + ln -sf -- "libsha2.$(LIBMINOREXT).$(LIB_MINOR)" "$(DESTDIR)$(PREFIX)/lib/libsha2.$(LIBMAJOREXT)" + ln -sf -- "libsha2.$(LIBMAJOREXT)" "$(DESTDIR)$(PREFIX)/lib/libsha2.$(LIBEXT)" cp -- libsha2.h "$(DESTDIR)$(PREFIX)/include" cp -- $(MAN0) "$(DESTDIR)$(MANPREFIX)/man0" cp -- $(MAN3) "$(DESTDIR)$(MANPREFIX)/man3" @@ -98,8 +101,8 @@ install: uninstall: -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsha2.a" -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsha2.$(LIBEXT)" - -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsha2.$(LIBEXT).$(LIB_MAJOR)" - -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsha2.$(LIBEXT).$(LIB_MAJOR).$(LIB_MINOR)" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsha2.$(LIBMAJOREXT)" + -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsha2.$(LIBMINOREXT)" -rm -f -- "$(DESTDIR)$(PREFIX)/include/libsha2.h" -cd -- "$(DESTDIR)$(MANPREFIX)/man0" && rm -f -- $(MAN0) -cd -- "$(DESTDIR)$(MANPREFIX)/man3" && rm -f -- $(MAN3) diff --git a/config.mk b/config.mk index ce6682d..cd79dd2 100644 --- a/config.mk +++ b/config.mk @@ -4,6 +4,3 @@ MANPREFIX = $(PREFIX)/share/man CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 CFLAGS = -std=c99 -Wall -Wextra -O3 $(CPPFLAGS) LDFLAGS = -s - -LIBEXT = so -LIBFLAGS = -shared -Wl,-soname,libsha2.$(LIBEXT).$(LIB_MAJOR) diff --git a/linux.mk b/linux.mk new file mode 100644 index 0000000..3618fcd --- /dev/null +++ b/linux.mk @@ -0,0 +1,5 @@ +LIBEXT = so +LIBFLAGS = -shared -Wl,-soname,libsha2.$(LIBEXT).$(LIB_MAJOR) + +LIBMAJOREXT = $(LIBEXT).$(LIB_MAJOR) +LIBMINOREXT = $(LIBEXT).$(LIB_MAJOR).$(LIB_MINOR) diff --git a/macos.mk b/macos.mk new file mode 100644 index 0000000..47d4b44 --- /dev/null +++ b/macos.mk @@ -0,0 +1,5 @@ +LIBEXT = dylib +LIBFLAGS = -dynamiclib + +LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT) +LIBMINOREXT = $(LIB_MAJOR).$(LIB_MINOR).$(LIBEXT) -- cgit v1.2.3-70-g09d2