65 lines
3.6 KiB
Makefile
65 lines
3.6 KiB
Makefile
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
# See LICENSE.md for license information.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# macOS build rules (make macos): JoeyLib programs as Mac apps, through the
|
|
# hosted core and its SDL3 backend (src/hosted, src/hosted/sdl3), built on
|
|
# Linux. The rules are make/hosted.mk's; this file says what is macOS's. A
|
|
# project reaches it through make/project.mk.
|
|
#
|
|
# Built with make/support/macos/cc.sh: zig for Apple silicon and for Intel,
|
|
# against the Apple SDK, the two joined into universal files that run on
|
|
# either (macOS 13 or newer). Programs link the universal static SDL3 the
|
|
# installer builds (SDL3_MACOS_DIR), so they run without an SDL3 on the Mac.
|
|
# A program is an app, bin/NAME.app, with the program in Contents/MacOS and
|
|
# its DATA and icon in Contents/Resources, its folder, which the port makes
|
|
# the current directory when the window opens (SAVES/ and joeylog.txt go in
|
|
# the user's Application Support folder: src/hosted/sdl3/sdl3Backend.c). The
|
|
# app's identifier is MACOS_ID_PREFIX, a reverse-DNS name of the project's
|
|
# own, and the program's name; the project must set it. The Apple silicon
|
|
# half is signed ad hoc as zig links it, which macOS needs to run it at all.
|
|
|
|
PLATFORM := macos
|
|
include $(dir $(lastword $(MAKEFILE_LIST)))/common.mk
|
|
|
|
SDL3_MACOS_LIB := $(SDL3_MACOS_DIR)/lib/libSDL3.a
|
|
$(call requireTool,$(ZIG),toolchain:macos)
|
|
$(call requireTool,$(MACOS_LIBTOOL),toolchain:macos)
|
|
$(call requireTool,$(SDL3_MACOS_LIB),toolchain:macos)
|
|
|
|
SDL3_MACOS_PKG_CONFIG := PKG_CONFIG_LIBDIR=$(SDL3_MACOS_DIR)/lib/pkgconfig pkg-config
|
|
MACOS_SUPPORT := $(REPO_DIR)/make/support/macos
|
|
|
|
# LLVM's libtool archives the universal objects (it warns that audio.o and
|
|
# input.o are named twice, src/core's and src/hosted's, and keeps both).
|
|
HOSTED_CC := $(MACOS_SUPPORT)/cc.sh
|
|
HOSTED_AR := $(MACOS_LIBTOOL)
|
|
HOSTED_ARFLAGS := -static -o
|
|
HOSTED_BACKEND := sdl3
|
|
HOSTED_DEFINES := -DJOEYLIB_PLATFORM_HOSTED -DJOEYLIB_HOSTED_SDL3 -DJOEYLIB_HOSTED_POSIX_SERIAL
|
|
HOSTED_SDK_CFLAGS := $(shell $(SDL3_MACOS_PKG_CONFIG) --cflags sdl3)
|
|
HOSTED_LINK := $(shell $(SDL3_MACOS_PKG_CONFIG) --static --libs sdl3) -Wl,-dead_strip
|
|
PROGRAM_EXT :=
|
|
# A program is relinked when SDL changes, and with it repacked when the
|
|
# packing does.
|
|
HOSTED_PROGRAM_DEPS := $(SDL3_MACOS_LIB) $(MACOS_SUPPORT)/packApp.sh
|
|
|
|
# One program's app, $(1) its id: in bin/ (or ID_BINDIR), never in a folder
|
|
# of its own (an app is one). Its folder is the app's Contents/Resources,
|
|
# where its DATA goes, and SDL's base path for it.
|
|
macosApp = $(or $(call programVar,$(1),BINDIR),$(BINDIR))/$(call programName,$(1)).app
|
|
programDir = $(call macosApp,$(1))/Contents/Resources
|
|
programBin = $(call macosApp,$(1))/Contents/MacOS/$(call programName,$(1))
|
|
|
|
# Linked outside the app, which then gets a copy: the dependency file stays
|
|
# out of it. By the id, which a probe build (ID_BINDIR) does not share with
|
|
# the program of its name.
|
|
HOSTED_LINK_OUT = $(PROGRAM_BUILD)/link/$(1)
|
|
# Its identifier: the project's prefix and its name.
|
|
macosId = $(call requireSet,MACOS_ID_PREFIX,the start of its apps' identifiers$(comma) a reverse-DNS name of the project's own (com.example.games))$(MACOS_ID_PREFIX).$(call programName,$(1))
|
|
HOSTED_PACK = $(MACOS_SUPPORT)/packApp.sh $(call HOSTED_LINK_OUT,$(1)) $(call macosApp,$(1)) $(call macosId,$(1)) $(call shellQuote,$(or $(call programVar,$(1),TITLE),$(call programName,$(1))))
|
|
# Its icon is the app's (Finder, the Dock), not the window's.
|
|
HOSTED_ICON = $(call programDir,$(1))/icon.icns
|
|
HOSTED_ICON_BAKE = $(ICON_BAKE) icns $(call programIcon,$(1)) $(call HOSTED_ICON,$(1))
|
|
|
|
include $(REPO_DIR)/make/hosted.mk
|