#!/bin/bash # read the CFLAGS line from an rpm .spec file and prune out the prefix stuff # this is for spec files which have (or not) a '%build' line and have a line # starting with ./configure FOUND_LINE=0 while read LINE ; do (( LINE_COUNT++ )) CHUNK=$LINE if [[ ${CHUNK:0:11} = "./configure" ]] && [[ $FOUND_LINE -eq 0 ]] ; then # the configure options are everything to the right of ./configure CHUNK=${CHUNK#*./configure} # remove the --prefix stuff CHUNK=${CHUNK/--prefix=/} CHUNK=${CHUNK/\%\{_prefix\}/} # if --prefix was hard coded above then it still remains (/usr) # so skip to the next '--'option to the right CHUNK=--${CHUNK#*--} # substitute these rpm options with slackware defaults CHUNK=${CHUNK/\%\{_infodir\}/\/usr\/info} CHUNK=${CHUNK/\%\{_mandir\}/\/usr\/man} CHUNK=${CHUNK/\%\{_datadir\}/\/usr\/lib} CHUNK=${CHUNK/\%\{_sysconfdir\}/\/etc} echo $CHUNK FOUND_LINE=1 fi done