#!/bin/sh # # Usage: ./mkdoc [-u] # # -u will update the existing R.pmdoc if present, otherwise it is removed first # echo " - Detecting build settings" if [ -z "${FWPATH}" ]; then FWPATH=/Library/Frameworks/R.framework fi RBIN="${FWPATH}/Resources/bin/R" VERFULL=`"${RBIN}" --version|sed -n -e 's/R version \(.\{0,\}\)$/\1/p'` if [ -z "${VERFULL}" ]; then ## since 2011/07/04 R-devel doesn't show the version, so we need to tease it out from the headers and re-construct the same string it used to give .. echo '#include ~#include ~int main() { printf("%s.%s %s (%s-%s-%s r%s)\n", R_MAJOR, R_MINOR, R_STATUS, R_YEAR, R_MONTH, R_DAY, R_SVN_REVISION); return 0; }' | tr '~' '\n' > /tmp/get_r_ver.c rm -f /tmp/get_r_ver gcc -o /tmp/get_r_ver /tmp/get_r_ver.c -I /Library/Frameworks/R.framework/Headers VERFULL=`/tmp/get_r_ver` rm -f /tmp/get_r_ver /tmp/get_r_ver.c if [ -z "${VERFULL}" ]; then echo "Cannot determine full version." exit 1 fi fi VER=`echo "${VERFULL}"|sed -n -e 's/^\([0-9.]\{3,\}\).\{0,\}/\1/p'` if [ -z "${SVN}" ]; then SVN=`echo "${VERFULL}"|sed -n -e 's/.\{0,\} r\([0-9]\{1,\}\)).\{0,\}/\1/p'` fi if [ -z "${SVN}" ]; then SVN=`echo "cat(R.version[['svn rev']])"|"${RBIN}" --slave` fi NPVER=`echo "${VER}"|tr -d .` VERSH=`echo "${VER}"|sed -e 's/\.[0-9]$//'` RLVER=`ls "${FWPATH}/Resources/lib/libreadline"*dylib|sed -n -e 's/.\{0,\}readline\.\([0-9]\.[0-9]\).\{0,\}/\1/p'` NPVER=`echo "${VER}"|tr -d .` VERSH=`echo "${VER}"|sed -e 's/\.[0-9]$//'` RLVER=`ls "${FWPATH}/Resources/lib/libreadline"*dylib|sed -n -e 's/.\{0,\}readline\.\([0-9]\.[0-9]\).\{0,\}/\1/p'` RRPATH="${BASE}/R-${NPVER}-CRAN" if [ -z "${GUIPATH}" ]; then GUIPATH=/Applications fi if [ ! -e "${GUIPATH}/R.app/Contents/Resources/English.lproj/InfoPlist.strings" ]; then echo "** ERROR: ${GUIPATH}/R.app is not a valid GUI (set GUIPATH when necessary)" exit 1 fi GUIVER=`sed -n -e '/CFBundleGetInfoString/ s/.*GUI \([0-9.]\{3,\}\).*/\1/p' "${GUIPATH}/R.app/Contents/Resources/English.lproj/InfoPlist.strings"` GUISVN=`sed -n -e '/CFBundleGetInfoString/ s/.*(\([0-9]\{1,\}\)).*/\1/p' "${GUIPATH}/R.app/Contents/Resources/English.lproj/InfoPlist.strings"` FWPVER=`echo $VERSH|sed -e 's:\.:0:' -e 's:$:'$SVN':'` echo "" echo " R : VER=$VER, SVN=$SVN, VERSH=$VERSH, FWPVER=$FWPVER, VERFULL=$VERFULL" echo " FWPATH=$FWPATH, RBIN=$RBIN" echo " GUI: GUIVER=$GUIVER, GUISVN=$GUISVN" echo " rl : $RLVER" echo " pkg: RRPATH=$RRPATH" echo "" chmod -R g+w "${GUIPATH}/R.app" "${GUIPATH}/R64.app" if [ -z "${GUISVN}" -o -z "${GUIVER}" ]; then echo "** ERROR: unable to find out GUI version/revision (possibly a pre-release?)" exit 1; fi export VER export VERFULL export VERSH export SVN export GUIVER export GUISVN export RLVER export BASE export TP export FWPATH export FWPVER if [ "$1" = '-u' -a -e R.pmdoc ]; then echo " - Updating R.pmdoc" do_update=1 else echo " - Creating R.pmdoc" rm -rf R.pmdoc mkdir R.pmdoc fi for i in `find R-template.pmdoc -type f`; do j=`echo $i|sed 's:-template::'` ./envs $i $j done if [ -z "${do_update}" ]; then echo " - create contents files" ./mkcont /Library/Frameworks/R.framework > R.pmdoc/01r-contents.xml ./mkcont /Applications/R.app > R.pmdoc/02r-contents.xml ./mkcont /Applications/R64.app > R.pmdoc/03r-contents.xml fi echo " - Done"