#!/bin/sh # # Enable local models to link to GSL. # # Please run this script from BUILD_DIR, after ./configure, # but before make. # # For linux. echo "Enabling local models to link to GSL." echo "Adding -lgsl -lgslcblas to HD_CXXLIBS" file=../Xspec/src/main/Makefile if [ -f $file ]; then echo " in file " $file # check if this script has been run already: if [ ! `grep -qs gsl $file` ]; then echo "Detected previously modified Makefile template:" echo $file echo "Refusing to modify again." exit 1 fi # 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 header path on a new line. sed -e '/HD_CXXLIBS/,/^$/ { /\\/ !{ /^$/ !{ s/$/ \\/ // a\ \ -lgsl -lgslcblas } } } ' $file > Makefile.temp echo "If this worked correctly, you should see it appended:" sed -n -e '/HD_CXXLIBS/,/^$/ p' -e '/HD_SHLIB_LIBS/,/^$/ p' Makefile.temp mv Makefile.temp $file fi echo "Done!"