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 
37BLIB = ../bootplib
38
39none:
40	@echo "make what?"
41
42gen: genoptionfiles
43	rm -f gen_dhcp*.h
44	cc -Wall -g -o genoptionfiles genoptionfiles.c
45	./genoptionfiles -table > gen_dhcp_parse_table.h
46	./genoptionfiles -dhcptag > gen_dhcp_tags.h
47	./genoptionfiles -dhcptype > gen_dhcp_types.h
48	chmod 444 gen_dhcp*.h
49
50inetroute: inetroute.c
51	cc -Wall -g -o inetroute -DTEST_INETROUTE inetroute.c dynarray.c ptrlist.c util.c
52
53sharepoints:
54	cc -Wno-four-char-constants -o sharepoints $(OTHER_CFLAGS) -DTEST_SHAREPOINTS sharepoints.c -F$(NEXT_ROOT)/System/Library/PrivateFrameworks -framework ServerControl -framework ServerPrefix -framework AFPDefines
55
56nilist: NICache.c NICache.h
57	cc -Wall -g -o nilist -DNICACHE_TEST NICache.c dynarray.c ptrlist.c netinfo.c host_identifier.c util.c NIDomain.c
58
59afpusers:
60	cc -Wall -g -o afpusers -DTEST_AFPUSERS AFPUsers.c NICache.c dynarray.c ptrlist.c netinfo.c host_identifier.c util.c NIDomain.c
61
62readtest:
63	cc -Wall -g -o readtest -DREAD_TEST NICache.c dynarray.c ptrlist.c netinfo.c host_identifier.c util.c
64
65arp: arp.c arp.h
66	cc -Wall -g -o arp -DMAIN arp.c -I/System/Library/Frameworks/System.framework/PrivateHeaders
67
68nihosts:
69	cc -Wall -g -o nihosts -DTEST_NIHOSTS NIHosts.m util.c NIDomain.c dynarray.c ptrlist.c netinfo.c host_identifier.c
70
71interfaces: interfaces.c IPConfigurationLog.c ptrlist.c dynarray.c
72	$(CC) -isysroot $(SYSROOT) $(ARCH_FLAGS) -framework CoreFoundation -framework SystemConfiguration -DTEST_INTERFACES $(SYSTEM_PRIVATE) $(SC_PRIV) -g -o $@ $^
73
74dhcpopt: dhcp_options.c
75	cc -Wall -g -DTEST_DHCP_OPTIONS -o dhcpopt dhcp_options.c ptrlist.c util.c DNSNameList.c -framework CoreFoundation -framework SystemConfiguration -framework CoreFoundation
76
77macncopt: macnc_options.c
78	cc -Wall -g -DTEST_MACNC_OPTIONS -o macncopt macnc_options.c dhcp_options.c ptrlist.c util.c DNSNameList.c
79
80nbsp: nbsp.c nbsp.h
81	cc -Wall -g -DTEST_NBSP -o nbsp nbsp.c ptrlist.c dynarray.c
82
83hfsvols: hfsvols.c hfsvols.h
84	cc -Wall -g -DTEST_HFSVOLS -o hfsvols hfsvols.c ptrlist.c dynarray.c
85
86nbimages: nbimages.c nbimages.h cfutil.c
87	cc -Wall -g -DTEST_NBIMAGES -o nbimages nbimages.c util.c nbsp.c ptrlist.c dynarray.c cfutil.c -framework CoreFoundation -I$(NET_ROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders -framework SystemConfiguration
88
89dnsnamelist: DNSNameList.c DNSNameList.h
90	cc -Wall -g -DTEST_DNSNAMELIST -o dnsnamelist DNSNameList.c util.c -framework CoreFoundation -framework SystemConfiguration
91
92subnets: subnets.c cfutil.c DNSNameList.c util.c ptrlist.c dynarray.c dhcp_options.c
93	cc -g -Wall -DTEST_SUBNETS -o subnets subnets.c cfutil.c util.c ptrlist.c dynarray.c DNSNameList.c dhcp_options.c -framework CoreFoundation
94
95test-dhcpv6-options: DHCPv6Options.c DHCPv6.c DHCPDUID.c
96	cc -g -Wall DHCPv6Options.c DHCPDUID.c DHCPv6.c -o test-dhcpv6-options -DTEST_DHCPV6_OPTIONS ptrlist.c util.c DNSNameList.c cfutil.c -framework CoreFoundation -framework SystemConfiguration
97
98clean:
99	rm -f afpusers arp dhcpopt dnsnamelist genoptionfiles hfsvols interfaces nbimages nbsp nihosts nilist readtest sharepoints subnets test-dhcpv6-options
100	rm -rf *.dSYM/
101