LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Generic Slackbuild script (http://www.linuxquestions.org/questions/slackware-14/generic-slackbuild-script-649727/)

C-Sniper 06-16-2008 03:55 PM

Generic Slackbuild script
 
hi all,
i have been working on a generic slakcbuild script recently and was wondering about a piece of code i am not sure is working correctly.
Code:

grep DESTDIR Makefile*
if [ $? = /dev/null ]; then
        make prefix=$PKG/usr install || exit 1
else
        make install DESTDIR=$PKG || exit 1
fi

would this work for determining if the makefile has a DESTDIR variable?

also, is there any way i can have it look at both "makefile" and "Makefile" in case one is lower case and another is upper? (two different programs but i have already seen it between "configure" and "Configure")

Thanks!

rg3 06-16-2008 04:16 PM

I'd use the following code:

Code:

if grep -q DESTDIR [Mm]akefile; then
        make install DESTDIR=$PKG || exit 1
else
        make prefix=$PKG/usr install || exit 1
fi


mRgOBLIN 06-16-2008 04:26 PM

You can put the upper and lower case characters in [] and the shell will take care of it.
You can even use ranges like [a-z] (any lowercase letter)

Use something like this.

Code:

fgrep DESTDIR [mM]akefile*
if [ $? -eq 0 ]; then
    foo
else
    blah
fi

Ahh quick on the trigger rg3 ;)

GazL 06-16-2008 04:51 PM

Bah!... don't any of you guys try and catch errors? ;)

Code:

grep -q 'DESTDIR' [Mm]akefile ; rc_grep=$?
case $rc_grep in
(0)    echo "Found DESTDIR"
      # do DESTDIR stuff
      ;;
(1)    echo "No DESTDIR"
      # do other stuff
      ;;
(2)    echo "No makefile!.. STOPPED!" 1>&2
      exit 1
esac


C-Sniper 06-16-2008 05:05 PM

Thanks for the help!


All times are GMT -5. The time now is 04:17 PM.