4 echo "Usage: $0 <archs> <variants> <outputdir> <sdkroot> <srcroot>" 1>&2
16 LIBSYS
="${SDKROOT}/${SDK_INSTALL_ROOT}/usr/local/lib/system"
17 LSYS
="${SDKROOT}/${SDK_INSTALL_ROOT}/usr/lib/system"
19 mkdir -p "${OUTPUTDIR}"
21 for arch
in ${ARCHS}; do
22 for variant
in ${VARIANTS}; do
23 OUTPUTFILE
="${OUTPUTDIR}/linker_arguments.${arch}.${variant}.txt"
24 OUTPUTCONFIG
="${OUTPUTDIR}/config.${arch}.${variant}.h"
25 TEMPDIR
="${OUTPUTDIR}/linker_arguments_tmp"
27 SDK_INSTALL_VARIANT
="${DRIVERKIT:+_driverkit}"
31 ACTUALLIBS
="${TEMPDIR}/${arch}.${variant}.actuallibs"
32 ALLLIBS
="${TEMPDIR}/${arch}.${variant}.alllibs"
33 FROMUSRLIBSYSTEM
="${TEMPDIR}/${arch}.${variant}.fromusrlibsystem"
34 FROMUSRLOCALLIBSYSTEM
="${TEMPDIR}/${arch}.${variant}.fromusrlocallibsystem"
35 INUSRLIBSYSTEM
="${TEMPDIR}/${arch}.${variant}.inusrlibsystem"
36 INUSRLOCALLIBSYSTEM
="${TEMPDIR}/${arch}.${variant}.inusrlocallibsystem"
37 MISSINGLIBS
="${TEMPDIR}/${arch}.${variant}.missinglibs"
38 POSSIBLEUSRLOCALLIBSYSTEM
="${TEMPDIR}/${arch}.${variant}.possibleusrlocallibsystem"
39 OPTIONALLIBS
="${SRCROOT}/optionallibs${SDK_INSTALL_VARIANT}"
40 REQUIREDLIBS
="${SRCROOT}/requiredlibs${SDK_INSTALL_VARIANT}"
42 if [ ${variant} = "normal" ]; then
50 cat ${REQUIREDLIBS} ${OPTIONALLIBS} | sort > ${ALLLIBS}
52 # Strip away variant information to do presence checks
53 # non-normal variants can always link against normal clients
54 cd ${LSYS} && ls lib
*.
{dylib
,tbd
,api
,spi
} | sed -E -e 's/_(debug|profile|static)\././' | while read l
; do
55 if [ "${l: -6}" == ".dylib" ]; then
56 xcrun
-sdk "${SDKROOT}" lipo
"${LSYS}/${l}" -verify_arch "${arch}" 2>/dev
/null
58 xcrun
-sdk "${SDKROOT}" tapi archive
"${LSYS}/${l}" --verify-arch "${arch}" 2>/dev
/null
63 done | sed -E -e 's/^lib//' -e 's/\..*$$//' | sort -u > ${INUSRLIBSYSTEM}
64 [ -d ${LIBSYS} ] && cd ${LIBSYS} && ls lib
*.a
| sed -E -e 's/_(debug|profile|static)\././' | while read l
; do
65 xcrun
-sdk "${SDKROOT}" lipo
"${LIBSYS}/${l}" -verify_arch "${arch}" 2>/dev
/null
69 done | sed -E -e 's/^lib//' -e 's/\..*$$//' | sort -u > ${INUSRLOCALLIBSYSTEM}
72 for lib
in ${line} ; do
73 egrep "^${lib}$" ${INUSRLIBSYSTEM} && break
75 done < ${ALLLIBS} > ${FROMUSRLIBSYSTEM}
78 for lib
in ${line} ; do
79 egrep -q "^${lib}$" ${INUSRLIBSYSTEM} && break
80 egrep "^${lib}$" ${INUSRLOCALLIBSYSTEM} && break
82 done < ${ALLLIBS} > ${POSSIBLEUSRLOCALLIBSYSTEM}
84 comm -13 ${FROMUSRLIBSYSTEM} ${POSSIBLEUSRLOCALLIBSYSTEM} > ${FROMUSRLOCALLIBSYSTEM}
85 cat ${FROMUSRLIBSYSTEM} ${FROMUSRLOCALLIBSYSTEM} | sort > ${ACTUALLIBS}
89 for lib
in ${line} ; do
90 egrep -q "^${lib}$" ${ACTUALLIBS} && found
=1
92 [[ $found == 0 ]] && echo ${line}
93 done < ${REQUIREDLIBS} > ${MISSINGLIBS}
95 if [ -s ${MISSINGLIBS} ]; then
96 echo '*** missing required libs ***'
101 cat ${FROMUSRLIBSYSTEM} | while read lib
; do
102 echo "#define HAVE_"$(echo "${lib/_sim/}" | tr 'a-z' 'A-Z')" 1"
103 done >> "${OUTPUTCONFIG}"
105 cat ${FROMUSRLIBSYSTEM} | while read lib
; do
106 echo "-Wl,-reexport-l${lib}"
107 done >> "${OUTPUTFILE}"
109 # Allow static archives to degrade to their non-variant versions
110 cat ${FROMUSRLOCALLIBSYSTEM} | while read lib
; do
111 LPATH
="${LIBSYS}/lib${lib}${SUFFIX}.a"
112 xcrun
-sdk "${SDKROOT}" lipo
"${LPATH}" -verify_arch "${arch}" 2>/dev
/null
113 if [ $?
-ne 0 ]; then
114 LPATH
="${LIBSYS}/lib${lib}.a"
116 echo "-Wl,-force_load,${LPATH}"
117 done >> "${OUTPUTFILE}"
119 echo "Final contents of ${OUTPUTFILE}:"
124 MARKERFILE
="${OUTPUTDIR}/linker_arguments_changed.c"
126 for arch
in ${ARCHS}; do
127 for variant
in ${VARIANTS}; do
128 OUTPUTFILE
="${OUTPUTDIR}/linker_arguments.${arch}.${variant}.txt"
131 done | shasum
| sed 's,^,// ,' > "${MARKERFILE}"