diff --git a/m4/macosx.m4 b/m4/macosx.m4 index b934c5d9..d6919b89 100644 --- a/m4/macosx.m4 +++ b/m4/macosx.m4 @@ -33,7 +33,7 @@ if test "x$target_darwin" = "xyes" && test "x$ac_cv_mac_universal" = "xyes"; the ;; esac MAC_UNIVERSAL_CFLAGS="$mac_arches $mac_sysroot $mac_minversion" - MAC_UNIVERSAL_LDFLAGS="-dynamiclib" + MAC_UNIVERSAL_LDFLAGS="$mac_arches" fi AC_SUBST([MAC_UNIVERSAL_CFLAGS]) AC_SUBST([MAC_UNIVERSAL_LDFLAGS]) diff --git a/scripts/mkappbundle.sh b/scripts/mkappbundle.sh index e04153c9..0016f888 100755 --- a/scripts/mkappbundle.sh +++ b/scripts/mkappbundle.sh @@ -55,18 +55,15 @@ set -e cd "$build" -if test "x$STRIP" = "x0"; then - INSTALL_PROGRAM_CMD="$INSTALL_STRIP_PROGRAM" -else - INSTALL_PROGRAM_CMD="$INSTALL_PROGRAM" -fi - # bundle the binary appname="${PACKAGE_TARNAME}-${PACKAGE_VERSION}.app" -echo "Creating ${build}/$bundle_dir/$appname" +echo "creating ${build}/$bundle_dir/$appname" $mkinstalldirs "$bundle_dir/$appname/Contents/MacOS" "$bundle_dir/$appname/Contents/Resources" cd "$bundle_dir" -$INSTALL_PROGRAM_CMD "${build}/$binary" "$appname/Contents/MacOS" +$INSTALL_PROGRAM "${build}/$binary" "$appname/Contents/MacOS" +if test "x$STRIP" != "x0"; then + strip -S "$appname/Contents/MacOS/$binary" +fi $INSTALL_DATA "$icon" "$appname/Contents/Resources" echo "APPL${signature}" > "$appname/Contents/PkgInfo" sed -e "s!%%IDENTIFIER%%!${identifier}!g; s!%%NAME%%!${name}!g;\ @@ -79,7 +76,7 @@ fi # bundle the binary and its non-standard dependencies -echo "Creating ${build}/$static_bundle_dir/$appname" +echo "creating ${build}/$static_bundle_dir/$appname" cd .. $mkinstalldirs "$static_bundle_dir" cp -pR "$bundle_dir/$appname" "$static_bundle_dir" @@ -107,5 +104,7 @@ while test "x$list" != "x"; do done cd "$build" -hdiutil create -srcfolder "$bundle_dir" -format UDZO -tgtimagekey zlib-level=9 "$PACKAGE_TARNAME-$PACKAGE_VERSION-nolibs.dmg" -hdiutil create -srcfolder "$static_bundle_dir" -format UDZO -tgtimagekey zlib-level=9 "$PACKAGE_TARNAME-$PACKAGE_VERSION.dmg" +echo $ECHO_N "creating disk image" +hdiutil create -ov -srcfolder "$bundle_dir" -format UDZO -tgtimagekey zlib-level=9 "$PACKAGE_TARNAME-$PACKAGE_VERSION-nolibs.dmg" +echo $ECHO_N "creating disk image" +hdiutil create -ov -srcfolder "$static_bundle_dir" -format UDZO -tgtimagekey zlib-level=9 "$PACKAGE_TARNAME-$PACKAGE_VERSION.dmg" diff --git a/scripts/mkhamlibstatic.sh b/scripts/mkhamlibstatic.sh index 828c064a..d498e59c 100755 --- a/scripts/mkhamlibstatic.sh +++ b/scripts/mkhamlibstatic.sh @@ -1,23 +1,13 @@ #!/bin/sh +# This script must be run by make + set -e -if [ $# -ne 1 ]; then - echo "Syntax: $0 obj-dir" >&2 - exit 1 -fi -tmp="$1" -binary="fldigi" - -if ! test -r "$binary"; then - echo "E: $binary not found" - exit 1 -fi - if test "x$PKG_CONFIG" != "x"; then hamlib_dir="$($PKG_CONFIG --variable=libdir hamlib)" if test "x$hamlib_dir" = "x"; then - echo "E: Could not determine hamlib \$libdir" + echo "E: Could not determine hamlib \$libdir" >&2 exit 1 fi else @@ -28,20 +18,24 @@ else fi fi -rm -rf $tmp -mkdir -p $tmp -cd $tmp -for i in "$hamlib_dir"/hamlib-*.a; do - ar x $i -done -cd .. - case "$target_os" in - *cygwin*) - AM_LDFLAGS="$AM_LDFLAGS -Wl,--export-all-symbols" + *linux*) + AM_LDFLAGS="$AM_LDFLAGS -Wl,--whole-archive $hamlib_dir/hamlib-*.a -Wl,--no-whole-archive" + ;; + *darwin*) + # Apple's ld isn't quite up to this task: there is no way to specify -all_load for + # only a subset of the libraries that we must link with. For this reason we resort + # to using the "dangerous" -m flag, which turns "multiply defined symbol" errors + # into warnings. This will probably not work for ppc64 and x86_64 universal binaries. + AM_LDFLAGS="$AM_LDFLAGS -Wl,-all_load -Wl,-m $hamlib_dir/hamlib-*.a" + ;; + *cygwin*) + AM_LDFLAGS="$AM_LDFLAGS -Wl,--export-all-symbols -Wl,--whole-archive $hamlib_dir/hamlib-*.a -Wl,--no-whole-archive" + ;; + *) + echo "E: This script does not support $target_os" >&2 + exit 1 ;; esac -$CXX -o ${binary}${EXEEXT} $AM_CXXFLAGS $CXXFLAGS $AM_LDFLAGS $LDFLAGS $fldigi_OBJECTS $tmp/*.${OBJEXT} $fldigi_LDADD - -rm -rf $tmp +$CXX -o ${1}${EXEEXT} $AM_CXXFLAGS $CXXFLAGS $AM_LDFLAGS $LDFLAGS $fldigi_OBJECTS $fldigi_LDADD diff --git a/src/Makefile.am b/src/Makefile.am index 3418b19c..a1aaed0d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -90,7 +90,7 @@ flgen: $(srcdir)/dialogs/confdialog.fl $(srcdir)/rigcontrol/rigdialog.fl endif if DARWIN -appbundle: +appbundle: fldigi sh $(srcdir)/../scripts/mkappbundle.sh "$(srcdir)/../data" . \ $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)-bundle-nolibs \ $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)-bundle @@ -100,9 +100,8 @@ CLEAN_LOCAL_FILES += $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)-bundle-nolibs \ endif if ENABLE_HAMLIB -hamlib-static: - sh $(srcdir)/../scripts/mkhamlibstatic.sh hls-tmp -CLEAN_LOCAL_FILES += hls-tmp +hamlib-static: $(fldigi_OBJECTS) + sh $(srcdir)/../scripts/mkhamlibstatic.sh fldigi endif clean-local: