| 1 | BUILDHOME = $(PWD) |
|---|
| 2 | SCAVERSION = 0.3.0-pre3 |
|---|
| 3 | OPENSCVERSION = 0.11.13 |
|---|
| 4 | OPENSSHVERSION = 5.3p1 |
|---|
| 5 | LIBP11VERSION = 0.2.7 |
|---|
| 6 | ENGINEVERSION = 0.1.8 |
|---|
| 7 | PKGCONFIGVERSION = 0.23 |
|---|
| 8 | PACKAGEMAKER = /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker |
|---|
| 9 | |
|---|
| 10 | all: sca-$(SCAVERSION).dmg |
|---|
| 11 | clean: clean-pkg-config clean-opensc clean-libp11 clean-engine clean-openssh |
|---|
| 12 | |
|---|
| 13 | clean-pkg-config: |
|---|
| 14 | rm -rf pkg-config |
|---|
| 15 | rm -rf compiled-pkg-config |
|---|
| 16 | rm -f fetch-pkg-config build-pkg-config |
|---|
| 17 | |
|---|
| 18 | clean-opensc: |
|---|
| 19 | rm -rf opensc |
|---|
| 20 | rm -rf compiled-opensc |
|---|
| 21 | rm -f fetch-opensc build-opensc install-opensc |
|---|
| 22 | |
|---|
| 23 | clean-libp11: |
|---|
| 24 | rm -rf libp11 |
|---|
| 25 | rm -rf compiled-libp11 |
|---|
| 26 | rm -f fetch-libp11 build-libp11 install-libp11 |
|---|
| 27 | |
|---|
| 28 | clean-engine: |
|---|
| 29 | rm -rf engine_pkcs11 |
|---|
| 30 | rm -rf compiled-engine |
|---|
| 31 | rm -f fetch-engine build-engine install-engine |
|---|
| 32 | |
|---|
| 33 | clean-openssh: |
|---|
| 34 | rm -rf openssh |
|---|
| 35 | rm -rf compiled-openssh |
|---|
| 36 | rm -f fetch-openssh build-openssh install-openssh |
|---|
| 37 | |
|---|
| 38 | clean-sca: |
|---|
| 39 | rm -f sca-$(SCAVERSION).dmg* |
|---|
| 40 | rm -rf sca.mpkg |
|---|
| 41 | |
|---|
| 42 | dist: sca-$(SCAVERSION).dmg |
|---|
| 43 | |
|---|
| 44 | sca-$(SCAVERSION).dmg: package |
|---|
| 45 | rm -rf sca.mpkg |
|---|
| 46 | cp -R sca_orig.mpkg sca.mpkg |
|---|
| 47 | cp -R OpenSC.pkg sca.mpkg/Contents/Packages/ |
|---|
| 48 | cp -R libp11.pkg sca.mpkg/Contents/Packages/ |
|---|
| 49 | cp -R engine_pkcs11.pkg sca.mpkg/Contents/Packages/ |
|---|
| 50 | cp -R openssh.pkg sca.mpkg/Contents/Packages/ |
|---|
| 51 | find sca.mpkg -name '.svn' | xargs rm -rf |
|---|
| 52 | rm -f sca-$(SCAVERSION).dmg |
|---|
| 53 | hdiutil create -srcfolder sca.mpkg -volname "SCA $(SCAVERSION)" sca-$(SCAVERSION).dmg |
|---|
| 54 | hdiutil internet-enable -yes sca-$(SCAVERSION).dmg |
|---|
| 55 | md5 sca-$(SCAVERSION).dmg > sca-$(SCAVERSION).dmg.md5 |
|---|
| 56 | |
|---|
| 57 | pkg-config-$(PKGCONFIGVERSION).tar.gz: |
|---|
| 58 | curl -O http://pkgconfig.freedesktop.org/releases/$@ |
|---|
| 59 | |
|---|
| 60 | opensc-$(OPENSCVERSION).tar.gz: |
|---|
| 61 | curl -O http://www.opensc-project.org/files/opensc/$@ |
|---|
| 62 | #curl -O http://www.opensc-project.org/files/opensc/snapshots/$@ |
|---|
| 63 | # curl -O http://www.opensc-project.org/files/opensc/testing/$@ |
|---|
| 64 | |
|---|
| 65 | libp11-$(LIBP11VERSION).tar.gz: |
|---|
| 66 | curl -O http://www.opensc-project.org/files/libp11/$@ |
|---|
| 67 | |
|---|
| 68 | engine_pkcs11-$(ENGINEVERSION).tar.gz: |
|---|
| 69 | curl -O http://www.opensc-project.org/files/engine_pkcs11/$@ |
|---|
| 70 | |
|---|
| 71 | openssh-$(OPENSSHVERSION).tar.gz: |
|---|
| 72 | #curl -O http://ftp.belnet.be/packages/openbsd/OpenSSH/portable/$@ |
|---|
| 73 | curl -O http://anga.funkfeuer.at/ftp/pub/OpenBSD/OpenSSH/portable/$@ |
|---|
| 74 | |
|---|
| 75 | fetch: fetch-pkg-config fetch-opensc fetch-libp11 fetch-engine fetch-openssh |
|---|
| 76 | |
|---|
| 77 | fetch-pkg-config: pkg-config-$(PKGCONFIGVERSION).tar.gz |
|---|
| 78 | rm -rf pkg-config |
|---|
| 79 | tar xzvf $^ |
|---|
| 80 | mv pkg-config-$(PKGCONFIGVERSION) pkg-config |
|---|
| 81 | touch $@ |
|---|
| 82 | |
|---|
| 83 | fetch-opensc: opensc-$(OPENSCVERSION).tar.gz |
|---|
| 84 | rm -rf opensc |
|---|
| 85 | tar xzvf $^ |
|---|
| 86 | mv opensc-$(OPENSCVERSION) opensc |
|---|
| 87 | touch $@ |
|---|
| 88 | |
|---|
| 89 | fetch-libp11: libp11-$(LIBP11VERSION).tar.gz |
|---|
| 90 | rm -rf libp11 |
|---|
| 91 | tar xzvf $^ |
|---|
| 92 | mv libp11-$(LIBP11VERSION) libp11 |
|---|
| 93 | touch $@ |
|---|
| 94 | |
|---|
| 95 | fetch-engine: engine_pkcs11-$(ENGINEVERSION).tar.gz |
|---|
| 96 | rm -rf engine_pkcs11 |
|---|
| 97 | tar xzvf $^ |
|---|
| 98 | mv engine_pkcs11-$(ENGINEVERSION) engine_pkcs11 |
|---|
| 99 | touch $@ |
|---|
| 100 | |
|---|
| 101 | fetch-openssh: openssh-$(OPENSSHVERSION).tar.gz |
|---|
| 102 | rm -rf openssh |
|---|
| 103 | tar xzvf $^ |
|---|
| 104 | mv openssh-$(OPENSSHVERSION) openssh |
|---|
| 105 | cd openssh && patch -p1 <../opensc/src/openssh/ask-for-pin.diff |
|---|
| 106 | touch $@ |
|---|
| 107 | |
|---|
| 108 | build: build-pkg-config build-opensc build-libp11 build-engine build-openssh |
|---|
| 109 | |
|---|
| 110 | build-pkg-config: fetch-pkg-config |
|---|
| 111 | cd pkg-config && \ |
|---|
| 112 | ./configure --prefix=$(BUILDHOME)/compiled-pkg-config && \ |
|---|
| 113 | make && \ |
|---|
| 114 | make install |
|---|
| 115 | touch $@ |
|---|
| 116 | |
|---|
| 117 | build-opensc: fetch-opensc |
|---|
| 118 | cd opensc && \ |
|---|
| 119 | CFLAGS="-arch x86_64 -arch i386 -arch ppc7400" \ |
|---|
| 120 | LDFLAGS="-arch x86_64 -arch i386 -arch ppc7400" \ |
|---|
| 121 | ./configure --prefix=/Library/OpenSC --enable-pcsc --sysconfdir=/Library/OpenSC/etc --disable-dependency-tracking && \ |
|---|
| 122 | make && \ |
|---|
| 123 | make install prefix=$(BUILDHOME)/compiled-opensc/Library/OpenSC |
|---|
| 124 | touch $@ |
|---|
| 125 | |
|---|
| 126 | build-libp11: fetch-libp11 |
|---|
| 127 | cd libp11 && \ |
|---|
| 128 | CFLAGS="-arch x86_64 -arch i386 -arch ppc7400" \ |
|---|
| 129 | LDFLAGS="-arch x86_64 -arch i386 -arch ppc7400" \ |
|---|
| 130 | ./configure --prefix=/Library/OpenSC --disable-dependency-tracking && \ |
|---|
| 131 | make && \ |
|---|
| 132 | make install prefix=$(BUILDHOME)/compiled-libp11/Library/OpenSC |
|---|
| 133 | touch $@ |
|---|
| 134 | |
|---|
| 135 | build-engine: fetch-engine |
|---|
| 136 | cd engine_pkcs11 && \ |
|---|
| 137 | PKG_CONFIG="$(BUILDHOME)/compiled-pkg-config/bin/pkg-config" \ |
|---|
| 138 | LIBP11_CFLAGS="-I$(BUILDHOME)/compiled-libp11/Library/OpenSC/include" \ |
|---|
| 139 | LIBP11_LIBS="-L$(BUILDHOME)/compiled-libp11/Library/OpenSC/lib -lp11" \ |
|---|
| 140 | CFLAGS="-arch x86_64 -arch i386 -arch ppc7400" \ |
|---|
| 141 | LDFLAGS="-arch x86_64 -arch i386 -arch ppc7400" \ |
|---|
| 142 | ./configure --prefix=/Library/OpenSC --disable-dependency-tracking && \ |
|---|
| 143 | make && \ |
|---|
| 144 | make install prefix=$(BUILDHOME)/compiled-engine/Library/OpenSC |
|---|
| 145 | touch $@ |
|---|
| 146 | |
|---|
| 147 | build-openssh: fetch-openssh |
|---|
| 148 | cd openssh && \ |
|---|
| 149 | LIBS="-lresolv" \ |
|---|
| 150 | CFLAGS="-arch x86_64 -arch i386 -arch ppc7400" \ |
|---|
| 151 | LDFLAGS="-arch x86_64 -arch i386 -arch ppc7400" \ |
|---|
| 152 | ./configure --prefix=/Library/OpenSC --disable-dependency-tracking \ |
|---|
| 153 | --with-opensc=$(BUILDHOME)/compiled-opensc/Library/OpenSC \ |
|---|
| 154 | --without-zlib-version-check \ |
|---|
| 155 | --with-ldflags="-L$(BUILDHOME)/compiled-opensc/Library/OpenSC/lib" && \ |
|---|
| 156 | make && \ |
|---|
| 157 | make install-nokeys prefix=$(BUILDHOME)/compiled-openssh/Library/OpenSC |
|---|
| 158 | mv $(BUILDHOME)/compiled-openssh/Library/OpenSC/share/man $(BUILDHOME)/compiled-openssh/Library/OpenSC/man |
|---|
| 159 | rm -f $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/scp |
|---|
| 160 | rm -f $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/sftp |
|---|
| 161 | rm -f $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/ssh-keyscan |
|---|
| 162 | rm -f $(BUILDHOME)/compiled-openssh/Library/OpenSC/etc/ssh_host* |
|---|
| 163 | rm -f $(BUILDHOME)/compiled-openssh/Library/OpenSC/etc/sshd_config |
|---|
| 164 | rm -rf $(BUILDHOME)/compiled-openssh/Library/OpenSC/libexec |
|---|
| 165 | rm -f $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/scp.1 |
|---|
| 166 | rm -f $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/sftp.1 |
|---|
| 167 | rm -f $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/ssh-keyscan.1 |
|---|
| 168 | rm -f $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man5/sshd_config.5 |
|---|
| 169 | rm -rf $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man8 |
|---|
| 170 | rm -rf $(BUILDHOME)/compiled-openssh/Library/OpenSC/sbin |
|---|
| 171 | mv $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/ssh $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/scssh |
|---|
| 172 | mv $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/ssh-add $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/scssh-add |
|---|
| 173 | mv $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/ssh-agent $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/scssh-agent |
|---|
| 174 | mv $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/ssh-keygen $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/scssh-keygen |
|---|
| 175 | rm -f $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/slogin |
|---|
| 176 | cd $(BUILDHOME)/compiled-openssh/Library/OpenSC/bin/ && ln -s ./scssh scslogin |
|---|
| 177 | mv $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/ssh-add.1 $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/scssh-add.1 |
|---|
| 178 | mv $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/ssh-agent.1 $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/scssh-agent.1 |
|---|
| 179 | mv $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/ssh-keygen.1 $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/scssh-keygen.1 |
|---|
| 180 | mv $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/ssh.1 $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/scssh.1 |
|---|
| 181 | rm -f $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/slogin.1 |
|---|
| 182 | cd $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man1/ && ln -s ./scssh.1 scslogin.1 |
|---|
| 183 | mv $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man5/ssh_config.5 $(BUILDHOME)/compiled-openssh/Library/OpenSC/man/man5/scssh_config.5 |
|---|
| 184 | touch $@ |
|---|
| 185 | |
|---|
| 186 | install: |
|---|
| 187 | mkdir -p compiled-opensc/Library/OpenSC/etc/ |
|---|
| 188 | cp opensc/etc/opensc.conf compiled-opensc/Library/OpenSC/etc/opensc.conf.orig |
|---|
| 189 | cp opensc-uninstall compiled-opensc/Library/OpenSC/bin/ |
|---|
| 190 | ./libtool-bundle compiled-opensc/Library/OpenSC/lib/opensc-pkcs11.so compiled-opensc/Library/OpenSC/lib |
|---|
| 191 | cd compiled-opensc/Library/OpenSC/lib/ && \ |
|---|
| 192 | ln -sf libopensc.2.dylib libopensc.2.0.0.dylib && \ |
|---|
| 193 | ln -sf libscconf.2.dylib libscconf.2.0.0.dylib && \ |
|---|
| 194 | ln -sf libpkcs15init.2.dylib libpkcs15init.2.0.0.dylib |
|---|
| 195 | |
|---|
| 196 | install2: |
|---|
| 197 | chown -R root:wheel $(BUILDHOME)/compiled*/* |
|---|
| 198 | chmod -R g+w $(BUILDHOME)/compiled*/* |
|---|
| 199 | |
|---|
| 200 | manual-install: install-opensc install-libp11 install-engine install-openssh |
|---|
| 201 | |
|---|
| 202 | install-opensc: build-opensc |
|---|
| 203 | cp -HR $(BUILDHOME)/compiled-opensc/Library/OpenSC /Library |
|---|
| 204 | touch $@ |
|---|
| 205 | |
|---|
| 206 | install-libp11: build-libp11 |
|---|
| 207 | cp -HR $(BUILDHOME)/compiled-libp11/Library/OpenSC /Library |
|---|
| 208 | touch $@ |
|---|
| 209 | |
|---|
| 210 | install-engine: build-pkg-config build-engine |
|---|
| 211 | cp -HR $(BUILDHOME)/compiled-engine/Library/OpenSC /Library |
|---|
| 212 | touch $@ |
|---|
| 213 | |
|---|
| 214 | install-openssh: build-openssh |
|---|
| 215 | cp -HR $(BUILDHOME)/compiled-openssh/Library/OpenSC /Library |
|---|
| 216 | touch $@ |
|---|
| 217 | |
|---|
| 218 | package: package-opensc package-libp11 package-engine package-openssh |
|---|
| 219 | |
|---|
| 220 | package-opensc: build-opensc |
|---|
| 221 | $(PACKAGEMAKER) -build -p OpenSC.pkg -f compiled-opensc -v -ds \ |
|---|
| 222 | -i opensc-pack/Info.plist -r opensc-pack/resources -d opensc-pack/Description.plist |
|---|
| 223 | cp opensc-pack/InstallationCheck.strings OpenSC.pkg/Contents/Resources/English.lproj |
|---|
| 224 | cp opensc-pack/InstallationCheck.strings OpenSC.pkg/Contents/Resources |
|---|
| 225 | touch $@ |
|---|
| 226 | |
|---|
| 227 | package-libp11: build-libp11 |
|---|
| 228 | $(PACKAGEMAKER) -build -p libp11.pkg -f compiled-libp11 -v -ds \ |
|---|
| 229 | -i libp11-pack/Info.plist -d libp11-pack/Description.plist |
|---|
| 230 | touch $@ |
|---|
| 231 | |
|---|
| 232 | package-engine: build-engine |
|---|
| 233 | $(PACKAGEMAKER) -build -p engine_pkcs11.pkg -f compiled-engine -v -ds \ |
|---|
| 234 | -i engine-pack/Info.plist -d engine-pack/Description.plist |
|---|
| 235 | touch $@ |
|---|
| 236 | |
|---|
| 237 | package-openssh: build-openssh |
|---|
| 238 | $(PACKAGEMAKER) -build -p openssh.pkg -f compiled-openssh -v -ds \ |
|---|
| 239 | -i openssh-pack/Info.plist -d openssh-pack/Description.plist |
|---|
| 240 | touch $@ |
|---|
| 241 | |
|---|
| 242 | uninstall: |
|---|
| 243 | rm -rf /Library/Receipts/libp11.pkg |
|---|
| 244 | rm -rf /Library/Receipts/engine_pkcs11.pkg |
|---|
| 245 | rm -rf /Library/Receipts/OpenSC.pkg |
|---|
| 246 | rm -rf /Library/Receipts/openssh.pkg |
|---|
| 247 | rm -rf /Library/OpenSC |
|---|
| 248 | |
|---|
| 249 | manual-uninstall: |
|---|
| 250 | rm -rf /Library/OpenSC |
|---|
| 251 | rm -f install* |
|---|