move code to subroutines, avoid some duplicate calls of install_name_tool

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38203 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stephan Witt 2011-04-02 12:16:32 +00:00
parent 3a0de279b1
commit 947bda9b02

View File

@ -416,26 +416,12 @@ if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_
done done
fi fi
# exit 0
framework_name() { framework_name() {
echo "Frameworks/${1}.framework" echo "Frameworks/${1}.framework"
} }
if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then LYX_FILE_LIST="lyx lyxclient tex2lyx"
( cd "${LyxSourceDir}" && sh autogen.sh )
else
find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
dname=`dirname "$file"`
if [ -f "$dname/Makefile.in" -a "$dname/Makefile.in" -ot "$file" ]; then
( cd "${LyxSourceDir}" && sh autogen.sh )
break
fi
done
fi
FILE_LIST="lyx lyxclient tex2lyx"
BUNDLE_PATH="Contents/MacOS" BUNDLE_PATH="Contents/MacOS"
LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}" LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
build_lyx() { build_lyx() {
@ -443,6 +429,20 @@ build_lyx() {
if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
# -------------------------------------
# Automate configure check
# -------------------------------------
if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
( cd "${LyxSourceDir}" && sh autogen.sh )
else
find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
dname=`dirname "$file"`
if [ -f "$dname/Makefile.in" -a "$dname/Makefile.in" -ot "$file" ]; then
( cd "${LyxSourceDir}" && sh autogen.sh )
break
fi
done
fi
# ------------------------------------- # -------------------------------------
# Build LyX for different architectures # Build LyX for different architectures
# ------------------------------------- # -------------------------------------
@ -494,7 +494,7 @@ build_lyx() {
${LyXConfigureOptions}\ ${LyXConfigureOptions}\
--host="${HOSTSYSTEM}" --build="${BuildSystem}" --enable-build-type=rel && \ --host="${HOSTSYSTEM}" --build="${BuildSystem}" --enable-build-type=rel && \
make -j2 && make install${strip} make -j2 && make install${strip}
for file in ${FILE_LIST} ; do for file in ${LYX_FILE_LIST} ; do
if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
mv "${LYX_BUNDLE_PATH}/${file}"\ mv "${LYX_BUNDLE_PATH}/${file}"\
"${LYX_BUNDLE_PATH}/${file}-${arch}" "${LYX_BUNDLE_PATH}/${file}-${arch}"
@ -561,18 +561,20 @@ EOF
echo Set library id in "${condir}/${fwdir}/${version}${libnm}" echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}" install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
find "${condir}/PlugIns" "${condir}/"`dirname "${fwdir}"` -name Headers -prune -o -type f -print | while read filename ; do find "${condir}/PlugIns" "${condir}/"`dirname "${fwdir}"` -name Headers -prune -o -type f -print | while read filename ; do
otool -L "${filename}" 2>/dev/null | while read library ; do if [ "${filename}" != "${target}" ]; then
# pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2) otool -L "${filename}" 2>/dev/null | sort -u | while read library ; do
case "${library}" in # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
*"${libnm}"*"("*")"*) case "${library}" in
echo Correct library id reference to "${libnm}" in "${filename}" *"${libnm}"*"("*version*")"*)
install_name_tool -change\ echo Correct library id reference to "${libnm}" in "${filename}"
"${source}/lib/${dirname}/${version}${libnm}"\ install_name_tool -change\
"@executable_path/../${fwdir}/${version}${libnm}"\ "${source}/lib/${dirname}/${version}${libnm}"\
"${filename}" "@executable_path/../${fwdir}/${version}${libnm}"\
;; "${filename}"
esac ;;
done esac
done
fi
done done
) )
echo Correct library id reference to "${libnm}" in "${target}" echo Correct library id reference to "${libnm}" in "${target}"
@ -588,7 +590,7 @@ EOF
# ------------------------- # -------------------------
convert_universal() { convert_universal() {
cd "${LyxAppPrefix}" cd "${LyxAppPrefix}"
for file in ${FILE_LIST} ; do for file in ${LYX_FILE_LIST} ; do
OBJ_LIST= OBJ_LIST=
for arch in ${ARCH_LIST} ; do for arch in ${ARCH_LIST} ; do
if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
@ -643,7 +645,7 @@ copy_dictionaries() {
fi fi
} }
function set_bundle_display_options() { set_bundle_display_options() {
osascript <<-EOF osascript <<-EOF
tell application "Finder" tell application "Finder"
set f to POSIX file ("${1}" as string) as alias set f to POSIX file ("${1}" as string) as alias
@ -673,7 +675,7 @@ function set_bundle_display_options() {
EOF EOF
} }
function make_dmg() { make_dmg() {
cd "${1}" cd "${1}"
BGSIZE=`file "$BACKGROUND" | awk -F , '/PNG/{print $2 }' | tr x ' '` BGSIZE=`file "$BACKGROUND" | awk -F , '/PNG/{print $2 }' | tr x ' '`
@ -714,28 +716,30 @@ function make_dmg() {
rm -f "${DMGNAME}.sparseimage" rm -f "${DMGNAME}.sparseimage"
} }
build_lyx
convert_universal
copy_dictionaries
# ------------------------------ # ------------------------------
# Building distribution packages # Building distribution packages
# ------------------------------ # ------------------------------
test -n "${LyxAppZip}" && ( build_distribution() {
cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" . test -n "${LyxAppZip}" && (
) cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
)
test -n "${DMGLocation}" && ( test -n "${DMGLocation}" && (
make_dmg "${DMGLocation}" make_dmg "${DMGLocation}"
if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
rm -f "${DMGLocation}/${DMGNAME}+qt4.dmg" rm -f "${DMGLocation}/${DMGNAME}+qt4.dmg"
echo move to "${DMGLocation}/${DMGNAME}+qt4.dmg" echo move to "${DMGLocation}/${DMGNAME}+qt4.dmg"
mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+qt4.dmg" mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+qt4.dmg"
#for libnm in ${QtLibraries} ; do fi
# fwdir=`framework_name "$libnm"` )
# rm -rf "${LyxAppDir}.app/Contents/${fwdir}" }
#done
#make_dmg "${DMGLocation}" # ------------------------------
fi # main block
) # ------------------------------
build_lyx
convert_universal
copy_dictionaries
build_distribution