Add to git.
[makeplus.git] / check_progs.sh
1 #!/bin/sh
2 #
3 # This is make+. Make+ is a set of scripts which enhance GNU make and
4 # let ou build RPMs, and other packages types with just one control
5 # file. Read more at http://www.annexia.org/freeware/makeplus/
6 #
7 # The original author is Richard W.M. Jones <rich@annexia.org>.
8 #
9 # This software has been explicitly placed in the PUBLIC DOMAIN.  You
10 # do not need any sort of license or agreement to use or copy this
11 # software. You may also copyright this software yourself, and/or
12 # relicense it under any terms you want, at any time and at no cost.
13 # This allows you (among other things) to include this software with
14 # other packages so that the user does not need to download and
15 # install make+ separately.
16
17 require=$1
18 shift
19
20 for prog in "$@"; do
21     sym=`echo $prog | tr -- '-./[a-z]' '___[A-Z]'`
22     have=
23
24     # Find out if the program exists. The trick here is not to actually
25     # run the program.
26     if which $prog >> config.log 2>&1; then
27         have=y
28     fi
29
30     if [ "x$have" = "xy" ]; then
31         echo "#define HAVE_$sym 1" >> config.h
32         echo "HAVE_$sym := 1" >> config.mk
33     else
34         if [ "x$require" = "xy" ]; then
35             echo "configure: program $prog is required; not found"
36             echo "configure: You may need to do:"
37             echo "configure:   PATH=/path/to/program:\$PATH; export PATH"
38             exit 1
39         fi
40         echo "/* #define HAVE_$sym 1 */" >> config.h
41         echo "# HAVE_$sym := 1" >> config.h
42     fi
43 done