From 00c76ec9332555992f3ff181c985b526eece0637 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 19 Feb 2022 22:54:27 +0100 Subject: Update makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 11 ++++++----- config.mk | 4 ++-- mk/linux.mk | 2 ++ mk/macos.mk | 4 +++- mk/windows.mk | 4 +++- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 65e77d0..686ddeb 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,5 @@ .POSIX: -LIB_MAJOR = 1 -LIB_MINOR = 1 -LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR) - - CONFIGFILE = config.mk include $(CONFIGFILE) @@ -15,6 +10,10 @@ OS = linux include mk/$(OS).mk +LIB_MAJOR = 1 +LIB_MINOR = 1 +LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR) + all: libparser.a libparser.$(LIBEXT) libparser-generate calc-example/calc libparser.o: libparser.c libparser.h @@ -31,6 +30,7 @@ libparser-generate: libparser-generate.o $(CC) -o $@ libparser-generate.o $(LDFLAGS) libparser.a: libparser.o + @rm -f -- $@ $(AR) rc $@ libparser.o $(AR) -s $@ @@ -53,6 +53,7 @@ install: libparser.a libparser.$(LIBEXT) libparser-generate cp -- libparser-generate "$(DESTDIR)$(PREFIX)/bin" cp -- libparser.a "$(DESTDIR)$(PREFIX)/lib" cp -- libparser.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libparser.$(LIBMINOREXT)" + $(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libparser.$(LIBMINOREXT)" ln -sf -- libparser.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libparser.$(LIBMAJOREXT)" ln -sf -- libparser.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libparser.$(LIBEXT)" cp -- libparser.h "$(DESTDIR)$(PREFIX)/include" diff --git a/config.mk b/config.mk index accd17b..52600f2 100644 --- a/config.mk +++ b/config.mk @@ -1,8 +1,8 @@ PREFIX = /usr MANPREFIX = $(PREFIX)/share/man -CC = cc +CC = c99 CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -I"$$(pwd)" -CFLAGS = -std=c99 -Wall -O2 +CFLAGS = -Wall -O2 LDFLAGS = -s diff --git a/mk/linux.mk b/mk/linux.mk index bafa31c..2d0a26c 100644 --- a/mk/linux.mk +++ b/mk/linux.mk @@ -2,3 +2,5 @@ LIBEXT = so LIBFLAGS = -shared -Wl,-soname,libparser.$(LIBEXT).$(LIB_MAJOR) LIBMAJOREXT = $(LIBEXT).$(LIB_MAJOR) LIBMINOREXT = $(LIBEXT).$(LIB_VERSION) + +FIX_INSTALL_NAME = : diff --git a/mk/macos.mk b/mk/macos.mk index bd92de6..1217a0b 100644 --- a/mk/macos.mk +++ b/mk/macos.mk @@ -1,4 +1,6 @@ LIBEXT = dylib -LIBFLAGS = -dynamiclib +LIBFLAGS = -dynamiclib -Wl,-compatibility_version,$(LIB_MAJOR) -Wl,-current_version,$(LIB_VERSION) LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT) LIBMINOREXT = $(LIB_VERSION).$(LIBEXT) + +FIX_INSTALL_NAME = install_name_tool -id "$(PREFIX)/lib/libparser.$(LIBMAJOREXT)" diff --git a/mk/windows.mk b/mk/windows.mk index e9602e1..ed5ec8d 100644 --- a/mk/windows.mk +++ b/mk/windows.mk @@ -1,4 +1,6 @@ LIBEXT = dll -LIBFLAGS = -mdll +LIBFLAGS = -shared LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT) LIBMINOREXT = $(LIB_VERSION).$(LIBEXT) + +FIX_INSTALL_NAME = : -- cgit v1.2.3-70-g09d2