diff --git a/arch/darwin/Makefile.in b/arch/darwin/Makefile.in index db3f1296a..e4ea3be45 100644 --- a/arch/darwin/Makefile.in +++ b/arch/darwin/Makefile.in @@ -8,7 +8,8 @@ DSOPOST = .dylib DSORPATH = DSOSONAME = -install_name ${LIBDIR}/ -LIPO ?= @arch/darwin/lipo.sh +DYLIBBUNDLER ?= @arch/darwin/bundle.sh +LIPO ?= @arch/darwin/lipo.sh # # darwin specific recipes. @@ -93,16 +94,23 @@ ifneq (${DARWIN_META_TARGETS},1) # Per-arch targets. # +UTILS_ZLIB_LDFLAGS ?= ${PREFIX}/lib/libz.a +UTILS_LIBPNG_LDFLAGS ?= ${PREFIX}/lib/libpng.a + package: all ifeq (${BUILD_EDITOR},1) + ${DYLIBBUNDLER} ${REAL_ARCH} ${mzx} ${MV} ${mzx} ${mzx}.${REAL_ARCH} endif ifeq (${BUILD_MZXRUN},1) + ${DYLIBBUNDLER} ${REAL_ARCH} ${mzxrun} ${MV} ${mzxrun} ${mzxrun}.${REAL_ARCH} endif ifeq (${BUILD_MODULAR},1) + ${DYLIBBUNDLER} ${REAL_ARCH} ${core_target} ${MV} ${core_target} ${core_target}.${REAL_ARCH} ifeq (${BUILD_EDITOR},1) + ${DYLIBBUNDLER} ${REAL_ARCH} ${editor_target} ${MV} ${editor_target} ${editor_target}.${REAL_ARCH} endif endif @@ -205,15 +213,6 @@ ifneq (${PREFIX_ARM64E},) endif @${MAKE} lipo -#package_clean: -# @${MAKE} ARCH=i686 package_clean -# @${MAKE} ARCH=x86_64 package_clean -# @${MAKE} ARCH=x86_64h package_clean -# @${MAKE} ARCH=ppc package_clean -# @${MAKE} ARCH=ppc64 package_clean -# @${MAKE} ARCH=arm64 package_clean -# @${MAKE} ARCH=arm64e package_clean - mzx_app := ${build_root}/MegaZeux.app/ mzxrun_app := ${build_root}/MZXRun.app/ @@ -225,6 +224,9 @@ build: ${CP} contrib/icons/quantump.icns ${mzx_app}/Contents/Resources/MegaZeux.icns ${CP} ${build}/LICENSE ${build}/docs/ ${MV} ${build}/docs ${mzx_app}/../Documentation +ifeq (${BUILD_UTILS},1) + ${MV} ${build}/utils/ ${mzx_app}/../Utilities +endif ${MV} ${build}/${mzx} ${mzx_app}/Contents/MacOS/MegaZeux ifneq (${BUILD_MZXRUN},) ${MV} ${build}/${mzxrun} ${mzx_app}/Contents/MacOS/MZXRun @@ -233,6 +235,7 @@ ifneq (${BUILD_MODULAR},) ${MV} ${build}/${core_target} ${mzx_app}/Contents/MacOS/ ${MV} ${build}/${editor_target} ${mzx_app}/Contents/MacOS/ endif + ${CP} -r ./bundles/libs-* ${mzx_app}/Contents/ ifneq (${BUILD_MZXRUN},) ${CP} -r ${mzx_app} ${mzxrun_app} ${RM} ${mzx_app}/Contents/MacOS/MZXRun diff --git a/arch/darwin/README.md b/arch/darwin/README.md index 1e298270a..1803f093b 100644 --- a/arch/darwin/README.md +++ b/arch/darwin/README.md @@ -25,6 +25,11 @@ Untested and unsupported features: - arm64 and arm64e builds haven't been tested. - Notarization isn't supported yet. +Other required software: + +- [dylibbundler](https://github.com/auriamg/macdylibbundler/), which can be + installed via MacPorts: `sudo port install dylibbundler`. + ## PREREQUISITES (Xcode 3.2.6) Note: this section was written against Xcode 3.2.6. The process of building diff --git a/arch/darwin/bundle.sh b/arch/darwin/bundle.sh new file mode 100755 index 000000000..2b83a70f6 --- /dev/null +++ b/arch/darwin/bundle.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +ARCH=$1 +shift + +for exe in $@; do + if [ -f "$exe" ]; then + mkdir -p ./bundles + dylibbundler -od -b -x $exe \ + -d "./bundles/libs-$ARCH/" -p "@executable_path/../libs-$ARCH/" + fi +done diff --git a/arch/darwin/dmg.sh b/arch/darwin/dmg.sh index 5089cf47b..b66a8fe88 100755 --- a/arch/darwin/dmg.sh +++ b/arch/darwin/dmg.sh @@ -7,7 +7,7 @@ DMGNAME=${BASEDIR}/${TARGET}.dmg VOLNAME=MegaZeux mkdir -p ${BASEDIR} -hdiutil create $DMGNAME -size 50m -fs HFS+ \ +hdiutil create $DMGNAME -size 100m -fs HFS+ \ -volname "$VOLNAME" -layout SPUD && DEV_HANDLE=`hdid $DMGNAME | grep Apple_HFS | \ perl -e '\$_=<>; /^\\/dev\\/(disk.)/; print \$1'` diff --git a/src/utils/Makefile.in b/src/utils/Makefile.in index 6aa81bf83..60dad85e4 100644 --- a/src/utils/Makefile.in +++ b/src/utils/Makefile.in @@ -16,23 +16,27 @@ utils_obj = src/utils/.build # Define UTILS_LIBSPEC so these properly link. utils_cflags := ${LIBPNG_CFLAGS} ${PTHREAD_CFLAGS} -DUTILS_LIBSPEC= +# Hack for static linking the utilities on macOS. +UTILS_ZLIB_LDFLAGS ?= ${ZLIB_LDFLAGS} +UTILS_LIBPNG_LDFLAGS ?= ${LIBPNG_LDFLAGS} + zip_objs := ${io_obj}/path.o ${io_obj}/vio_no_vfs.o ${io_obj}/zip.o ${io_obj}/zip_stream.o img_objs := ${utils_obj}/image_file.o ${utils_obj}/image_gif.o img_flags := ifneq (${LIBPNG},) -img_flags += ${LIBPNG_LDFLAGS} ${ZLIB_LDFLAGS} -lm +img_flags += ${UTILS_LIBPNG_LDFLAGS} ${UTILS_ZLIB_LDFLAGS} -lm endif checkres := ${utils_src}/checkres${BINEXT} checkres_objs := ${utils_obj}/checkres.o \ ${io_obj}/fsafeopen.o \ ${zip_objs} -checkres_ldflags := ${ZLIB_LDFLAGS} +checkres_ldflags := ${UTILS_ZLIB_LDFLAGS} downver := ${utils_src}/downver${BINEXT} downver_objs := ${utils_obj}/downver.o ${zip_objs} -downver_ldflags := ${ZLIB_LDFLAGS} +downver_ldflags := ${UTILS_ZLIB_LDFLAGS} hlp2html := ${utils_src}/hlp2html${BINEXT} hlp2html_objs := ${utils_obj}/hlp2html.o