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
34SYSTEM_PRIVATE = -I$(SYSROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
35
36SC_PRIV = -DUSE_SYSTEMCONFIGURATION_PRIVATE_HEADERS
37
38BLIB = ../bootplib
39ARPTEST_BOOTPLIB_CFILES = $(BLIB)/dynarray.c $(BLIB)/ptrlist.c $(BLIB)/interfaces.c $(BLIB)/bpflib.c $(BLIB)/ioregpath.c
40
41arptest: arp_session.o arp_session.h timer.c timer.h FDSet.c FDSet.h
42	cc -g -arch i386 -Wall -DTEST_ARP_SESSION $(SYSTEM_PRIVATE) -I../bootplib -o arptest arp_session.o timer.c FDSet.c $(ARPTEST_BOOTPLIB_CFILES) -framework CoreFoundation -framework IOKit
43
44arp_session.o: arp_session.c arp_session.h
45	cc -g -arch i386 -Wall -c arp_session.c -DTEST_ARP_SESSION $(SYSTEM_PRIVATE) -I../bootplib
46
47inet6_addrs: ifutil.c rtutil.c ../bootplib/arp.c ../bootplib/IPConfigurationLog.c ../bootplib/util.c
48	cc -DTEST_INET6_ADDRLIST -DCONFIGURE_IPV6 -I../bootplib $(SYSTEM_PRIVATE) -framework SystemConfiguration -framework CoreFoundation -g -o $@ $^
49
50dhcpv6: DHCPv6Client.c ifutil.c cga.c rsakey.c FDSet.c timer.c HostUUID.c IPv6Socket.c ../bootplib/ptrlist.c ../bootplib/dynarray.c ../bootplib/IPConfigurationLog.c ../bootplib/interfaces.c ../bootplib/DHCPv6.c ../bootplib/DHCPv6Options.c ../bootplib/DHCPDUID.c DHCPv6Socket.c DHCPDUIDIAID.c ../bootplib/DNSNameList.c ../bootplib/cfutil.c ../bootplib/util.c
51	cc -D__APPLE_USE_RFC_3542 -DTEST_DHCPV6_CLIENT -g -Wall -I../bootplib -framework CoreFoundation -framework SystemConfiguration $(SYSTEM_PRIVATE) -o $@ $^
52
53dhcpduid: DHCPDUIDIAID.c ../bootplib/util.c ../bootplib/DHCPDUID.c ../bootplib/interfaces.c ../bootplib/ptrlist.c ../bootplib/dynarray.c ../bootplib/cfutil.c HostUUID.c ../bootplib/IPConfigurationLog.c
54	cc -DTEST_DHCPDUIDIAID -I$(BLIB) -g -Wall -framework CoreFoundation -framework SystemConfiguration -o $@ $^
55
56rtadv: RTADVSocket.c ../bootplib/interfaces.c ../bootplib/ptrlist.c ../bootplib/dynarray.c timer.c FDSet.c ../bootplib/IPConfigurationLog.c ../bootplib/util.c
57	cc -D__APPLE_USE_RFC_3542 $(SYSTEM_PRIVATE) -I../bootplib -DTEST_RTADVSOCKET -framework CoreFoundation -framework SystemConfiguration -o $@ $^
58
59rsakey: RSAKey.c ../bootplib/cfutil.c ../bootplib/IPConfigurationLog.c
60	cc -I../bootplib -DTEST_RSAKEY -framework SystemConfiguration -framework CoreFoundation -g -Wall -o $@ $^
61
62cga: CGA.c ../bootplib/cfutil.c ../bootplib/IPConfigurationLog.c RSAKey.c HostUUID.c ../bootplib/util.c
63	$(CC) -isysroot $(SYSROOT) $(ARCH_FLAGS) $(SYSTEM_PRIVATE) -I../bootplib -DTEST_CGA -framework SystemConfiguration -framework CoreFoundation $(SC_PRIV) -g -Wall -o $@ $^
64
65ndadvert: IPv6Socket.c ../bootplib/interfaces.c ../bootplib/ptrlist.c ../bootplib/dynarray.c ../bootplib/IPConfigurationLog.c ifutil.c CGA.c ../bootplib/util.c ../bootplib/cfutil.c rsakey.c HostUUID.c
66	$(CC) -isysroot $(SYSROOT) $(ARCH_FLAGS) -D__APPLE_USE_RFC_3542 $(SYSTEM_PRIVATE) -I../bootplib -DTEST_NEIGHBOR_ADVERT -framework SystemConfiguration -framework CoreFoundation $(SC_PRIV) -g -Wall -o $@ $^
67
68ipv6ll: ifutil.c ../bootplib/cfutil.c ../bootplib/util.c ../bootplib/IPConfigurationLog.c rtutil.c ../bootplib/arp.c
69	$(CC) -isysroot $(SYSROOT) $(ARCH_FLAGS) $(SYSTEM_PRIVATE) -I../bootplib -DTEST_IPV6_LL -framework SystemConfiguration -framework CoreFoundation $(SC_PRIV) -g -Wall -o $@ $^
70
71clean:
72	rm -f arptest arp_session.o inet6_addrs dhcpv6 dhcpduid cga rsakey ipv6ll
73	rm -rf *.dSYM/
74