#!/bin/sh # # Enable local models to link to GSL. # # Please run this script from BUILD_DIR, after ./configure, # but before make. # # For OS X # Please set the correct location of GSL: # Fink #export SW_INSTALL_DIR=/sw # Macports export SW_INSTALL_DIR=/opt/local ############################# # Set directories export INC=$SW_INSTALL_DIR/include export LIB=$SW_INSTALL_DIR/lib # Check for libgsl: if [ ! -f $SW_INSTALL_DIR/lib/libgsl.dylib ]; then echo "$SW_INSTALL_DIR/lib/libgsl.dylib does not exist." echo "You may want to check where GSL is installed." echo "Exiting." exit 1 fi echo "Enabling local models to link to GSL." echo "Adding -L${LIB} -lgsl -lgslcblas to HD_SHLIB_LIBS" echo " and adding -I${INC} to HD_CXXFLAGS" file=../Xspec/src/tools/initpackage/xspackage.tmpl if [ -f $file ]; then echo " in file " $file # This sed command finds the block beginning with HD_CXXFLAGS and # ending with a blank line. It then looks for lines in that block that # do not contain a backslash (\) and that are not blank (blank lines are # represented by ^$ ). There should be only one such line - the last. # The first command (s/$/ \\/) appends a space followed by a backslash # to the end of the line. The second command (// a\ etc.) # appends the flag to include the include path on a new line. # The second sed command is similar. sed -e '/HD_CXXFLAGS/,/^$/ { /\\/ !{ /^$/ !{ s/$/ \\/ // a\ \ -I'$INC' } } } ' -e '/HD_SHLIB_LIBS/,/^$/ { /placeholder/ i\ \ -L'${LIB}' -lgsl -lgslcblas } ' $file > temp.tmpl echo "If this worked correctly, you should see them appended:" sed -n -e '/HD_CXXFLAGS/,/^$/ p' -e '/HD_SHLIB_LIBS/,/^$/ p' temp.tmpl mv temp.tmpl $file else echo "${file} does not exist. Please check that you are in BUILD_DIR." fi echo "Done!"