LoginSignup
0
0

More than 5 years have passed since last update.

libcidr を macOS でビルドする

Posted at

libcidr とは

環境

  • macOS 10.13.1

GNU Make 4.2.1 のインストール

brew install make

Makefile を修正する

以下のファイルの -soname-install_name に、-shared-dynamiclib に、拡張子 .so.dylib に変更する。

src/GNUmakefile.inc
src/Makefile.inc

差分は次のとおり。

diff --git a/src/GNUmakefile.inc b/src/GNUmakefile.inc
index 4df45d7..f2019ac 100644
--- a/src/GNUmakefile.inc
+++ b/src/GNUmakefile.inc
@@ -49,7 +49,7 @@ def: all

 ${SHLIB_NAME}: ${SO_FILES}
        @echo Linking ${SHLIB_NAME}...
-       ${CC} -shared -Wl,-x -o ${@} -Wl,-soname,${SHLIB_NAME} \
+       ${CC} -dynamiclib -Wl,-x -o ${@} -Wl,-install_name,${SHLIB_NAME} \
                        `${LORDER} ${SO_FILES} | ${TSORT}`
        ${LN} -sf ${SHLIB_NAME} ${SHLIB_LINK}

@@ -74,7 +74,7 @@ ifdef PROGNAME
 # These paths wind up relative to src/{test,examples}/*
 CFLAGS += -I../../../include
 L_FLAGS += -g -pipe -L../..
-LCIDR = ../../libcidr.so
+LCIDR = ../../libcidr.dylib

 CLEAN_FILES = ${O_FILES} ${PROGNAME} *core .depend

@@ -86,4 +86,3 @@ ${PROGNAME}: ${O_FILES} ${LCIDR}
 ${LCIDR}:
        (cd ../.. && make)
 endif
-
diff --git a/src/Makefile.inc b/src/Makefile.inc
index 653357b..f1877a3 100644
--- a/src/Makefile.inc
+++ b/src/Makefile.inc
@@ -45,7 +45,7 @@ def: all

 ${SHLIB_NAME}: ${SO_FILES}
        @echo Linking ${SHLIB_NAME}...
-       ${CC} -shared -Wl,-x -o ${@} -Wl,-soname,${SHLIB_NAME} \
+       ${CC} -dynamiclib -Wl,-x -o ${@} -Wl,-install_name,${SHLIB_NAME} \
                        `${LORDER} ${SO_FILES} | ${TSORT}`
        ${LN} -sf ${SHLIB_NAME} ${SHLIB_LINK}

@@ -70,7 +70,7 @@ clean allclean:
 # These paths wind up relative to src/{test,examples}/*
 CFLAGS += -I../../../include
 L_FLAGS += -g -pipe -L../..
-LCIDR = ../../libcidr.so
+LCIDR = ../../libcidr.dylib

 CLEAN_FILES = ${O_FILES} ${PROGNAME} *core .depend

以下のファイルの拡張子 .so.dylib に変更する。

GNUmakefile.inc
Makefile.inc

差分は次のとおり。

diff --git a/GNUmakefile.inc b/GNUmakefile.inc
index bb0f46b..6076f9d 100644
--- a/GNUmakefile.inc
+++ b/GNUmakefile.inc
@@ -5,8 +5,8 @@

 # Library naming and versioning
 LIB_VERS = 0
-SHLIB_NAME = libcidr.so.${LIB_VERS}
-SHLIB_LINK = libcidr.so
+SHLIB_NAME = libcidr.dylib.${LIB_VERS}
+SHLIB_LINK = libcidr.dylib

 # Define some destination directories
 # Where we think of ourselves as living
diff --git a/Makefile.inc b/Makefile.inc
index 3c44a94..674150d 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -2,8 +2,8 @@

 # Library naming and versioning
 LIB_VERS = 0
-SHLIB_NAME = libcidr.so.${LIB_VERS}
-SHLIB_LINK = libcidr.so
+SHLIB_NAME = libcidr.dylib.${LIB_VERS}
+SHLIB_LINK = libcidr.dylib

 # Define some destination directories
 # Where we think of ourselves as living

ビルド

./mkgmake.sh
gmake -f GNUmakefile
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0