Skip to content

Commit a8960c6

Browse files
committed
install: Sign installed executables if running macOS on Apple silicon
Signed-off-by: Jafar Al-Gharaibeh <to.jafar@gmail.com>
1 parent 1d5434c commit a8960c6

File tree

6 files changed

+46
-10
lines changed

6 files changed

+46
-10
lines changed

Makedefs.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ O=@OBJ@
6363
UOS=@unicon_os@
6464
OSDIST=@unicon_osdist@
6565
OSREL=@unicon_osrel@
66+
UNICONCPU=@unicon_cpu@
67+
UNICONHOST=@unicon_host@
6668

6769
# commands
6870
SHELL = /bin/sh

Makedefs.uni.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
UNIOS=@unicon_os@
33
UNIOSDIST=@unicon_osdist@
44
UNIOSREL=@unicon_osrel@
5+
UNICONCPU=@unicon_cpu@
6+
UNICONHOST=@unicon_host@
57

68
EXE=@EXE@
79
GRAPHICS=@GRAPHICS@

Makefile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,15 @@ UIPL=$(ULROT)/ipl
203203
UPLUGINS=$(ULROT)/plugins/lib
204204
INST=$(SHTOOL) install -c
205205
F=*.{u,icn}
206-
Tbins=unicon$(EXE) icont$(EXE) iconx$(EXE) iconc$(EXE) unicont$(EXE) uniconx$(EXE) \
207-
uniconc$(EXE) udb$(EXE) uprof$(EXE) unidep$(EXE) unidoc$(EXE) ui$(EXE) ivib$(EXE) \
208-
ulsp$(EXE) patchstr$(EXE) iyacc$(EXE) rt.a rt.h
206+
207+
# runtime binaries, variants of iconx, icont, and iconc
208+
RTbins=$(UNICONX)$(EXE) | $(UNICONWX)$(EXE) | $(UNICONT)$(EXE) | $(UNICONWT)$(EXE) | $(UNICONC)$(EXE)
209+
ADDONbins=udb$(EXE) uprof$(EXE) unidep$(EXE) unidoc$(EXE) ui$(EXE) ivib$(EXE) ulsp$(EXE)
210+
UTILbins=$(PATCHSTR) iyacc$(EXE)
211+
ALLbins=$(RTbins) unicon$(EXE) $(ADDONbins) $(UTILbins) rt.a rt.h
212+
# binaries that should be signed after install, only needed on arm macOS for now
213+
SIGNbins=$(RTbins) $(UTILbins)
214+
209215
Tdirs=$(DESTDIR)$(ULB) $(DESTDIR)$(UIPL) $(DESTDIR)$(UPLUGINS)
210216
Udirs=lib 3d gui unidoc unidep xml parser ulsp
211217
IPLdirs=lib incl gincl mincl procs
@@ -218,7 +224,7 @@ uninstall Uninstall:
218224
rm -rf $$d; \
219225
done
220226
# delete the binaries we installed from unicon/bin
221-
@for f in $(Tbins); do \
227+
@for f in $(ALLbins); do \
222228
echo "Uninstalling $(DESTDIR)$(bindir)/$$f ..."; \
223229
rm -f $(DESTDIR)$(bindir)/$$f; \
224230
done
@@ -241,7 +247,7 @@ install Install:
241247
(echo "Creating dir $(DESTDIR)$(ULB)/$$d") && (mkdir -p $(DESTDIR)$(ULB)/$$d); \
242248
done
243249
# install unicon/bin
244-
@for f in $(Tbins); do \
250+
@for f in $(ALLbins); do \
245251
if test -f "bin/$$f"; then \
246252
(echo "Installing bin/$$f") && ($(INST) bin/$$f $(DESTDIR)$(bindir)); \
247253
if test "$$f" = $(UNICONT)$(EXE) ; then \
@@ -281,6 +287,13 @@ install Install:
281287
@$(INST) -m 644 README.md $(DESTDIR)$(docdir)
282288
@echo "Installing $(DESTDIR)$(docdir) ..."
283289
@$(INST) -m 644 doc/unicon/*.* $(DESTDIR)$(docdir)
290+
# Sign code if we are running MacOS on Apple's processors
291+
if test "$(UNICONHOST)" = "arm_64_macos"; then \
292+
for f in $(SIGNbins); do \
293+
echo signing $(DESTDIR)$(bindir)/$$f ; \
294+
codesign -s - $(DESTDIR)$(bindir)/$$f ;\
295+
done;; \
296+
fi
284297

285298
# Bundle up for binary distribution.
286299
PKGDIR=$(PKG_TARNAME).$(PKG_VERSION)

Makefile.in

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,15 @@ UIPL=$(ULROT)/ipl
203203
UPLUGINS=$(ULROT)/plugins/lib
204204
INST=$(SHTOOL) install -c
205205
F=*.{u,icn}
206-
Tbins=unicon$(EXE) icont$(EXE) iconx$(EXE) iconc$(EXE) unicont$(EXE) uniconx$(EXE) \
207-
uniconc$(EXE) udb$(EXE) uprof$(EXE) unidep$(EXE) unidoc$(EXE) ui$(EXE) ivib$(EXE) \
208-
ulsp$(EXE) patchstr$(EXE) iyacc$(EXE) rt.a rt.h
206+
207+
# runtime binaries, variants of iconx, icont, and iconc
208+
RTbins=$(UNICONX)$(EXE) $(UNICONWX)$(EXE) $(UNICONT)$(EXE) $(UNICONWT)$(EXE) $(UNICONC)$(EXE)
209+
ADDONbins=udb$(EXE) uprof$(EXE) unidep$(EXE) unidoc$(EXE) ui$(EXE) ivib$(EXE) ulsp$(EXE)
210+
UTILbins=$(PATCHSTR) iyacc$(EXE)
211+
ALLbins=$(RTbins) unicon$(EXE) $(ADDONbins) $(UTILbins) rt.a rt.h
212+
# binaries that should be signed after install, only needed on arm macOS for now
213+
SIGNbins=$(RTbins) $(UTILbins)
214+
209215
Tdirs=$(DESTDIR)$(ULB) $(DESTDIR)$(UIPL) $(DESTDIR)$(UPLUGINS)
210216
Udirs=lib 3d gui unidoc unidep xml parser ulsp
211217
IPLdirs=lib incl gincl mincl procs
@@ -218,7 +224,7 @@ uninstall Uninstall:
218224
rm -rf $$d; \
219225
done
220226
# delete the binaries we installed from unicon/bin
221-
@for f in $(Tbins); do \
227+
@for f in $(ALLbins); do \
222228
echo "Uninstalling $(DESTDIR)$(bindir)/$$f ..."; \
223229
rm -f $(DESTDIR)$(bindir)/$$f; \
224230
done
@@ -241,7 +247,7 @@ install Install:
241247
(echo "Creating dir $(DESTDIR)$(ULB)/$$d") && (mkdir -p $(DESTDIR)$(ULB)/$$d); \
242248
done
243249
# install unicon/bin
244-
@for f in $(Tbins); do \
250+
@for f in $(ALLbins); do \
245251
if test -f "bin/$$f"; then \
246252
(echo "Installing bin/$$f") && ($(INST) bin/$$f $(DESTDIR)$(bindir)); \
247253
if test "$$f" = $(UNICONT)$(EXE) ; then \
@@ -281,6 +287,13 @@ install Install:
281287
@$(INST) -m 644 README.md $(DESTDIR)$(docdir)
282288
@echo "Installing $(DESTDIR)$(docdir) ..."
283289
@$(INST) -m 644 doc/unicon/*.* $(DESTDIR)$(docdir)
290+
# Sign code if we are running MacOS on Apple's processors
291+
if test "$(UNICONHOST)" = "arm_64_macos"; then \
292+
for f in $(SIGNbins); do \
293+
echo signing $(DESTDIR)$(bindir)/$$f ; \
294+
codesign -s - $(DESTDIR)$(bindir)/$$f ;\
295+
done;; \
296+
fi
284297

285298
# Bundle up for binary distribution.
286299
PKGDIR=$(PKG_TARNAME).$(PKG_VERSION)

configure

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,8 @@ LDDYN
678678
CFDYN
679679
RLIBS
680680
RLINK
681+
unicon_host
682+
unicon_cpu
681683
unicon_osrel
682684
unicon_osdist
683685
unicon_os
@@ -7944,6 +7946,8 @@ fi
79447946

79457947

79467948

7949+
7950+
79477951

79487952

79497953

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ AC_SUBST(BITS)
474474
AC_SUBST(unicon_os)
475475
AC_SUBST(unicon_osdist)
476476
AC_SUBST(unicon_osrel)
477+
AC_SUBST(unicon_cpu)
478+
AC_SUBST(unicon_host)
477479

478480
AC_SUBST(CC)
479481
AC_SUBST(RLINK)

0 commit comments

Comments
 (0)