Check-in [059330a9a5]
Overview
Comment:Fixed bug in UUID of package

Added PKCS11.tokend package to CACKey on Mac OS X

Removed legacy (pre-Mac OS X 10.5) build support

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:059330a9a588e166039075cb32e1e9e45767de54
User & Date: rkeene on 2011-08-25 04:00:27
Other Links: manifest | tags
Context
2011-08-25
04:01
CACKey 0.6.0 check-in: 21d6e16ab8 user: rkeene tags: trunk, 0.6.0
04:00
Fixed bug in UUID of package

Added PKCS11.tokend package to CACKey on Mac OS X

Removed legacy (pre-Mac OS X 10.5) build support check-in: 059330a9a5 user: rkeene tags: trunk

2011-08-24
03:44
Removed incomplete and never-used SPM implementation check-in: 6723914ef9 user: rkeene tags: trunk
Changes

Modified build/cackey_osx_build/Template_pmbuild/03libcackey.xml.in from [fe50c1df7a] to [b6742d933b].

1
2
3
4
5
6
7
8
<pkgref spec="1.12" uuid="@@OSXVERSION@@">
	<config>
		<identifier>mil.army.usace.cackeyForMacOsX@@OSXVERSION@@.cackey.pkg</identifier>
		<version>1</version>
		<description></description>
		<post-install type="none"/>
		<requireAuthorization/>
		<installFrom relative="true" mod="true">cackey.dylib</installFrom>
|







1
2
3
4
5
6
7
8
<pkgref spec="1.12" uuid="@@UUID@@">
	<config>
		<identifier>mil.army.usace.cackeyForMacOsX@@OSXVERSION@@.cackey.pkg</identifier>
		<version>1</version>
		<description></description>
		<post-install type="none"/>
		<requireAuthorization/>
		<installFrom relative="true" mod="true">cackey.dylib</installFrom>

Added build/cackey_osx_build/Template_pmbuild/04pkcs11tokend-contents.xml.in version [e88a608a73].















>
>
>
>
>
>
>
1
2
3
4
5
6
7
<pkg-contents spec="1.12">
	<d n="PKCS11.tokend" o="root" g="wheel" p="33261" pt="@@BUILDROOTDIR@@/build/cackey_osx_build/PKCS11.tokend" m="true" t="file">
		<mod>owner</mod>
		<mod>mode</mod>
		<mod>group</mod>
	</d>
</pkg-contents>

Added build/cackey_osx_build/Template_pmbuild/04pkcs11tokend.xml.in version [793db41bea].











































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<pkgref spec="1.12" uuid="@@UUID@@">
	<config>
		<identifier>mil.army.usace.cackeyForMacOsX@@OSXVERSION@@.PKCS11.pkg</identifier>
		<version>1</version>
		<description></description>
		<post-install type="none"/>
		<requireAuthorization/>
		<installFrom relative="true" mod="true">PKCS11.tokend</installFrom>
		<installTo mod="true" relocatable="true">/System/Library/Security/tokend/PKCS11.tokend</installTo>
		<flags></flags>
		<packageStore type="internal"></packageStore>
		<mod>parent</mod>
		<mod>scripts.postinstall.path</mod>
		<mod>scripts.scriptsDirectoryPath.isRelativeType</mod>
		<mod>scripts.scriptsDirectoryPath.path</mod>
		<mod>installTo.isAbsoluteType</mod>
		<mod>installTo.isRelativeType</mod>
		<mod>scripts.postflight.path</mod>
		<mod>relocatable</mod>
		<mod>version</mod>
		<mod>installTo.path</mod>
		<mod>installFrom.path</mod>
		<mod>installTo</mod>
	</config>
	<scripts>
		<postinstall mod="true">@@BUILDROOTDIR@@/build/cackey_osx_build/Template_pmbuild/scripts/04pkcs11tokend-post.sh</postinstall>
		<scripts-dir mod="true">@@BUILDROOTDIR@@/build/cackey_osx_build/Template_pmbuild/scripts</scripts-dir>
	</scripts>
	<contents>
		<file-list>04pkcs11tokend-contents.xml</file-list>
		<filter>/CVS$</filter>
		<filter>/\.svn$</filter>
		<filter>/\.cvsignore$</filter>
		<filter>/\.cvspass$</filter>
		<filter>/\.DS_Store$</filter>
	</contents>
</pkgref>

