Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS build: libtool APPLE vs GNU #228

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ darwin*)
AC_DEFUN([AC_PROG_LIBTOOL], [AC_CHECK_TOOL(LIBTOOL, libtool, :)])
AC_PROG_LIBTOOL

if test $(which ${LIBTOOL}) = /usr/bin/libtool; then
# if it is the Apple libtool
LIBTOOL_FLAGS='-static -o $@ $^'
else
# if it is the GNU libtool (built from source)
LIBTOOL_FLAGS='--mode=link $(CC) -static -install_name $@ -o $@ $^ $(LDFLAGS) $(LIBS)'
fi

AR_LIB=libliquid.ar
SH_LIB=libliquid.dylib
REBIND=""
Expand Down Expand Up @@ -277,6 +285,7 @@ AC_SUBST(ARCH_OPTION) # compiler architecture option
AC_SUBST(DEBUG_MSG_OPTION) # debug messages option (.e.g -DDEBUG)
AC_SUBST(COVERAGE_OPTION) # source code coverage option (e.g. -fprofile-arcs -ftest-coverage)
AC_SUBST(CLIB) # C library linkage (e.g. '-lc')
AC_SUBST(LIBTOOL_FLAGS) # libtool flags

AC_CONFIG_FILES([makefile])
AC_OUTPUT
5 changes: 3 additions & 2 deletions makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ RANLIB := @RANLIB@
# flags
INCLUDE_CFLAGS = $(addprefix -I,$(include_dirs))
COVERAGE_FLAGS = @COVERAGE_OPTION@ # dynamic library linker needs separate flag
LIBTOOL_FLAGS = @LIBTOOL_FLAGS@ # libtool flags differs between macOS and GNU
CONFIG_CFLAGS = @CFLAGS@ @DEBUG_MSG_OPTION@ @ARCH_OPTION@ ${COVERAGE_FLAGS}
CPPFLAGS = @CPPFLAGS@ $(INCLUDE_CFLAGS)
CFLAGS = $(CONFIG_CFLAGS) -Wall -fPIC
Expand Down Expand Up @@ -1194,9 +1195,9 @@ SHARED_LIB = @SH_LIB@
# darwin
#
libliquid.ar: $(objects)
${LIBTOOL} -static -o $@ $^
${LIBTOOL} ${LIBTOOL_FLAGS}

# gcc -dynamiclib -install_name libliquid.dylib -o libliquid.dylib libmodem.a libutility.a
# clang -dynamiclib -install_name libliquid.dylib -o libliquid.dylib libmodem.a libutility.a
libliquid.dylib: $(objects)
$(CC) -dynamiclib ${COVERAGE_FLAGS} -install_name $@ -o $@ $^ $(LDFLAGS) $(LIBS)

Expand Down