Re: [hatari-devel] Hatari macOS builds - handover need?

[ Thread Index | Date Index | More Archives ]

Am 23.04.2023 um 09:03 schrieb Thomas Huth <th.huth@xxxxxxxxx>:

Am Thu, 20 Apr 2023 14:05:04 +0200
schrieb Andreas Grabher <andreas_g86@xxxxxxxxxx>:

Am 20.04.2023 um 13:59 schrieb Chris Jenkins <cdpjenkins@xxxxxxxxx>:

I still have a Mac and would be willing to help out if I can. But I think Thomas's suggestion of publishing artefacts from the CI build is probably the best option.

I think we could update the macOS CI job in the Cirrus-CI to publish the
built binary as CI artifacts there. However, these runners are arm64 only,
so I guess that means "good bye" for the x86 support? Or is XCode on ARM
still ablte to built binaries for x86, too?  

My understanding is that Xcode on Apple Silicon _can_ create x86 binaries (or universal binaries) no problem. See for example   

I can confirm that one can easily build arm64/x86_64 universal binaries on macOS running on Apple Silicon. I do this for Previous using a slightly modified (compared to Hatari) CMake script. It also works from the command line.

Hi Andreas,

could you please provide the details here how to do it? ... I failed to
spot this in the Previous sources so far...


If you do a diff with CMakeLists.txt and src/CMakeLists.txt you will see the differences. The FileMerge tool from Xcode is very useful for comparing. The most important differences are in CMakeLists.txt:

For building universal binaries targeting macOS 10.13 an later:


set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Target architectures" FORCE)



and in src/CMakeLists.txt:

set_target_properties(Previous PROPERTIES INSTALL_RPATH "@executable_path/../Frameworks")
set_target_properties(Previous PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)

With the appended patch I build from the source directory with 
cmake .
cd src/
install_name_tool -change /opt/local/lib/libz.1.dylib /usr/lib/libz.1.dylib Previous
codesign --force -s - Previous

The resulting binary is distributable and contains all non-standard dependencies. The user can start without installing anything on his Mac running macOS 10.13 or later.

The file building.previous.txt contains under "Building a distributable application bundle on macOS“ more detailed instructions, also on creating png.framework. You can skip step 3 if using build.diff.

Attachment: build.diff
Description: Binary data

 Compiling Previous on macOS

Previous can be compiled on any UNIX-like operating system including macOS. 
These instructions also apply to building on Linux except that a different 
package manager will be used. macOS comes with some packages pre-installed. On 
other platforms you might need to also install libpcap, readline and zlib.

1. Install macports:
   Follow the instructions on to download and install 
   the macports package manager. If not already installed this includes to also 
   install Xcode developer tools.

2. Installing required packages:
   Download the latest runtime binary of SDL2 from and 
   copy SDL2.framework to /Library/Frameworks.

   From the command line use the command "port install <package_name>" to 
   install the following packages:

3. Compiling Previous:
   From the command line change the directory to the location of Previous' 
   source tree and run these commands:
      mkdir build
      cd build
      cmake ..

4. Installing Previous:
   Copy from build/src to any target directory. It should now be 
   possible to start and use

 Special notes for Linux

1. It seems that on some distributions of Linux rendering has to be done from 
   the main thread. To make Previous render from the main thread you have to 
   disable the rendering thread with following compile-time option:
      ./configure --disable-rendering-thread

2. Some Linux distributions have pre-installed outdated versions of SDL2. You 
   might have to build an up-to-date version yourself. To compile against your 
   own build of SDL2 you have to set an environment variable:
      setenv SDL2_DIR /path/to/custom/SDL2 ; ./configure

 Building a distributable application bundle on macOS

These are special instructions on how to build an application bundle that can 
be distributed and run on any macOS version >= deployment target. If you want 
to build a distributable package skip step 3 from the above instructions and 
replace with these steps:

1. Build png.framework:
   a Download source code from
   b Go to the source directory and build an Xcode project:
   c Open the Xcode project and select "libpng" in left side bar
   d Select "Targets > png_framework" in middle sector
   e Set "Architectures" to "Standard Architectures (Apple Silicon, Intel)"
   f Set "Build Active Architecture Only" to "No"
   g Set "macOS Deployment Target" to "macOS 10.13" or oldest available
   h Set "Framework Version" to "A"
   i Set "Compatibility Version" to "1.0.0"
   j Set "Current Library Version" to the actual version of libpng
   k Select "png_framework > Any Mac" in title bar and go to "Edit Scheme ..."
   l Set "Build Configuration" to "Release"
   m Select "Product > Build" from the menu bar
   n Using Terminal go to bundle directory, change loader path and sign code:
        install_name_tool -change /opt/local/lib/libz.1.dylib /usr/lib/libz.1.dylib png
        codesign --force -s - png
   o Copy the framework to /Library/Frameworks and make sure no other versions
     of libpng are installed (if applicable remove macports version of libpng)

2. From the command line go to Previous' source directory and build Previous 
   using this command from the command line:
      cmake .

3. Add SDL2.framework and png.framework to the application bundle:
   The application bundle is located in the src directory of the 
   source tree. Go inside the application bundle and go to the Contents folder.
   Copy SDL2.framework and png.framework into the "Frameworks" folder.

4. Change internal linking of Previous:
   Using Terminal go to the MacOS directory inside the application bundle and
   run these commands from the command line:
      install_name_tool -change /opt/local/lib/libz.1.dylib /usr/lib/libz.1.dylib Previous
      codesign --force -s - Previous

5. Make a package for distribution:
   Create a folder named "Previous <version>" and copy into it. 
   Copy the following files and folders to the same folder:

   Archive the folder using the Compress option from the Finder context menu.

 Compiling Previous on Windows

Previous can be compiled on Windows using the MinGW64 compiler on the MSYS2 
platform. The code won't compile with Visual Studio (MSVC) because it relies on 
POSIX functions that are not supported by MSVC.

1. Install MSYS2 64-bit:
   Follow the instructions on to download and install the 
   MinGW compiler.

2. Installing required packages:
   Open the MinGW command prompt from the Start menu (MSYS2 MinGW x64) and 
   install the following packages using the command: "pacman -S <package_name>":
      mingw-w64-x86_64-ninja   (optional, but recommended)

3. Compiling Previous:
   On the MSYS2 MinGW x64 prompt change the directory to the location of 
   Previous' source tree and run these commands:
      mkdir build
      cd build
      cmake ..
      cmake --build . && strip src/Previous.exe

4. Installing Previous:
   Copy Previous.exe from build/src to any target directory and copy the files 
   listed below from <MSYS2_installation_dir>/mingw64/bin to the same location 
   as Previous.exe:

   It should now be possible to start and use Previous.exe.

Mail converted by MHonArc 2.6.19+