Skip to content

Commit d5af716

Browse files
author
Dan Wilcox
committed
added pd external example, updated to mac-dist-helpers 0.3.0, fleshed out readme
1 parent 92d6c4d commit d5af716

18 files changed

+1548
-69
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
21
# macOS
32
.DS_Store

HelloOF/.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# TODO please fill me
22

33
config.make
4-
export
4+
5+
# mac-dist-helper
56
dist
7+
*.zip
8+
*.dmg
69

710
# model
811
bin/data/model

HelloOF/HelloOF.entitlements

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict/>
5+
</plist>

HelloOF/Makefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ endif
1212
# call the project makefile!
1313
include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
1414

15-
##### mac-dist-helpers
15+
##### Makefile-mac-dist.mk
1616

1717
# app name to build
1818
mac.app.name = HelloOF
@@ -26,10 +26,13 @@ mac.app.project.scheme = $(mac.app.name) Release
2626
# include openFrameworks project data
2727
mac.dist.include = bin/data
2828

29+
# add link to /Applications in dmg
30+
mac.dmg.appslink = true
31+
2932
# codesign identity, usually a Developer ID Application string
3033
# REPLACE this with your own or set it via the commandline:
3134
# make app distdmg mac.codesign.identity="Foo Bar Baz Developers"
3235
mac.codesign.identity = ZKM | Zentrum fuer Kunst und Medientechnologie Karlsruhe
3336

34-
include ../mac-dist-helpers/Makefile-mac-app.mk
35-
include ../mac-dist-helpers/Makefile-mac-dist.mk
37+
MACDISTHELPER_DIR=../mac-dist-helper
38+
include $(MACDISTHELPER_DIR)/Makefile-mac-dist.mk

HelloWorld/.gitignore

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
2-
# mac-dist-helpers
3-
export
1+
# mac-dist-helper
42
dist
5-
6-
# packages
73
*.zip
84
*.dmg
95

HelloWorld/HelloWorld/AppDelegate.swift

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ import Cocoa
1010
@main
1111
class AppDelegate: NSObject, NSApplicationDelegate {
1212

13-
14-
15-
1613
func applicationDidFinishLaunching(_ aNotification: Notification) {
1714
// Insert code here to initialize your application
1815
}
@@ -25,6 +22,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
2522
return true
2623
}
2724

28-
25+
// single window app
26+
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
27+
return true
28+
}
2929
}
30-

HelloWorld/Makefile

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
# app name to build (no extension) for Makefile-mac-app.mk
1+
# app name to build (no extension)
22
mac.app.name = HelloWorld
33

4-
# dist name and app for Makefile-mac-dist.mk,
5-
# define these if not using Makefile-mac-app.mk
6-
#mac.dist.name = HelloWorld
7-
#mac.dist.apps = $(mac.dist.name).app
8-
94
# pull version string from project, this is slow...
105
#mac.dist.version := $(shell xcodebuild -showBuildSettings 2> /dev/null | grep MARKETING_VERSION | tr -d 'MARKETING_VERSION =')
11-
126
# ... or set it manually
137
mac.dist.version = 0.1.0
148

15-
# additional files to add to distribution?
16-
#mac.dist.include = README.txt
9+
# additional files to add to distribution
10+
mac.dist.include = README.txt
11+
12+
# add link to /Applications in dmg
13+
mac.dmg.appslink = true
1714

1815
# codesign identity, usually a Developer ID Application string
1916
# REPLACE this with your own or set it via the commandline:
2017
# make app distdmg mac.codesign.identity="Foo Bar Baz Developers"
2118
mac.codesign.identity = ZKM | Zentrum fuer Kunst und Medientechnologie Karlsruhe
2219

23-
include ../mac-dist-helpers/Makefile-mac-app.mk
24-
include ../mac-dist-helpers/Makefile-mac-dist.mk
20+
MACDISTHELPER_DIR=../mac-dist-helper
21+
include $(MACDISTHELPER_DIR)/Makefile-mac-dist.mk
2522

26-
mac.dmg.name=$(mac.dist.name.version)-macos-$(shell uname -m)
27-
mac.zip.name=$(mac.dist.name.version)-macos-$(shell uname -m)
23+
# for completeness
24+
.PHONY: clean
25+
clean:

README.md

+40-27
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mac-dist-helper-examples
22
========================
33

