1# Default platform uses the native SDK.
2# To build for Mac OS X using internal SDK, use 'make PLATFORM=macosx <target>'
3# To build for iOS, use 'make PLATFORM=iphoneos <target>'
4
5ifeq ($(PLATFORM),iphoneos)
6# iOS internal SDK
7CORETELEPHONY=-framework CoreTelephony
8ARCHS=armv7
9endif
10
11ifeq ($(PLATFORM),macosx)
12# Mac OS X internal SDK
13ARCHS=i386 x86_64
14CORETELEPHONY=
15endif
16
17ifeq ($(PLATFORM),)
18# Mac OS X native SDK
19ARCHS=i386 x86_64
20CORETELEPHONY=
21CC = cc
22SYSROOT = /
23PF_INC = -F/System/Library/PrivateFrameworks
24else
25# Mac OS X or iOS internal SDK
26SDK=$(PLATFORM).internal
27SYSROOT=$(shell xcodebuild -version -sdk $(SDK) Path)
28CC = xcrun -sdk $(SDK) cc
29PF_INC = -F$(SYSROOT)/System/Library/PrivateFrameworks
30endif
31
32ARCH_FLAGS=$(foreach a,$(ARCHS),-arch $(a))
33
34SCPRIV += -DUSE_SYSTEMCONFIGURATION_PRIVATE_HEADERS=1
35
36certattrs: EAPCertificateUtil.c myCFUtil.c EAPSecurity.c EAPTLSUtil.c printdata.c EAPUtil.c EAPClientModule.c
37	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -DTEST_EAPSecCertificateCopyAttributesDictionary $(PF_INC) -framework Security -framework CoreFoundation -framework SystemConfiguration -g -o $@ $^
38
39identity: EAPCertificateUtil.c myCFUtil.c EAPSecurity.c EAPTLSUtil.c printdata.c EAPUtil.c EAPClientModule.c EAPLog.c EAPSIMAKAPersistentState.c EAPKeychainUtil.c
40	$(CC) $(ARCH_FLAGS) $(SCPRIV) -isysroot $(SYSROOT) -Wall -I.. -DTEST_EAPSecIdentity $(PF_INC) -framework Security -framework CoreFoundation -framework SystemConfiguration -g -o $@ $^
41	xcrun -sdk $(SDK) codesign -s - -f --entitlements ../eapolclient.tproj/entitlements.plist $@
42
43
44identity_trust_chain: EAPCertificateUtil.c myCFUtil.c EAPSecurity.c EAPTLSUtil.c printdata.c EAPUtil.c EAPClientModule.c EAPSIMAKAPersistentState.c EAPKeychainUtil.c
45	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -DTEST_EAPSecIdentityHandleCreateSecIdentityTrustChain $(PF_INC) -framework Security -framework CoreFoundation -framework SystemConfiguration -g -o $@ $^
46
47mschap: mschap.c printdata.c DESSupport.c
48	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -DTEST_MSCHAP -framework CoreFoundation -framework SystemConfiguration -lcrypto -g -o $@ $^
49
50keychain: EAPKeychainUtil.c myCFUtil.c EAPSecurity.c
51	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -DTEST_EAPKEYCHAINUTIL $(PF_INC) -framework Security -framework CoreFoundation -g -o $@ $^
52
53item: EAPKeychainUtil.c EAPSecurity.c myCFUtil.c
54	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -DTEST_EAPKEYCHAINUTIL $(PF_INC) -framework Security -framework CoreFoundation -g -o $@ $^
55
56trustx: EAPTLSUtil.c EAPCertificateUtil.c EAPSecurity.c printdata.c myCFUtil.c
57	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -I. -DTEST_TRUST_EXCEPTIONS $(PF_INC) -framework Security -framework CoreFoundation -framework SystemConfiguration -g -o $@ $^
58
59eapsectrust: EAPTLSUtil.c EAPCertificateUtil.c EAPSecurity.c printdata.c myCFUtil.c
60	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -I. -DTEST_SEC_TRUST $(PF_INC) -framework Security -framework CoreFoundation -framework SystemConfiguration -g -o $@ $^
61
62test_server_names: EAPTLSUtil.c EAPCertificateUtil.c EAPSecurity.c printdata.c myCFUtil.c EAPUtil.c EAPClientModule.c
63	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -I. -DTEST_SERVER_NAMES $(PF_INC) -framework Security -framework CoreFoundation -framework SystemConfiguration -g -o $@ $^
64
65simtlv: EAPSIMAKAUtil.c EAPUtil.c EAPClientModule.c printdata.c EAPLog.c EAPSIMAKAPersistentState.c EAPKeychainUtil.c EAPSecurity.c myCFUtil.c fips186prf.c fr_sha1.c
66	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -Wcast-align -I. -DEAPSIMAKA_PACKET_DUMP -DTEST_TLVLIST_PARSE $(PF_INC) -framework CoreFoundation -framework SystemConfiguration $(CORETELEPHONY) -framework Security -g -o $@ $^
67
68
69rand_dups: eapsim_plugin.c fips186prf.c fr_sha1.c myCFUtil.c printdata.c SIMAccess.c EAPSIMAKAPersistentState.c EAPKeychainUtil.c EAPUtil.c EAPClientModule.c EAPSecurity.c EAPLog.c EAPSIMAKAUtil.c
70	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -I. -DTEST_RAND_DUPS $(PF_INC) -framework CoreFoundation -framework SystemConfiguration $(CORETELEPHONY) -framework Security -g -o $@ $^
71
72sim_crypto: fips186prf.c fr_sha1.c myCFUtil.c printdata.c EAPUtil.c EAPClientModule.c EAPSecurity.c EAPSIMAKAUtil.c EAPSIMAKAPersistentState.c EAPKeychainUtil.c EAPLog.c
73	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -I. -DEAPSIMAKA_PACKET_DUMP -DTEST_SIM_CRYPTO $(PF_INC) -framework CoreFoundation -framework SystemConfiguration -framework Security $(CORETELEPHONY) -g -o $@ $^
74
75sim_set_version: eapsim_plugin.c myCFUtil.c fips186prf.c fr_sha1.c printdata.c EAPSIMAKAPersistentState.c EAPKeychainUtil.c EAPUtil.c EAPClientModule.c EAPSecurity.c SIMAccess.c EAPSIMAKAUtil.c EAPLog.c
76	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -I. -DTEST_SET_VERSION_LIST $(PF_INC) -framework CoreFoundation -framework SystemConfiguration -framework Security $(CORETELEPHONY) -g -o $@ $^
77
78fips186prf: fips186prf.c fr_sha1.c
79	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -Wall -I. -DTEST_FIPS186PRF -g -o $@ $^
80
81siminfo: eapsim_plugin.c SIMAccess.c fips186prf.c fr_sha1.c myCFUtil.c printdata.c EAPSIMAKAPersistentState.c EAPKeychainUtil.c EAPUtil.c EAPClientModule.c EAPSecurity.c EAPSIMAKAUtil.c EAPLog.c
82	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) $(SCPRIV) -Wall -I. -DTEST_SIM_INFO $(PF_INC) -framework CoreFoundation -framework SystemConfiguration -framework Security -framework CoreTelephony -g -o $@ $^
83	xcrun -sdk $(SDK) codesign -s - -f --entitlements ../eapolclient.tproj/entitlements.plist $@
84
85SIMAccess: SIMAccess.c printdata.c myCFUtil.c EAPSIMAKAUtil.c EAPUtil.c EAPClientModule.c EAPSIMAKAPersistentState.c EAPKeychainUtil.c EAPSecurity.c fips186prf.c fr_sha1.c EAPLog.c
86	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) $(SCPRIV) -Wall -I. -DTARGET_OS_EMBEDDED -DTEST_SIMACCESS $(PF_INC) -framework CoreFoundation $(CORETELEPHONY) -framework SystemConfiguration -framework Security -g -o $@ $^
87	xcrun -sdk $(SDK) codesign -s - -f --entitlements ../eapolclient.tproj/entitlements.plist $@
88
89verify_server: EAPTLSUtil.c EAPCertificateUtil.c EAPSecurity.c myCFUtil.c printdata.c EAPUtil.c EAPClientModule.c EAPSIMAKAPersistentState.c EAPKeychainUtil.c
90	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DTEST_EAPTLSVerifyServerCertificateChain $(PF_INC) -framework CoreFoundation -framework Security -g -o $@ $^
91
92eapol_socket: eapol_socket.c
93	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -I../EAP8021X.fproj -DTEST_EAPOL_SOCKET -g -o $@ $^
94
95simaka_persist: EAPSIMAKAPersistentState.c EAPKeychainUtil.c myCFUtil.c EAPSecurity.c printdata.c
96	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DTEST_EAPSIMAKA_PERSISTENT_STATE $(PF_INC) -framework CoreFoundation -framework Security -framework SystemConfiguration -g -o $@ $^
97	export CODESIGN_ALLOCATE=$(shell xcrun -sdk $(SDK) -find codesign_allocate)
98	xcrun -sdk $(SDK) codesign -s - -f --entitlements ../eapolclient.tproj/entitlements.plist $@
99
100test_eapaka: eapaka_plugin.c EAPSIMAKAUtil.c SIMAccess.c EAPUtil.c EAPClientModule.c EAPSIMAKAPersistentState.c fips186prf.c printdata.c myCFUtil.c EAPKeychainUtil.c EAPSecurity.c fr_sha1.c EAPLog.c
101	$(CC) $(ARCH_FLAGS) -isysroot $(SYSROOT) -DEAPSIMAKA_PACKET_DUMP -DTEST_EAPAKA_PLUGIN $(PF_INC) -framework CoreFoundation -framework Security -framework SystemConfiguration -g -o $@ $^
102
103clean:
104	rm -rf *.dSYM/
105	rm -f *~
106	rm -f certattrs identity identity_trust_chain mschap keychain item trustx eapsectrust test_server_names simtlv rand_dups sim_crypto sim_set_version fips186prf siminfo SIMAccess verify_server eapol_socket simaka_persist test_eapaka
107