From f72790b98302711f6b80a60d1393d03cc4916b67 Mon Sep 17 00:00:00 2001 From: Thomas Gillis Date: Thu, 23 Feb 2023 17:44:03 -0600 Subject: [PATCH] build: add darwin compatible dynamic libraries add dylib extensions to the dynamic libs for usage on darwin systems and compatibility with -rpath linker option --- Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 64ff8e9..512d18d 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,8 @@ endif ################################################################################ # FROM HERE, DO NOT CHANGE +UNAME := $(shell uname) + #------------------------------------------------------------------------------- PREFIX ?= ./ NAME := h3lpr @@ -114,7 +116,7 @@ all: lib_dynamic lib_static compdb #------------------------------------------------------------------------------- .PHONY: lib_dynamic -lib_dynamic: $(TARGET).so +lib_dynamic: $(TARGET).so $(TARGET).dylib .PHONY: lib_static lib_static: $(TARGET).a @@ -123,6 +125,12 @@ lib_static: $(TARGET).a $(TARGET).so: $(OBJ) $(CXX) -shared $(LDFLAGS) $^ $(LIB) -o $@ +# generate the .dylib only on darwin systems +$(TARGET).dylib: $(OBJ) +ifeq ($(UNAME), Darwin) + $(CXX) -dynamiclib $(LDFLAGS) -install_name $(PREFIX)/lib/lib$@ $^ $(LIB) -o $@ +endif + $(TARGET).a: $(OBJ) ar rvs $@ $^ @@ -152,6 +160,9 @@ install: info lib_dynamic lib_static | install_dir $(call copy_list,$(HEAD),$(PREFIX)/include/${NAME}) $(call mv_list,$(TARGET).a,$(PREFIX)/lib/lib$(TARGET).a) $(call mv_list,$(TARGET).so,$(PREFIX)/lib/lib$(TARGET).so) +ifeq ($(UNAME), Darwin) + $(call mv_list,$(TARGET).dylib,$(PREFIX)/lib/lib$(TARGET).dylib) +endif .PHONY: install_dir install_dir: