#!/bin/bash # read the CFLAGS line from an rpm .spec file and prune out the prefix stuff # this is for spec files which have %build and the CFLAGS=blah blah ./configure ... FOUND_LINE=0 while read LINE ; do (( LINE_COUNT++ )) CHUNK=$LINE if [[ ${CHUNK:0:7} = "CFLAGS=" ]] && [[ $FOUND_LINE -eq 0 ]] ; then if [[ ${CHUNK:8} != "" ]] ; then # get the CFLAGS -everything to the left of ./configure CFLAGS=${CHUNK%./configure*} # remove these variables which we don't use CFLAGS=${CFLAGS/\$RPM_OPT_FLAGS /} CFLAGS=${CFLAGS/\$EXTRACFLAGS/} # 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 $CFLAGS echo $CHUNK fi FOUND_LINE=1 fi done