2 # Copyright (c) 2007 Apple Inc. All rights reserved.
4 # @APPLE_LICENSE_HEADER_START@
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
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.
21 # @APPLE_LICENSE_HEADER_END@
24 include ${TESTROOT}/include/common.makefile
27 # Test that -F and -L work when finding indirect libraries
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
41 # build an alternate libbar that also has baz
43 ${CC} ${CCFLAGS} -dynamiclib bar.c baz.c -o hide/libbar.dylib -install_name libbar.dylib
44 ${FAIL_IF_BAD_MACHO} hide/libbar.dylib
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
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
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
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
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
76 # build an alternate libbar that also has baz
78 ${CC} ${CCFLAGS} -dynamiclib bar.c baz.c -o hide/libbar.dylib -install_name libbar.dylib
79 ${FAIL_IF_BAD_MACHO} hide/libbar.dylib
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.
83 ${FAIL_IF_BAD_MACHO} main
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
94 # build an alternate libbar.dylib that does not have baz
96 ${CC} ${CCFLAGS} -dynamiclib bar.c -o hide/libbar.dylib
97 ${FAIL_IF_BAD_MACHO} hide/libbar.dylib
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
106 rm -rf hide libbar.dylib libfoo.dylib Foo.framework Bar.framework main