Modified build/cackey_osx_build/Template_pmbuild/index.xml.in from [eb9bc49ba6] to [9543623cb4].

15
16
17
18
19
20
21



22
23
24
25
26
27
28
..
31
32
33
34
35
36
37



38
39
40
41
42
43
44
..
60
61
62
63
64
65
66



67
68
69
70
71
72
73
..
77
78
79
80
81
82
83

84
85
86
87
88
89
		<choice title="CACKey PKCS#11 Library (Core)" id="cackey" starts_selected="true" starts_enabled="true" starts_hidden="false">
			<pkgref id="mil.army.usace.cackeyForMacOsX@@OSXVERSION@@.libcackey.pkg"/>
			<pkgref id="mil.army.usace.cackeyForMacOsX@@OSXVERSION@@.cackey.pkg"/>
		</choice>
		<choice title="CACKey PKCS#11 Library (Debug)" id="cackeydebug" starts_selected="true" starts_enabled="true" starts_hidden="false">
			<pkgref id="mil.army.usace.cackeyForMacOsX@@OSXVERSION@@.@@LIBCACKEYG@@"/>
		</choice>



	</contents>
	<resources bg-scale="none" bg-align="topleft">
		<locale lang="en">
			<resource mime-type="text/rtf" kind="embedded" type="license">
				<![CDATA[{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf540
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
{\colortbl;\red255\green255\blue255;}
................................................................................
\f0\fs26 \cf0 Release information:\
    pkg: CACKey\
 author: US Army Corps of Engineers\
Mac build contact: Kenneth Van Alstyne <kenneth.vanalstyne@hq.dhs.gov>\
                   US Department of Homeland Security\
contact: Roy Keene <roy.s.keene@usace.army.mil>\
------------------------------------------------\



\
The following files in the source directory are the intellectual property of the\
Free Software Foundation and are licensed under the terms of the GNU General\
Public License (GPL):\
	config.guess, config.sub, install-sh\
\
The files in the source directory and the "leakcheck" directory are the intellectual\
................................................................................
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\f0\fs26 \cf0 Thank you for choosing to install CACKey.\
\
To use CACKey, install /Library/CACKey/libcackey.dylib or\
/usr/lib/pkcs11/cackey.dylib as a security module into any application that can use a PKCS#11 provider.\



\
A debug version, /Library/CACKey/libcackey_g.dylib is provided if debug output is necessary.}]]>
			</resource>
		</locale>
	</resources>
	<requirements>
		<requirement id="tosv" operator="lt" value="'@@NEXTOSXVER@@'">
................................................................................
			<message>This CACKey release requires Mac OS X @@CUROSXVER@@.</message>
		</requirement>
	</requirements>
	<flags/>
	<item type="file">01libcackey.xml</item>
	<item type="file">02libcackey.xml</item>
	<item type="file">03libcackey.xml</item>

	<mod>properties.customizeOption</mod>
	<mod>properties.title</mod>
	<mod>description</mod>
	<mod>properties.systemDomain</mod>
	<mod>properties.anywhereDomain</mod>
</pkmkdoc>







>
>
>







 







>
>
>







 







>
>
>







 







>






