8000 Mac OS Makefile support by frno7 · Pull Request #34 · frno7/psgplay · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Mac OS Makefile support #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 10, 2025
Merged

Mac OS Makefile support #34

merged 7 commits into from
Apr 10, 2025

Conversation

frno7
Copy link
Owner
@frno7 frno7 commented Apr 9, 2025

No description provided.

@@ -14,6 +14,8 @@ pkgdir = $(libdir)/pkgconfig

export prefix includedir libdir

BUILD_SYSTEM := $(shell uname -s)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... HOST_SYSTEM would probably be somewhat more appropriate, considering its main use. Or maybe we should have both BUILD_SYSTEM and HOST_SYSTEM. The difference between the two is relevant when cross compiling, but maybe Mac users generally won’t care about such things anyway?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmhmm... Mac users may still want to build the TOS binaries right?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm... There are two TOS programs:

  1. lib/tos/tos which is compiled to m68k machine code from lib/tos/reset.S and lib/tos/sndh.c. This is the SNDH player running inside the PSG play emulator, primarily to configure timer interrupts and invoking init and play trampolines in the SNDH. However, I’ve commited a precompiled tos file in the Git repo, so unless any of the two source files are updated, it doesn’t need to be cross-compiled.
  2. PSGPLAY.TOS is the Atari ST variant of PSG play. Running the exact same interactive text mode as on Linux and Mac OS. Someday I’d like to make a GEM version too, for both Atari ST and X Windows in Linux. :-)

Well, the adventurous Mac user will have to compile an m68k-elf-gcc cross-compiler first, and then try:

psgplay/INSTALL

Lines 53 to 55 in 7677952

Build for the Atari ST:
$ make TARGET_COMPILE=m68k-elf- PSGPLAY.TOS

I’ve made a Docker with an m68k cross-compiler in the gentoo-m68k repo, mostly for its use in the Github workflow that compiles PSGPLAY.TOS:

build-atari-st:
runs-on: ubuntu-latest
container: ghcr.io/frno7/gentoo-m68k:main

Copy link
Contributor
@kareandersen kareandersen Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see if I can scrounge up the adventurism for it one of these days, but meanwhile back in the real world there is Linux :) I did a docker setup once too, based on Vincent's excellent work and vasm/vbcc/vlink but in the end I enjoy m68k the most so the C-compilers have not been getting much use for quite a few years. Rethinking that right now - C turns out to be fun again :)

Anyway, patches can always be added later right?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see if I can scrounge up the adventurism for it one of these days, but meanwhile back in the real world there is Linux :) I did a docker setup once too, based on Vincent's excellent work and vasm/vbcc/vlink

Oh, based on MINT, with a patched C compiler having 16 bits int? I suppose the main difference is that I’m using a standard (unpatched) m68k/GCC compiler as it comes directly from GNU. That’s a 32-bit compiler, so I made my own TOS/libc that works with 32 bits int despite TOS being 16 bits. :-)

but in the end I enjoy m68k the most so the C-compilers have not been getting much use for quite a few years. Rethinking that right now - C turns out to be fun again :)

Yeah, C is fairly close to assembly code, and much less tedious, to my mind. :-)

Anyway, patches can always be added later right?

Patches for cross-compilation on Mac OS? Sure, if we can make it work cleanly!

Copy link
Contributor
@kareandersen kareandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Sequoia/Apple Clang and it works like a charm - very nice touch with the libtool! Will figure out the Homebrew bits in the build scripts, which makes a lot of sense, as some people still prefer MacPorts or other solutions - and some are perhaps even content with XCode...

@frno7
Copy link
Owner Author
frno7 commented Apr 9, 2025

Tested on Sequoia/Apple Clang and it works like a charm - very nice touch with the libtool! Will figure out the Homebrew bits in the build scripts, which makes a lot of sense, as some people still prefer MacPorts or other solutions - and some are perhaps even content with XCode...

Great, thanks! script/compile (currently) has a single arch command, and various labels such as x86_64 that assumes that both GCC and Clang, as well as ALSA, are installed. The label cross is kind of a meta label, that compiles atari-st, web, and $(uname -m). We could add new labels such as mac-arm-homebrew or whatever that does some things that are convenient for it.

@kareandersen
Copy link
Contributor

