Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Commit

Permalink
Improve the makefile
Browse files Browse the repository at this point in the history
- more precise selection of signer certificate
- shared targets for signed and unsigned parts
- should work with parallel builds
- uses CURDIR instead of PWD
  • Loading branch information
martinpaljak committed Jan 3, 2017
1 parent 2ef8613 commit 44684d1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
62 changes: 30 additions & 32 deletions Makefile
Expand Up @@ -2,64 +2,62 @@
CFLAGS = -mmacosx-version-min=10.11
export CFLAGS

TARGET = $(PWD)/target
BUILDPREFIX = $(PWD)/tmp
TARGET ?= $(CURDIR)/target
BUILDPREFIX ?= $(CURDIR)/tmp
CCIDVER = $(shell cd CCID && git describe --always --tags --long)
SIGNER ?= 9ME8T34MPV

PKG_CONFIG_PATH = $(BUILDPREFIX)/lib/pkgconfig
export PKG_CONFIG_PATH

default:
$(MAKE) clean
$(MAKE) dmg
# SIGNER ?= Martin Paljak
ifneq ($(strip $(SIGNER)),)
PKGSIGN = --sign "Developer ID Installer: $(SIGNER)"
endif

.PHONY: default clean
.NOTPARALLEL default: clean dmg srcdist

pkg: ccid-installer.pkg
dmg: ccid-installer.dmg

clean:
git submodule foreach git clean -dfx
git submodule foreach git reset --hard
rm -rf target build *.pkg *.dmg
rm -rf target tmp *.pkg *.dmg

target:
# Build libusb
LIBUSB = $(BUILDPREFIX)/lib/libusb-1.0.a
BUNDLE = $(TARGET)/usr/local/libexec/SmartCardServices/drivers/ifd-ccid.bundle

$(LIBUSB):
(cd libusb \
&& ./autogen.sh \
&& ./configure --prefix=$(BUILDPREFIX) --disable-dependency-tracking --enable-static --disable-shared \
&& make \
&& make install \
&& $(MAKE) \
&& $(MAKE) install \
)
# Build CCID

$(BUNDLE): $(LIBUSB)
(cd CCID \
&& ./bootstrap \
&& ./MacOSX/configure \
&& make \
&& make install DESTDIR=$(TARGET) \
&& $(MAKE) \
&& $(MAKE) install DESTDIR=$(TARGET) \
)

srcdist:
make -C CCID dist-gzip
$(MAKE) -C CCID dist-gzip
mv CCID/ccid-*.tar.gz $(CCIDVER).tar.gz

ifd-ccid.pkg: target
ifd-ccid.pkg: $(BUNDLE)
test -z "$(SIGNER)" || codesign -f -s "Developer ID Application: $(SIGNER)" $(BUNDLE)
pkgbuild --root $(TARGET) --scripts scripts --identifier org.openkms.mac.ccid --version $(CCIDVER) --install-location / --ownership recommended $@

signed: ifd-ccid.pkg
productbuild --distribution Distribution.xml --package-path . --resources resources --sign "$(SIGNER)" ccid-installer.pkg

ccid-installer.pkg: ifd-ccid.pkg
productbuild --distribution Distribution.xml --package-path . --resources resources $@
productbuild --distribution Distribution.xml --package-path . --resources resources $(PKGSIGN) $@

pkg: ccid-installer.pkg

uninstall.pkg:
pkgbuild --nopayload --identifier org.openkms.mac.ccid.uninstall --scripts uninstaller-scripts $@
uninstall.pkg: uninstaller-scripts/postinstall
pkgbuild --nopayload --identifier org.openkms.mac.ccid.uninstall --scripts uninstaller-scripts $(PKGSIGN) $@

ccid-installer.dmg: ccid-installer.pkg uninstall.pkg
hdiutil create -ov -srcfolder uninstall.pkg -srcfolder ccid-installer.pkg -volname "CCID installer ($(CCIDVER))" $@

dmg: ccid-installer.dmg

dmgsign: ccid-installer.dmg
codesign -s "$(SIGNER)" ccid-installer.dmg

dist: clean signed dmg dmgsign
cp ccid-installer.dmg ccid-installer-signed.dmg
test -z "$(SIGNER)" || codesign -f -s "Developer ID Application: $(SIGNER)" $@
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -14,7 +14,8 @@ Because of [OSX bugs](http://ludovicrousseau.blogspot.com/2016/04/os-x-el-capita
#### Development
* To build a signed release:
```
make dist SIGNER="XXXXXXXXXX"
make SIGNER="XXX"
```
* where `XXXXXXXXXX` is a [Developer ID](https://developer.apple.com/developer-id/), such as `9ME8T34MPV`.
* where `XXX` is the personal part of a [Developer ID](https://developer.apple.com/developer-id/) certificate common name, such as `Martin Paljak`
or `Martin Paljak (9ME8T34MPV)`
* You can list your ID-s with `security find-identity -v -p codesigning`

0 comments on commit 44684d1

Please sign in to comment.