4-
Example projects for the [mac-dist-helper Makefiles](https://github.com/zkmkarlsruhe/mac-dist-helper) which automate packaging macOS binaries for distribution
4+
Example projects for the [mac-dist-helper Makefile](https://github.com/zkmkarlsruhe/mac-dist-helper) which automates packaging macOS binaries for distribution
55

66
This code base has been developed by [ZKM | Hertz-Lab](https://zkm.de/en/about-the-zkm/organization/hertz-lab) as part of the project [»The Intelligent Museum«](#the-intelligent-museum).
77

@@ -15,6 +15,12 @@ WARRANTIES, see the file, "LICENSE.txt," in this distribution.
1515

1616
Inspired by the [Hello World](https://github.com/pure-data/helloworld) Pure Data external using pd-lib-builder.
1717

18+
19+
https://www.synack.com/blog/untranslocating-apps/
20+
https://proinsias.github.io/til/Mac-Remove-quarantine-flag-from-app/
21+
https://wiki.lazarus.freepascal.org/Code_Signing_for_macOS
22+
https://wiki.lazarus.freepascal.org/Notarization_for_macOS_10.14.5%2B
23+
1824
Quick Start
1925
-----------
2026

@@ -25,40 +31,49 @@ git clone [email protected]:zkmkarlsruhe/mac-dist-helper-examples.git
2531
git submodule update --init --recursive
2632
```
2733

28-
Next, make sure all requirements are setup: [mac-dist-helper requirements](https://github.com/zkmkarlsruhe/mac-dist-helper#requirements)
34+
Next, make sure all requirements are set up: [mac-dist-helper requirements](https://github.com/zkmkarlsruhe/mac-dist-helper#requirements)
2935

3036
Examples
3137
--------
3238

33-
These are very basic instructions to buiild both the examples and distribution images. For details, see the [mac-dist-helper readme](https://github.com/zkmkarlsruhe/mac-dist-helper).
39+
These are very basic instructions to build both the examples and distribution images. For details, see the [mac-dist-helper readme](https://github.com/zkmkarlsruhe/mac-dist-helper).
40+
41+
* **HelloWorld**: simple Cocoa app
42+
* **HelloOF**: [openFrameworks](https://openframeworks.cc) macOS application
43+
* **hello**: simple console program with a bundled dynamic library
44+
* **hellopd**: [Pure Data](https://pure-data.info) C external library
3445

35-
* HelloWorld: simple Cocoa .app bundle
36-
* HelloOF: [openFrameworks](https://openframeworks.cc) macOS app
37-
* hello: simple console program with a bundled dynamic library
38-
* hellopd: [Pure Data](https://pure-data.info) C external
46+
To do a full clean on any example:
47+
48+
```shell
49+
make clean dist-clean dist-clobber
50+
```
3951

4052
### HelloWorld
4153

4254
![media/helloworld-screenshot.png]
4355

56+
This is a basic single-window Cocoa application.
57+
4458
In the Xcode project Signing & Capabilities settings:
4559
* enable Automatically manage signing for Release and set the team
46-
* enable Hardened Runtime, if not set (default for Xcode 14+)
60+
* enable Hardened Runtime, if not set
4761

4862
Next, set the codesign identity in `HelloWorld/Makefile`.
4963

50-
Create a signed & notarized distribution `.dmg` disk image with:
64+
Create a signed & notarized distribution `dmg` disk image with:
5165

5266
```shell
5367
cd HelloWorld
54-
make app
55-
make distdmg
68+
make app dist-dmg
5669
```
5770

5871
### HelloOF
5972

6073
![media/helloof-screenshot.png]
6174

75+
This is an [openFrameworks](https://openframeworks.cc) application with an external `data` folder.
76+
6277
The Xcode project file is not included so you will need to generate it using the OF ProjectGenerator which is included with the openFrameworks distribution.
6378

6479
To (re)generate the Xcode project:
@@ -69,7 +84,7 @@ To (re)generate the Xcode project:
6984

7085
Additionally, in the Xcode project Signing & Capabilities settings:
7186
* enable Automatically manage signing for Release and set the team
72-
* enable Hardened Runtime, if not set (default for Xcode 14+)
87+
* enable Hardened Runtime, if not set
7388

7489
Next, set the codesign identity in `HelloOF/Makefile`.
7590

@@ -79,42 +94,41 @@ Before building for distribution, make sure the OF lib itself is built by buildi
7994

8095
```shell
8196
cd HelloOF
82-
make app
83-
make distdmg
97+
make all app dist-dmg
8498
```
8599

86100
### hello
87101

88102
![media/hello-screenshot.png]
89103

104+
This is a C console program which links to a custom dynamic library. Both binaries need to be signed "in place" then packaged and notarized.
105+
90106
Before starting, set the codesign identity in `hello/Makefile`.
91107

108+
When building, the following extra steps are performed for distribution:
109+
* an Info.plist is embedded in each program executable using `-sectcreate TEXT`
110+
* the dynamic lib loading paths are set to `@executable_path` using `install_name_tool`
111+
92112
Build for distribution with:
93113

94114
```shell
95115
cd hello
96-
make
97-
make dist codesign distdmg
98-
```
99-
100-
The separate `dist` and `codesign` targets are important to call before `distdmg` if the program is built without Xcode, so code signing needs to be performed manually on the binaries in the `dist` temp directory before creating a dmg or zip.
101-
102-
If encountering errors, do a full clean with:
103-
104-
```shell
105-
make clean distclean distclobber
116+
make all dist-dmg
106117
```
107118

108119
### hellopd
109120

110121
![media/hellopd-screenshot.png]
111122

123+
This is a [Pure Data](https://pure-data.info) external library which is build using the [pd-lib-builder](https://github.com/pure-data/pd-lib-builder) makefile. The `pd_darwin` file (renamed dylib) needs to be signed then packaged and notarized.
124+
125+
Before starting, set the codesign identity in `hello/Makefile`.
126+
112127
Build for distribution with:
113128

114129
```shell
115130
cd hellopd
116-
make
117-
make dist codesign distdmg
131+
make all dist-dmg
118132
```
119133

120134
The Intelligent Museum
@@ -127,4 +141,3 @@ The [ZKM | Center for Art and Media](https://zkm.de/en) and the [Deutsches Museu
127141
As part of the project, digital curating will be critically examined using various approaches of digital art. Experimenting with new digital aesthetics and forms of expression enables new museum experiences and thus new ways of museum communication and visitor participation. The museum is transformed to a place of experience and critical exchange.
128142

129143
![Logo](media/Logo_ZKM_DMN_KSB.png)
130-

hello/.gitignore

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
# c
1+
# build
2+
hello
23
*.o
34

4-
# mac-dist-helpers
5-
export
5+
# mac-dist-helper
66
dist
7-
8-
# packages
97
*.zip
108
*.dmg
119

hello/Makefile

+40-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11

22
VERSION = 0.1.0
33

4-
CFLAGS = -I./ -mmacosx-version-min=10.9
4+
CFLAGS = -I./
55
LDFLAGS = -L./
66

7-
.PHONY: libgreet rpath rpath-check clean
7+
PLATFORM=$(shell uname -s)
8+
ifeq ($(PLATFORM), Darwin)
9+
CFLAGS += -mmacosx-version-min=10.9
10+
endif
811

9-
all: libgreet hello rpath
12+
.PHONY: libgreet libpaths checklibpaths clean
13+
14+
all: libgreet hello libpaths
1015

1116
##### libgreet
1217

@@ -24,15 +29,21 @@ HELLO = hello
2429
HELLO_FILES = hello.c
2530
HELLO_LDFLAGS = -lgreet
2631

32+
ifeq ($(PLATFORM), Darwin)
2733
# add Info.plist contents for notarization
28-
HELLO_LDFLAGS += -sectcreate TEXT info_plist Info.plist -I.
34+
HELLO_LDFLAGS += -sectcreate TEXT info_plist Info.plist
35+
endif
2936

3037
hello: ${HELLO_FILES:.c=.o}
3138
$(CC) -o $@ $^ $(LDFLAGS) $(HELLO_LDFLAGS)
3239

3340
##### libpaths
3441

35-
# disambiguate dynamic lib paths
42+
.PHONY: libpaths checklibpaths
43+
44+
ifeq ($(PLATFORM), Darwin)
45+
46+
# disambiguate dynamic lib paths, required to run on other systems
3647
libpaths:
3748
install_name_tool -id @executable_path/$(LIBGREET) $(LIBGREET)
3849
install_name_tool -change $(LIBGREET) @executable_path/$(LIBGREET) $(HELLO)
@@ -41,26 +52,47 @@ libpaths:
4152
checklibpaths:
4253
otool -L $(LIBGREET) $(HELLO)
4354

55+
# Windows, Linux
56+
else
57+
58+
libpaths:
59+
60+
checklibpaths:
61+
62+
endif
63+
4464
##### clean
4565

4666
clean:
4767
rm -f *.o $(HELLO) $(LIBGREET)
4868

49-
##### mac-dist-helpers
69+
##### Makefile-mac-dist.mk
5070

71+
# base disttribution name
5172
mac.dist.name = hello
73+
74+
# console programs
5275
mac.dist.progs = $(HELLO)
76+
77+
# dynamic libraries (.dylib)
5378
mac.dist.libs = $(LIBGREET)
5479

5580
mac.dist.version = $(VERSION)
81+
82+
# additional files to add to distribution
5683
mac.dist.include = README.txt
5784

85+
# add link to /Applications in dmg
86+
mac.dmg.appslink = false
87+
5888
# codesign identity, usually a Developer ID Application string
5989
# REPLACE this with your own or set it via the commandline:
6090
# make app distdmg mac.codesign.identity="Foo Bar Baz Developers"
6191
mac.codesign.identity = ZKM | Zentrum fuer Kunst und Medientechnologie Karlsruhe
6292

63-
# specify optional entitlements for codesigning, ie. disable dynamic library validation, etc
93+
# specify optional entitlements for codesigning
94+
# ie. to disable dynamic library validation, etc
6495
#mac.codesign.entitlements = hello.entitlements
6596

66-
include ../mac-dist-helpers/Makefile-mac-dist.mk
97+
MACDISTHELPER_DIR=../mac-dist-helper
98+
include $(MACDISTHELPER_DIR)/Makefile-mac-dist.mk

hello/hello

-48.8 KB
Binary file not shown.

hellopd/.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# mac-dist-helper
2+
dist
3+
*.zip
4+
*.dmg
5+
6+
# builds
7+
*.pd_linux
8+
*.pd_darwin
9+
*.dll
10+
*.o
11+
*.so
12+
*.dylib

0 commit comments

Comments
 (0)