diff --git a/.gitea/workflows/build-macos.yml b/.gitea/workflows/build-macos.yml index f6efac7..f6b512f 100644 --- a/.gitea/workflows/build-macos.yml +++ b/.gitea/workflows/build-macos.yml @@ -41,6 +41,22 @@ jobs: export MACHTYPE=${{ matrix.machtype }} export HOSTTYPE=${{ matrix.arch }} export CCOPTFLAG="-O0 -Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -Wno-error=implicit-int" + + # Pre-generate code-generator outputs using host compiler if needed + if [ ! -f tiff/libtiff/tif_fax3sm.c ]; then + echo "Pre-generating tiff/libtiff/tif_fax3sm.c using host compiler..." + (cd tiff && chmod +x configure && ./configure --disable-old-jpeg --disable-pixarlog --disable-zlib --disable-jbig --disable-lzma) >/dev/null 2>&1 || true + cc -Itiff/libtiff tiff/libtiff/mkg3states.c tiff/port/strcasecmp.c -o tiff/mkg3states + tiff/mkg3states -c const tiff/libtiff/tif_fax3sm.c + rm -f tiff/mkg3states + fi + if [ ! -f imdi/imdi_k.h ] || [ ! -f imdi/imdi_k.c ]; then + echo "Pre-generating imdi kernel files using host compiler..." + cc -Ih -Inumlib imdi/imdi_make.c imdi/imdi_gen.c imdi/cgen.c -o imdi/imdi_make + (cd imdi && ./imdi_make -f -d .) + rm -f imdi/imdi_make + fi + jam -q -d2 -fJambase -j1 -sBUILTIN_TIFF=true -sBUILTIN_JPEG=true -sBUILTIN_PNG=true -sBUILTIN_Z=true -sBUILTIN_SSL=true install - name: Ad-hoc Sign & Verify Binaries @@ -58,10 +74,26 @@ jobs: ARGYLL_NOT_INTERACTIVE: "1" ARGYLL_EXCLUDE_SERIAL_SCAN: "1" run: | - ./bin/dispcal -? || true - ./bin/chartread -? || true - ./bin/colprof -? || true - ./bin/targen -? || true + HOST_ARCH="$(uname -m)" + if [ "${{ matrix.arch }}" = "$HOST_ARCH" ]; then + echo "Running native execution smoke tests for ${{ matrix.arch }}..." + ./bin/dispcal -? || true + ./bin/chartread -? || true + ./bin/colprof -? || true + ./bin/targen -? || true + else + echo "Skipping execution smoke tests when cross-compiling (${{ matrix.arch }} on $HOST_ARCH)." + fi + echo "Verifying Mach-O binary architectures match ${{ matrix.arch }}:" + for f in bin/*; do + if [ -f "$f" ] && file "$f" | grep -q "Mach-O"; then + echo "$f: $(file -b "$f")" + if ! file "$f" | grep -q "${{ matrix.arch }}"; then + echo "ERROR: $f architecture does not match expected ${{ matrix.arch }}!" + exit 1 + fi + fi + done - name: Package Release run: | @@ -160,7 +192,11 @@ jobs: echo "=== Binary Architecture & Signature Verification ===" for file in bin/*; do if [ -f "$file" ] && file "$file" | grep -q "Mach-O"; then - file "$file" + echo "$file: $(file -b "$file")" + if ! file "$file" | grep -q "universal binary"; then + echo "ERROR: $file is not a universal binary!" + exit 1 + fi codesign -dvv "$file" fi done diff --git a/Jambase b/Jambase index fa592c6..dd419f6 100755 --- a/Jambase +++ b/Jambase @@ -1045,7 +1045,25 @@ else if $(UNIX) LINKFLAGS += -framework Carbon ; # default for .c LINKFLAGS += -framework Cocoa ; # default for .m - if $(COMPILER) = "OSX10_6_X86_64BIT" { + if $(TARGET_ARCH) = "arm64" + || $(HOSTTYPE) = "arm64" + || $(MACHTYPE) = "arm64-apple-darwin" { + ECHO "Target architecture: macOS ARM 64-bit (arm64)" ; + TARGET64 = true ; + CCFLAGS += -arch arm64 ; + C++FLAGS += -arch arm64 ; + LINKFLAGS += -arch arm64 ; + + } else if $(TARGET_ARCH) = "x86_64" + || $(HOSTTYPE) = "x86_64" + || $(MACHTYPE) = "x86_64-apple-darwin" { + ECHO "Target architecture: macOS Intel 64-bit (x86_64)" ; + TARGET64 = true ; + CCFLAGS += -arch x86_64 ; + C++FLAGS += -arch x86_64 ; + LINKFLAGS += -arch x86_64 ; + + } else if $(COMPILER) = "OSX10_6_X86_64BIT" { ECHO "We're cross compiling to OSX 10.6 AMD/Intel 64 bit" ; # setup script needs to export MACOSX_DEPLOYMENT_TARGET="10.6" # and export CROSS_CFLAGS=--target=x86_64-apple-macosx10.6.0 diff --git a/imdi/Jamfile b/imdi/Jamfile index 2c0ec65..e1eb896 100755 --- a/imdi/Jamfile +++ b/imdi/Jamfile @@ -33,16 +33,18 @@ if $(NT) && $(MINGW64) { # imdi low level cgen test code Main ctest : ctest.c cgen.c ; -# make imdi code program -Main imdi_make : imdi_make.c imdi_gen.c cgen.c ; - HDRS = ../h ../numlib ; LINKLIBS = ../numlib/libnum ; -# GenFile source.c : program args ; make custom file -# Generate all the kernel files -GenFileND imdi_k.h : imdi_make $(IMDI_MAKE_OPT) -d [ NormPaths $(DOT) ] ; -Clean clean : imdi_k.c ; +# make imdi code program +if ! [ GLOB imdi : imdi_k.h ] || ! [ GLOB imdi : imdi_k.c ] { + Main imdi_make : imdi_make.c imdi_gen.c cgen.c ; + + # GenFile source.c : program args ; make custom file + # Generate all the kernel files + GenFileND imdi_k.h : imdi_make $(IMDI_MAKE_OPT) -d [ NormPaths $(DOT) ] ; + Clean clean : imdi_k.c ; +} # imdi library Library libimdi : imdi.c imdi_tab.c ; diff --git a/tiff/Jamfile b/tiff/Jamfile index 571b1ef..f484d76 100755 --- a/tiff/Jamfile +++ b/tiff/Jamfile @@ -31,12 +31,14 @@ ObjectKeep port/getopt.c ; ObjectKeep port/strcasecmp.c ; # generation utilities (don't use libport ! - there will be dependency problems for Xcompile!) -if $(UNIX) { - Main mkg3states : libtiff/mkg3states.c [ CatPaths port : strcasecmp.c ] ; -} else { - Main mkg3states : libtiff/mkg3states.c [ CatPaths port : getopt.c strcasecmp.c ] ; +if ! [ GLOB tiff/libtiff : tif_fax3sm.c ] { + if $(UNIX) { + Main mkg3states : libtiff/mkg3states.c [ CatPaths port : strcasecmp.c ] ; + } else { + Main mkg3states : libtiff/mkg3states.c [ CatPaths port : getopt.c strcasecmp.c ] ; + } + GenFileND libtiff/tif_fax3sm.c : mkg3states -c const [ NormPaths libtiff/tif_fax3sm.c ] ; } -GenFileND libtiff/tif_fax3sm.c : mkg3states -c const [ NormPaths libtiff/tif_fax3sm.c ] ; # support library for tools if $(UNIX) {