15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
..
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
..
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
		<choice title="CACKey PKCS#11 Library (Core)" id="cackey" starts_selected="true" starts_enabled="true" starts_hidden="false">
			<pkgref id="mil.army.usace.cackeyForMacOsX@@OSXVERSION@@.libcackey.pkg"/>
			<pkgref id="mil.army.usace.cackeyForMacOsX@@OSXVERSION@@.cackey.pkg"/>
		</choice>
		<choice title="CACKey PKCS#11 Library (Debug)" id="cackeydebug" starts_selected="true" starts_enabled="true" starts_hidden="false">
			<pkgref id="mil.army.usace.cackeyForMacOsX@@OSXVERSION@@.@@LIBCACKEYG@@"/>
		</choice>
		<choice title="PKCS11 Tokend Connector" id="PKCS11" starts_selected="true" starts_enabled="true" starts_hidden="false">
			<pkgref id="mil.army.usace.cackeyForMacOsX@@OSXVERSION@@.PKCS11.pkg"/>
		</choice>
	</contents>
	<resources bg-scale="none" bg-align="topleft">
		<locale lang="en">
			<resource mime-type="text/rtf" kind="embedded" type="license">
				<![CDATA[{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf540
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
{\colortbl;\red255\green255\blue255;}
................................................................................
\f0\fs26 \cf0 Release information:\
    pkg: CACKey\
 author: US Army Corps of Engineers\
Mac build contact: Kenneth Van Alstyne <kenneth.vanalstyne@hq.dhs.gov>\
                   US Department of Homeland Security\
contact: Roy Keene <roy.s.keene@usace.army.mil>\
------------------------------------------------\
\
The PKCS11.tokend connector module included in this package is licensed under\
the APSL. See: http://devel.kvanals.org/PKCS11_Tokend\
\
The following files in the source directory are the intellectual property of the\
Free Software Foundation and are licensed under the terms of the GNU General\
Public License (GPL):\
	config.guess, config.sub, install-sh\
\
The files in the source directory and the "leakcheck" directory are the intellectual\
................................................................................
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\f0\fs26 \cf0 Thank you for choosing to install CACKey.\
\
To use CACKey, install /Library/CACKey/libcackey.dylib or\
/usr/lib/pkcs11/cackey.dylib as a security module into any application that can use a PKCS#11 provider.\
\
A PKCS11 Connector for Tokend (Keychain Access) will be installed in /System/Library/Security/tokend.\
To use, be sure to import the certificate authorities into Keychain Access.\
\
A debug version, /Library/CACKey/libcackey_g.dylib is provided if debug output is necessary.}]]>
			</resource>
		</locale>
	</resources>
	<requirements>
		<requirement id="tosv" operator="lt" value="'@@NEXTOSXVER@@'">
................................................................................
			<message>This CACKey release requires Mac OS X @@CUROSXVER@@.</message>
		</requirement>
	</requirements>
	<flags/>
	<item type="file">01libcackey.xml</item>
	<item type="file">02libcackey.xml</item>
	<item type="file">03libcackey.xml</item>
	<item type="file">04pkcs11tokend.xml</item>
	<mod>properties.customizeOption</mod>
	<mod>properties.title</mod>
	<mod>description</mod>
	<mod>properties.systemDomain</mod>
	<mod>properties.anywhereDomain</mod>
</pkmkdoc>

Added build/cackey_osx_build/Template_pmbuild/scripts/04pkcs11tokend-post.sh version [1f1313960f].







>
>
>
1
2
3
#!/bin/bash
chmod -R go+rX /System/Library/Security/tokend/PKCS11.tokend
chown -R root:wheel /System/Library/Security/tokend/PKCS11.tokend

Modified build/cackey_osx_build/build_osx.sh from [0757f2f9f0] to [b98bcd81f7].

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30


31
32
33
34
35
36
37
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
..
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
...
202
203
204
205
206
207
208













209
210
211
212
213
214
215
...
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238

239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
...
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
	LIONBUILD=1
fi

# Usage function
usage() {
	echo "Usage: build_osx.sh <target>"
	echo Where target is one of:
	echo "    panther  - (Builds 10.3 Library for PPCG3) (LEGACY)"
	echo "    tiger  - (Builds Universal 10.4 Library for PPCG3/i386) (LEGACY)"
	echo "    leopard  - (Builds Universal 10.5 Library for PPCG4/i386)"
	echo "    snowleopard  - (Builds Universal 10.6 Library for i386/x86_64)"
	echo "    lion  - (Builds Universal 10.7 Library for i386/x86_64)"
	echo "    all - (Builds for all supported targets)"
	echo "    legacy - (Builds for all supported targets older than 10.7)"
	echo "    clean - (Cleans up)"
	echo "Run from CACKey Build Root."
	exit $?
}