Great, thanks! script/compile (currently) has a single arch command, and various labels such as x86_64 that assumes that both GCC and Clang, as well as ALSA, are installed. The label cross is kind of a meta label, that compiles atari-st, web, and $(uname -m). We could add new labels such as mac-arm-homebrew or whatever that does some things that are convenient for it.

mac-arm-homebrew-portaudio ;) - hmm, or would it be more appropriate to add dimensions to the arches?

@frno7
Copy link
Owner Author
frno7 commented Apr 9, 2025

mac-arm-homebrew-portaudio ;) - hmm, or would it be more appropriate to add dimensions to the arches?

Admittedly, I haven’t put much thought into it. :-) But yeah, the most important thing, I think, is to keep the Makefiles as tidy as we can, and lift hardcoded and convenience stuff outside in scripts. I don’t known if arch as an argument to script/compile is especially relevant anymore, as it once was. Another alternative could be a new script/compile-mac or somesuch. Let’s think about it a bit.

@kareandersen
Copy link
Contributor

<...> I don’t known if arch as an argument to script/compile is especially relevant anymore, as it once was. Another alternative could be a new script/compile-mac or somesuch. Let’s think about it a bit.

Yup. I'll hack something up later in another branch/PR and then you can dissect it in any way you see fit. Hopefully you are enjoying this too :)

8000

@frno7
Copy link
Owner Author
frno7 commented Apr 9, 2025

Yup. I'll hack something up later in another branch/PR and then you can dissect it in any way you see fit. Hopefully you are enjoying this too :)

Does Mac OS has something similar to package scripts? Examples:

  • I’ve made media-sound/psgplay ebuilds for Gentoo. The USE flag alsa controls whether ALSA should be on or off. They also support cross-compilation, so if one’s Gentoo runs on POWER9, they can cross-compile packages for ARM, for instance. The ebuilds currently come in three flavours, versions 0.6 and 0.7 (which are Git repo tags), and 9999 which means Git HEAD for Gentoo.
  • Someone has also made psgplay package for Arch Linux. Its PKGBUILD source is fairly simple too.
  • Wouldn’t it be nice with something like that for the Mac too? :-)

@kareandersen
Copy link
Contributor

Does Mac OS has something similar to package scripts? Examples:

Homebrew has formulae and is afaik the most common way of having a real Unix-like experience on macOS. It can be installed on Linux too. I will make such a Formula, it can be hosted decentralized (on github for example).

MacPorts has something similar to the BSD port trees. I used that a long time ago, but I now prefer the more GNU/Linux like experience of Homebrew. Other people may disagree, macOS userland is originally based on BSD (and Next), but I really see no reason to go back...

I rock Arch on my x86_64 machines - so I will pull that AUR :) Gentoo brings back fond memories but it's been a while!

  • Wouldn’t it be nice with something like that for the Mac too? :-)

No doubt. Both solutions can provide both binary and source builds, and the source builds are especially useful considering Apple's shift to signed software and the notarization system (which has a $99 yearly price tag on the certificate)

@frno7 frno7 merged commit ddd620b into main Apr 10, 2025
6 checks passed
@frno7
Copy link
Owner Author
frno7 commented Apr 10, 2025

Homebrew has formulae and is afaik the most common way of having a real Unix-like experience on macOS. It can be installed on Linux too. I will make such a Formula, it can be hosted decentralized (on github for example).

Great!

I rock Arch on my x86_64 machines - so I will pull that AUR :)

I just added a link in README.md to the Arch Linux package.

Gentoo brings back fond memories but it's been a while!

Cross-compilation with Gentoo is awesome, I think. With its crossdev package installed, obtaining an m68k compiler is just crossdev --stage1 --target m68k-elf, and that’s it, ready to compile code for the Atari ST. The whole thing is very simple to script too. I use crossdev for all kinds of cross-compilers, for MIPS, ARM, etc. etc.

I’ve merged to the main branch our progress so far on the Mac OS Makefile support up to commit ddd620b. I’ve also added a rationale for the audio buffer timings in commit 7997183, based on the discussion we had about it.

@frno7 frno7 deleted the macos branch April 10, 2025 07:06
@kareandersen
Copy link
Contributor

Thanks alot! Moving on to the next one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0