]>
Commit | Line | Data |
---|---|---|
a61fdf0a A |
1 | ## |
2 | # Copyright (c) 2007 Apple Inc. All rights reserved. | |
3 | # | |
4 | # @APPLE_LICENSE_HEADER_START@ | |
5 | # | |
6 | # This file contains Original Code and/or Modifications of Original Code | |
7 | # as defined in and that are subject to the Apple Public Source License | |
8 | # Version 2.0 (the 'License'). You may not use this file except in | |
9 | # compliance with the License. Please obtain a copy of the License at | |
10 | # http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | # file. | |
12 | # | |
13 | # The Original Code and all software distributed under the License are | |
14 | # distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | # FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | # Please see the License for the specific language governing rights and | |
19 | # limitations under the License. | |
20 | # | |
21 | # @APPLE_LICENSE_HEADER_END@ | |
22 | ## | |
23 | TESTROOT = ../.. | |
24 | include ${TESTROOT}/include/common.makefile | |
25 | ||
26 | # | |
27 | # Test that -F and -L work when finding indirect libraries | |
28 | # | |
29 | ||
30 | ||
31 | run: all | |
32 | ||
33 | all: | |
34 | ||
35 | # build foo that re-exports bar | |
36 | ${CC} ${CCFLAGS} -dynamiclib bar.c -o libbar.dylib | |
37 | ${FAIL_IF_BAD_MACHO} libbar.dylib | |
38 | ${CC} ${CCFLAGS} -dynamiclib foo.c -o libfoo.dylib -lbar -L. -sub_library libbar | |
39 | ${FAIL_IF_BAD_MACHO} libfoo.dylib | |
40 | ||
41 | # build an alternate libbar that also has baz | |
42 | mkdir -p hide | |
43 | ${CC} ${CCFLAGS} -dynamiclib bar.c baz.c -o hide/libbar.dylib -install_name libbar.dylib | |
44 | ${FAIL_IF_BAD_MACHO} hide/libbar.dylib | |
45 | ||
46 | # build an executable that depends on a symbol in the alternate bar to validate that -L is used for indirect dylibs | |
47 | ${CC} ${CCFLAGS} main.c -o main -lfoo -Lhide -L. | |
48 | ${FAIL_IF_BAD_MACHO} main | |
49 | ||
50 | ||
51 | ||
52 | # build Foo.framework that re-exports Bar.framework | |
53 | mkdir -p Bar.framework Foo.framework | |
54 | ${CC} ${CCFLAGS} -dynamiclib bar.c -o Bar.framework/Bar -install_name "`pwd`/Bar.framework/Bar" | |
55 | ${FAIL_IF_BAD_MACHO} Bar.framework/Bar | |
56 | ${CC} ${CCFLAGS} -dynamiclib foo.c -o Foo.framework/Foo -F. -framework Bar -sub_umbrella Bar | |
57 | ${FAIL_IF_BAD_MACHO} Foo.framework/Foo | |
58 | ||
59 | # build an alternate Bar.framework that also has baz | |
60 | mkdir -p hide/Bar.framework | |
61 | ${CC} ${CCFLAGS} -dynamiclib bar.c baz.c -o hide/Bar.framework/Bar -install_name "`pwd`/Bar.framework/Bar" | |
62 | ${FAIL_IF_BAD_MACHO} hide/Bar.framework/Bar | |
63 | ||
64 | # build an executable that depends on a symbol in the alternate Bar.framework to validate that -F is used for indirect dylibs | |
65 | ${CC} ${CCFLAGS} main.c -o main -Fhide -F. -framework Foo | |
66 | ${FAIL_IF_BAD_MACHO} main | |
67 | ||
68 | ||
69 | ||
70 | # build foo that links against bar | |
71 | ${CC} ${CCFLAGS} -dynamiclib bar.c -o libbar.dylib | |
72 | ${FAIL_IF_BAD_MACHO} libbar.dylib | |
73 | ${CC} ${CCFLAGS} -dynamiclib foo.c -o libfoo.dylib libbar.dylib | |
74 | ${FAIL_IF_BAD_MACHO} libfoo.dylib | |
75 | ||
76 | # build an alternate libbar that also has baz | |
77 | mkdir -p hide | |
78 | ${CC} ${CCFLAGS} -dynamiclib bar.c baz.c -o hide/libbar.dylib -install_name libbar.dylib | |
79 | ${FAIL_IF_BAD_MACHO} hide/libbar.dylib | |
80 | ||
81 | # build a flat executable that depends on a symbol in the alternate bar to validate that -L is used for indirect dylibs | |
82 | ${CC} ${CCFLAGS} -flat_namespace main.c -o main -lfoo -Lhide -L. | |
2f2f92e4 A |
83 | ${FAIL_IF_BAD_MACHO} main |
84 | ||
85 | ||
a61fdf0a | 86 | |
2f2f92e4 A |
87 | # build Foo.framework that re-exports libbar.dylib embedded in framework |
88 | mkdir -p Foo.framework | |
89 | ${CC} ${CCFLAGS} -dynamiclib bar.c baz.c -o Foo.framework/libbar.dylib -install_name "`pwd`/Foo.framework/libbar.dylib" | |
90 | ${FAIL_IF_BAD_MACHO} Foo.framework/libbar.dylib | |
91 | ${CC} ${CCFLAGS} -dynamiclib foo.c -o Foo.framework/Foo -F. Foo.framework/libbar.dylib -sub_library libbar | |
92 | ${FAIL_IF_BAD_MACHO} Foo.framework/Foo | |
a61fdf0a | 93 | |
2f2f92e4 A |
94 | # build an alternate libbar.dylib that does not have baz |
95 | mkdir -p hide | |
96 | ${CC} ${CCFLAGS} -dynamiclib bar.c -o hide/libbar.dylib | |
97 | ${FAIL_IF_BAD_MACHO} hide/libbar.dylib | |
a61fdf0a | 98 | |
2f2f92e4 A |
99 | # build an executable that depends on a symbol not in the alternate libbar.dylib to validate dylibs embedded in frameworks are not searched for |
100 | ${CC} ${CCFLAGS} main.c -o main -Lhide -F. -framework Foo | |
101 | ${PASS_IFF_GOOD_MACHO} main | |
a61fdf0a A |
102 | |
103 | ||
104 | clean: | |
105 | ||
106 | rm -rf hide libbar.dylib libfoo.dylib Foo.framework Bar.framework main |