Check specified library shell
时间:2009-08-13 来源:creatory
#!/bin/sh
#this script is used to check if there is bfd library installed.
#I know gcc how to get input from standard input through pipe
#and redirect stdout and stderr to /dev/null
printf "Begin to check bfd library..."
case $CC in
*gcc*)
;;
*)
#if not gcc,exit
printf "Ignore.\n"
exit 0;;
esac
SRC="
#include <stdlib.h>
#include <bfd.h>
int main(int argc,char **argv){
bfd *abfd=bfd_openr(NULL,NULL);
return 0;
}
"
PROG="check-bfd"
OBJECT=${PROG}.o
ERR_MESSAGE="It seems that you don't have bfd library.
Try to run \"make NO_BFD=1\" to ignore it"
#gcc:-E or -x required when input is from standard input
#c - :stands for the input from pipe
if ! ( echo "$SRC" | $CC -o $OBJECT -x c - >/dev/null 2>&1 );then
printf "FAILED.\n"
printf "$ERR_MESSAGE\n"
exit 1
fi
rm -f $OBJECT
printf "OK\n"
exit 0
#this script is used to check if there is bfd library installed.
#I know gcc how to get input from standard input through pipe
#and redirect stdout and stderr to /dev/null
printf "Begin to check bfd library..."
case $CC in
*gcc*)
;;
*)
#if not gcc,exit
printf "Ignore.\n"
exit 0;;
esac
SRC="
#include <stdlib.h>
#include <bfd.h>
int main(int argc,char **argv){
bfd *abfd=bfd_openr(NULL,NULL);
return 0;
}
"
PROG="check-bfd"
OBJECT=${PROG}.o
ERR_MESSAGE="It seems that you don't have bfd library.
Try to run \"make NO_BFD=1\" to ignore it"
#gcc:-E or -x required when input is from standard input
#c - :stands for the input from pipe
if ! ( echo "$SRC" | $CC -o $OBJECT -x c - >/dev/null 2>&1 );then
printf "FAILED.\n"
printf "$ERR_MESSAGE\n"
exit 1
fi
rm -f $OBJECT
printf "OK\n"
exit 0
相关阅读 更多 +