Skip to content

Commit

Permalink
Fix bundling libraries and utilities.
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceLR committed Feb 8, 2024
1 parent a322a59 commit d7b7e36
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
23 changes: 13 additions & 10 deletions arch/darwin/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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/

Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions arch/darwin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions arch/darwin/bundle.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion arch/darwin/dmg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'`
Expand Down
10 changes: 7 additions & 3 deletions src/utils/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d7b7e36

Please sign in to comment.