# Clean up function
clean() {
	rm -f build/cackey_osx_build/cackey.dylib


	rm -rf macbuild
	rm -rf build/cackey_osx_build/*.pmdoc
	make distclean
}

# Directory creation function
makedir() {
................................................................................
	if [ "`uname -r | cut -d . -f 1`" -lt "10" ]; then
		LIBTOOLDIR=/Developer/usr/share/libtool
	else
		LIBTOOLDIR=/Developer/usr/share/libtool/config
	fi
	if [ ! -d macbuild ]; then
		mkdir macbuild
		mkdir macbuild/Panther
		mkdir macbuild/Tiger
		mkdir macbuild/Leopard
		mkdir macbuild/Snowleopard
		mkdir macbuild/Lion
		mkdir macbuild/pkg
	fi
	if [ ! -f config.guess ]; then
		cp ${LIBTOOLDIR}/config.guess .
................................................................................
		cp ${LIBTOOLDIR}/config.sub .
	fi
	if [ ! -f install-sh ]; then
		cp ${LIBTOOLDIR}/install-sh .
	fi
}

# Build function for Panther
panther() {
	makedir
	HEADERS=/Developer/SDKs/MacOSX10.3.9.sdk/System/Library/Frameworks/PCSC.framework/Versions/A/Headers/
	LIBRARY=/Developer/SDKs/MacOSX10.3.9.sdk/System/Library/Frameworks/PCSC.framework/PCSC
	OSX=Panther
	PKTARGETOS=1
	NEXTOSXVER=10.4
	CUROSXVER=10.3
	HOST=powerpc-apple-darwin7
	make distclean
	ARCH="ppc -mcpu=G3"
	CFLAGS="-arch ${ARCH}" ./configure --with-pcsc-headers=${HEADERS} --with-pcsc-libs=${LIBRARY} --host=${HOST}
	make
	cp libcackey.dylib macbuild/${OSX}/libcackey.dylib
	cp libcackey_g.dylib macbuild/${OSX}/libcackey_g.dylib
	pkgbuild
}

# Build function for Tiger
tiger() {
	makedir
	HEADERS=/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/PCSC.framework/Versions/A/Headers/
	LIBRARY=/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/PCSC.framework/PCSC
	LIB=""
	ARCHLIST=""
	DLIB=""
	DARCHLIST=""
	OSX=Tiger
	PKTARGETOS=2
	NEXTOSXVER=10.5
	CUROSXVER=10.4
	for HOST in powerpc-apple-darwin8 i386-apple-darwin8; do
		genbuild
	done
	libbuild
	pkgbuild
}

# Build function for Leopard
leopard() {
	makedir
	HEADERS=/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/PCSC.framework/Versions/A/Headers/
	LIBRARY=/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/PCSC.framework/PCSC
	LIB=""
	ARCHLIST=""
................................................................................
	if [ "`uname -r | cut -d . -f 1`" -lt "10" ]; then
		LIBCACKEYG=libcackeyg.pkg
	else
		LIBCACKEYG=libcackey_g.pkg
	fi
	rm -f build/cackey_osx_build/cackey.dylib
	ln macbuild/${OSX}/libcackey.dylib build/cackey_osx_build/cackey.dylib













	for PMDOC in build/cackey_osx_build/Template_pmbuild/*.in; do
		PMDOC="`echo "${PMDOC}" | sed 's|l.in|l|g' | sed 's|build/cackey_osx_build/Template_pmbuild/||g'`"
		UUID="`python -c 'import uuid; print uuid.uuid1()' | dd conv=ucase 2>/dev/null`"
		mkdir -p build/cackey_osx_build/${OSX}_pmbuild.pmdoc
		sed "s|@@BUILDROOTDIR@@|$(pwd)|g" build/cackey_osx_build/Template_pmbuild/${PMDOC}.in > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}
		sed "s|@@OSXVERSION@@|${OSX}|g" build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC} > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1
		sed "s|@@UUID@@|${UUID}|g" build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1 > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}
................................................................................
		sed "s|@@TARGETOS@@|${PKTARGETOS}|g" build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC} > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1
		sed "s|@@NEXTOSXVER@@|${NEXTOSXVER}|g" build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1 > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}
		sed "s|@@CUROSXVER@@|${CUROSXVER}|g" build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC} > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1
		sed "s|@@LIBCACKEYG@@|${LIBCACKEYG}|g" build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1 > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}
		cp build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC} build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1
		mv build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1 build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}
	done
	if [ ${OSX} == "Panther" ]; then
		EXT=mpkg
		cat build/cackey_osx_build/${OSX}_pmbuild.pmdoc/index.xml | grep -v -i require > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/index.xml.new
		mv build/cackey_osx_build/${OSX}_pmbuild.pmdoc/index.xml.new build/cackey_osx_build/${OSX}_pmbuild.pmdoc/index.xml
	else
		EXT=pkg
	fi
	if [ ${OSX} == "Snowleopard" ]; then
		cat build/cackey_osx_build/${OSX}_pmbuild.pmdoc/index.xml | sed 's|for Mac OS X Snowleopard|for Mac OS X SnowLeopard|g' > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/index.xml.new
		mv build/cackey_osx_build/${OSX}_pmbuild.pmdoc/index.xml.new build/cackey_osx_build/${OSX}_pmbuild.pmdoc/index.xml
	fi
	/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker -d build/cackey_osx_build/${OSX}_pmbuild.pmdoc -o macbuild/pkg/CACKey_${CACKEY_VERSION}_${OSX}.${EXT}
	tar --create --directory macbuild/pkg/ --file macbuild/pkg/CACKey_${CACKEY_VERSION}_${OSX}.${EXT}.tar CACKey_${CACKEY_VERSION}_${OSX}.${EXT}
	gzip -9 macbuild/pkg/CACKey_${CACKEY_VERSION}_${OSX}.${EXT}.tar
	rm -rf macbuild/pkg/CACKey_${CACKEY_VERSION}_${OSX}.${EXT}
	rm -f build/cackey_osx_build/cackey.dylib

	echo "${OSX} build complete"
}

# Take command line arguments and execute
case "$1" in
	"")
		usage
		exit $?
	;;

	"panther")
		if [ "${LIONBUILD}" = "1" ]; then
			echo "Building for platforms older than Mac OS X 10.5 (Leopard) is not supported on Lion..."
			exit 1
		fi
		./autogen.sh
		panther
		exit $?
	;;

	"tiger")
		if [ "${LIONBUILD}" = "1" ]; then
			echo "Building for platforms older than Mac OS X 10.5 (Leopard) is not supported on Lion..."
			exit 1
		fi
		./autogen.sh
		tiger
		exit $?
	;;

	"leopard")
		./autogen.sh
		leopard
		exit $?
................................................................................
		snowleopard
		lion
		echo ""
		echo "All builds complete."
		exit $?
	;;

	"legacy")
		if [ "${LIONBUILD}" = "1" ]; then
			echo "Building for platforms older than Mac OS X 10.5 (Leopard) is not supported on Lion..."
			exit 1
		fi
		./autogen.sh
		panther
		tiger
		leopard
		snowleopard
		echo ""
		echo "All LEGACY builds complete."
		exit $?
	;;

	"clean")
		clean
		exit $?
	;;

	*)
		usage
		exit $?
	;;
esac 







<
<




<








>
>







 







<
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>







 







<
<
<
<
<
|
<









>







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










9
10
11
12
13
14
15


16
17
18
19

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
37
38
39
40
41
42
43


44
45
46
47
48
49
50
..
53
54
55
56
57
58
59







































60
61
62
63
64
65
66
...
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
...
187
188
189
190
191
192
193





194

195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211




















212
213
214
215
216
217
218
...
236
237
238
239
240
241
242















243
244
245
246
247
248
249
250
251
252
	LIONBUILD=1
fi

# Usage function
usage() {
	echo "Usage: build_osx.sh <target>"
	echo Where target is one of:


	echo "    leopard  - (Builds Universal 10.5 Library for PPCG4/i386)"
	echo "    snowleopard  - (Builds Universal 10.6 Library for i386/x86_64)"
	echo "    lion  - (Builds Universal 10.7 Library for i386/x86_64)"
	echo "    all - (Builds for all supported targets)"

	echo "    clean - (Cleans up)"
	echo "Run from CACKey Build Root."
	exit $?
}

# Clean up function
clean() {
	rm -f build/cackey_osx_build/cackey.dylib
	rm -rf build/cackey_osx_build/PKCS11.tokend
	rm -rf PKCS11.tokend
	rm -rf macbuild
	rm -rf build/cackey_osx_build/*.pmdoc
	make distclean
}

# Directory creation function
makedir() {
................................................................................
	if [ "`uname -r | cut -d . -f 1`" -lt "10" ]; then
		LIBTOOLDIR=/Developer/usr/share/libtool
	else
		LIBTOOLDIR=/Developer/usr/share/libtool/config
	fi
	if [ ! -d macbuild ]; then
		mkdir macbuild


		mkdir macbuild/Leopard
		mkdir macbuild/Snowleopard
		mkdir macbuild/Lion
		mkdir macbuild/pkg
	fi
	if [ ! -f config.guess ]; then
		cp ${LIBTOOLDIR}/config.guess .
................................................................................
		cp ${LIBTOOLDIR}/config.sub .
	fi
	if [ ! -f install-sh ]; then
		cp ${LIBTOOLDIR}/install-sh .
	fi
}








































# Build function for Leopard
leopard() {
	makedir
	HEADERS=/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/PCSC.framework/Versions/A/Headers/
	LIBRARY=/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/PCSC.framework/PCSC
	LIB=""
	ARCHLIST=""
................................................................................
	if [ "`uname -r | cut -d . -f 1`" -lt "10" ]; then
		LIBCACKEYG=libcackeyg.pkg
	else
		LIBCACKEYG=libcackey_g.pkg
	fi
	rm -f build/cackey_osx_build/cackey.dylib
	ln macbuild/${OSX}/libcackey.dylib build/cackey_osx_build/cackey.dylib
	rm -rf build/cackey_osx_build/PKCS11.tokend
	if [ "${LIONBUILD}" = 1 ]; then
		TAR=gnutar
	else
		TAR=tar
	fi
	if [ "${OSX}" = "Leopard" ]; then
		curl http://devel.kvanals.org/PKCS11_Tokend/PKCS11_tokend-latest.tar.gz | ${TAR} --strip-components 3 --wildcards -x -z -f - "PKCS11_tokend-*/prebuilt/leopard/PKCS11.tokend"
		mv PKCS11.tokend build/cackey_osx_build/PKCS11.tokend
	else
		curl http://devel.kvanals.org/PKCS11_Tokend/PKCS11_tokend-latest.tar.gz | ${TAR} --strip-components 3 --wildcards -x -z -f - "PKCS11_tokend-*/prebuilt/snowleopard/PKCS11.tokend"
		mv PKCS11.tokend build/cackey_osx_build/PKCS11.tokend
	fi
	for PMDOC in build/cackey_osx_build/Template_pmbuild/*.in; do
		PMDOC="`echo "${PMDOC}" | sed 's|l.in|l|g' | sed 's|build/cackey_osx_build/Template_pmbuild/||g'`"
		UUID="`python -c 'import uuid; print uuid.uuid1()' | dd conv=ucase 2>/dev/null`"
		mkdir -p build/cackey_osx_build/${OSX}_pmbuild.pmdoc
		sed "s|@@BUILDROOTDIR@@|$(pwd)|g" build/cackey_osx_build/Template_pmbuild/${PMDOC}.in > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}
		sed "s|@@OSXVERSION@@|${OSX}|g" build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC} > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1
		sed "s|@@UUID@@|${UUID}|g" build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1 > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}
................................................................................
		sed "s|@@TARGETOS@@|${PKTARGETOS}|g" build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC} > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1
		sed "s|@@NEXTOSXVER@@|${NEXTOSXVER}|g" build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1 > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}
		sed "s|@@CUROSXVER@@|${CUROSXVER}|g" build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC} > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1
		sed "s|@@LIBCACKEYG@@|${LIBCACKEYG}|g" build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1 > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}
		cp build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC} build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1
		mv build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}.1 build/cackey_osx_build/${OSX}_pmbuild.pmdoc/${PMDOC}
	done





	EXT=pkg

	if [ ${OSX} == "Snowleopard" ]; then
		cat build/cackey_osx_build/${OSX}_pmbuild.pmdoc/index.xml | sed 's|for Mac OS X Snowleopard|for Mac OS X SnowLeopard|g' > build/cackey_osx_build/${OSX}_pmbuild.pmdoc/index.xml.new
		mv build/cackey_osx_build/${OSX}_pmbuild.pmdoc/index.xml.new build/cackey_osx_build/${OSX}_pmbuild.pmdoc/index.xml
	fi
	/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker -d build/cackey_osx_build/${OSX}_pmbuild.pmdoc -o macbuild/pkg/CACKey_${CACKEY_VERSION}_${OSX}.${EXT}
	tar --create --directory macbuild/pkg/ --file macbuild/pkg/CACKey_${CACKEY_VERSION}_${OSX}.${EXT}.tar CACKey_${CACKEY_VERSION}_${OSX}.${EXT}
	gzip -9 macbuild/pkg/CACKey_${CACKEY_VERSION}_${OSX}.${EXT}.tar
	rm -rf macbuild/pkg/CACKey_${CACKEY_VERSION}_${OSX}.${EXT}
	rm -f build/cackey_osx_build/cackey.dylib
	rm -rf build/cackey_osx_build/PKCS11.tokend
	echo "${OSX} build complete"
}

# Take command line arguments and execute
case "$1" in
	"")
		usage




















		exit $?
	;;

	"leopard")
		./autogen.sh
		leopard
		exit $?
................................................................................
		snowleopard
		lion
		echo ""
		echo "All builds complete."
		exit $?
	;;
















	"clean")
		clean
		exit $?
	;;

	*)
		usage
		exit $?
	;;
esac