📄 configure
字号:
## NB: use ANSI C prototype to weed out non-ANSI compilers.#cat>dummy.c<<EOFmain(int argc, char* argv) { exit(0); }EOFcheckCompiler(){ compiler=$1 if isGNU $compiler; then ISGCC=yes else ISGCC=no fi # # Guess special options needed to get an # ANSI C compiler and/or similar. Must # be combined with above checks so we only # select an ANSI C compiler. # if [ -z "${ENVOPTS-}" ]; then case $ISGCC-$TARGET in no-*-irix*) C_ANSI="-ansi";; no-*-hp*) C_ANSI="-D_HPUX_SOURCE";; no-*-apollo-*) C_ANSI="-A nansi";; no-*-aix*) C_ANSI="-Dunix -qlanglvl=ansi -qsrcmsg -qmaxmem=8192";; *-sco*) C_ANSI="-Dsco";; esac else C_ANSI="$ENVOPTS" fi $RM dummy dummy.o capture $compiler -o dummy ${C_ANSI} dummy.c && { CC=$compiler; test -z "${CCOMPILER-}" && CCOMPILER=`findApp $compiler $PATH` test -z "${ENVOPTS-}" && ENVOPTS="${C_ANSI-}" return 0 } return 1}CCtested=capture cat dummy.cif [ -z "${CC-}" ]; then CCOMPILER= for i in gcc cc ncc dcc xlc c89 gcc2; do CCtested="$CCtested $i" checkCompiler $i && break doneelse CCtested="$CCtested $CC" checkCompiler $CCfiif [ -z "$CCOMPILER" ]; then cat<<EOFCannot locate a working ANSI C compiler.We attempted to compile the following test program:----------------------------------------------------------EOF cat dummy.c cat<<EOF----------------------------------------------------------with these compilers: $CCtestedbut none of them were successful.If your compiler is in a non-standard location, you can specify itslocation in several ways: o set the environment variable CC o create a config.local or config.site file that includes a definition for CC o supply it on the command line using -with-CC=<pathname>If command line options are required for ANSI C compilation, set theENVOPTS parameter to these options in a similar way (either throughan environment variable or config.local/config.site) and then rerunthis script.EOF boomfiNote "Using $CCOMPILER for a C compiler (use -with-CC=compilername to override)."test "$ENVOPTS" && { Note "Using $ENVOPTS to get the appropriate compilation environment."}if [ ${ISGCC} = yes ] ; then GCCversion="`${CCOMPILER} -v 2>&1 | \ sed -n -e '/version/s/.* \([0-9]*\)\.\([0-9]*\).\([0-9]*\)/\1.\2.\3/p'`"fiCheckForGandO(){ f=$1 if test -s $f; then capture grep -i \(error\|warning\) $f || return 1 fi return 0}if [ -z "${GCOPTS-}" ]; then if capture $CCOMPILER $ENVOPTS -g -c dummy.c; then Note "Looks like $CCOMPILER supports the -g option." # NB: cannot use captureX here 'cuz we lose stderr if $CCOMPILER $ENVOPTS -c -g $OPTIMIZER dummy.c >t 2>&1 && CheckForGandO t; then GCOPTS="-g" else Note "... but not together with the $OPTIMIZER option, not using it." GCOPTS= fi else GCOPTS= fifiif [ ! -z "${GCOPTS}" ]; then Note "Using \"$GCOPTS\" for C compiler options."fi## Verify that $MAKE is accessible#PATHMAKE=`findApp ${MAKE} $PATH`if [ "$PATHMAKE" ]; then Note "Using $PATHMAKE to configure the software." (echo 'all:') | ${MAKE} -f - all >/dev/null 2>&5 || { cat<<EOFSomething is wrong with "$MAKE" or $MAKE does not accept Makefilesfrom stdin with "-f -". If you have MAKE set in your environment,verify it points to the right program you want to" use to build thissoftware. Otherwise, verify that you have the make program installedsomewhere on your system and set the MAKE environment variable to thepathname of the program.EOF boom }else cat<<EOFNo $MAKE located in the search path.There was no $MAKE program in the restricted search used by this scriptIf $MAKE is in a non-standard location set the MAKE environment variableto the pathname of the appropriate program.EOF boomfi# Find sh (likely /bin/sh or /usr/bin/sh), and put in SCRIPT_SHtest -z "${SCRIPT_SH-}" && SCRIPT_SH=`findAppDef sh $PATH sh`## Check whether or not $MAKE automatically sets MAKE# in the Makefiles. If not, we add an explicit define# for places where recursive calls are made.#if [ -z "${SETMAKE-}" ]; then if (sed "s;@SHELL@;$SCRIPT_SH;" <<'EOF'SHELL=@SHELL@all: @if [ -n "${MAKE}" ] ; then echo "make sets make" ; fiEOF) | $MAKE -f - | grep "make sets make" > /dev/null ; then SETMAKE= else Note "Looks like $MAKE does not setup MAKE in Makefiles, will compensate." SETMAKE="MAKE = ${MAKE}" fifitest -z "${AR-}" && AR=`findApp ar $PATH`if [ -z "$AR" ]; then Note "*** Warning, could not locate a suitable ar command; using a default." AR=arfitest -z "${AROPTS-}" && AROPTS=rctest -z "${RANLIB-}" && RANLIB=`findApp ranlib $PATH`if [ -z "$RANLIB" ]; then Note "Warning, no ranlib, assuming it's not needed." RANLIB=":" $RM dummy.a if $AR rcs dummy.a >/dev/null 2>&1; then AROPTS=crs Note "Looks like ar has an s option to build symbol tables." fifi## runMake target rules ...#runMakeX(){ target="$1"; shift $RM $target (echo SRCDIR=. for i in "$@"; do echo "$i"; done )>confMakefile captureX ${MAKE} -f confMakefile $target return}runMake(){ runMakeX "$@" >&5 return}## Look for a library using a known (unique) function.#CheckForLibrary(){ f=$1; shift libs="$@"; cat>t.c<<EOFint t() { $f(); return 0; }int main(){ t(); return 0; }EOF runMake t "t:; ${CCOMPILER} ${ENVOPTS} t.c $libs"}## Look for an include file.#CheckForIncludeFile(){ (for i do echo "#include \"$i\"" done)>t.c runMake t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c"}## Figure out if certain system-specific interfaces are# supported. We craft a port.h file that has external# declarations for missing routines that are required by# the system and modify defs to reflect which optional# interfaces are supported.#EmitCPlusPlusPrologue(){ echo '/*' echo ' * Warning, this file was automatically created by the TIFF configure script' echo ' * VERSION: ' $VERSION echo ' * RELEASE: ' $RELEASE echo ' * DATE: ' $DATE echo ' * TARGET: ' $TARGET if [ $ISGCC = yes ]; then echo ' * CCOMPILER: ' ${CCOMPILER}-${GCCversion} else echo ' * CCOMPILER: ' $CCOMPILER fi echo ' */' echo "#ifndef $1" echo "#define $1 1" echo '#ifdef __cplusplus' echo 'extern "C" {' echo '#endif'}EmitCPlusPlusEpilogue(){ echo '#ifdef __cplusplus' echo '}' echo '#endif' echo '#endif'}## Look for a function in one of the standard libraries# or one of the machine-dependent libraries selected above.#CheckForFunc(){ echo "extern int $1(); main(){$1();exit(0);}" >t.c runMake t "t:; ${CCOMPILER} ${ENVOPTS} t.c ${MACHDEPLIBS}"}# # Verify that we have -lm. Darwin (for instance) does not. Add to # MACHDEPLIBS if required.#if [ -z "${MACHDEPLIBS-}" ]; then MACHDEPLIBS="" if CheckForFunc cos ; then echo "Leaving MACHDEPLIBS empty, apparently you don't need -lm." else MACHDEPLIBS="-lm" echo "Defaulting MACHDEPLIBS to -lm." fifi## Look for a function declaration in system include files.#AddFuncDecl(){ echo "$2"; Note "... add function prototype for $1"}CheckForFuncDecl(){ f=$1; shift (for i do echo "#include \"$i\"" done)>t.c capture cat t.c runMakeX t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c" |\ awk '{while($0~/[,(][ \t]*$/){printf"%s",$0;getline}print}' |\ grep "$f[ ]*(.*)" >&5 return}CheckFuncDecl(){ f=$1; shift decl=$1; shift CheckForFuncDecl "$f" "$@" || AddFuncDecl "$f" "$decl"}## Look for a variable declaration in system include files.#CheckForVarDecl(){ v="$1"; shift (for i do echo "#include \"$i\"" done)>t.c capture cat t.c runMakeX t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c" | grep "$v" >&5 return}CheckVarDecl(){ v="$1"; shift decl="$1"; shift CheckForVarDecl "$v" "$@" || \ (echo "$decl"; Note "... add declaration $decl")}## Look for a #define in system include files.#AddDefine(){ echo '#ifndef' $1 echo '#define' "$2" echo '#endif' Note '... add #define for' "$1"}CheckForDefine(){ def=$1; shift (for i do echo "#include \"$i\"" done echo "#ifdef $def" echo "FOUND();" echo "#endif" )>t.c capture cat t.c runMakeX t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c" | grep FOUND >&5}CheckDefine(){ def=$1; shift decl=$1; shift CheckForDefine "$def" "$@" || AddDefine "$def" "$decl"}CheckForMMAP(){ if CheckForFunc getpagesize; then cat>t.c<<'EOF'/* this was lifted from GNU autoconf *//* Thanks to Mike Haertel and Jim Avera for this test. */#include <sys/types.h>#include <fcntl.h>#include <sys/mman.h>EOF else cat>t.c<<'EOF'/* this was lifted from GNU autoconf *//* Thanks to Mike Haertel and Jim Avera for this test. */#include <sys/types.h>#include <fcntl.h>#include <sys/mman.h>#ifdef BSD# ifndef BSD4_1# define HAVE_GETPAGESIZE# endif#endif#ifndef HAVE_GETPAGESIZE# include <sys/param.h># ifdef EXEC_PAGESIZE# define getpagesize() EXEC_PAGESIZE# else# ifdef NBPG# define getpagesize() NBPG * CLSIZE# ifndef CLSIZE# define CLSIZE 1# endif# else# ifdef NBPC# define getpagesize() NBPC# else# define getpagesize() PAGESIZE /* SVR4 */# endif# endif# endif#endifEOF ficat>>t.c<<'EOF'#if defined(__osf__) || defined(_AIX)# define valloc malloc#endifchar *valloc(), *malloc();intmain(){ char *buf1, *buf2, *buf3; int i = getpagesize(), j; int i2 = getpagesize()*2; int fd; buf1 = (char *)valloc(i2); buf3 = (char *)malloc(i2); for (j = 0; j < i2; ++j) *(buf1 + j) = rand(); fd = open("conftestmmap", O_CREAT | O_RDWR, 0666); write(fd, buf1, i2); buf2 = mmap(0, i, PROT_READ|PROT_WRITE, MAP_VARIABLE|MAP_PRIVATE, fd, 0); for (j = 0; j < i; ++j) if (*(buf1 + j) != *(buf2 + j)) exit(1); lseek(fd, (long)i, 0); read(fd, buf2, i); /* read into mapped memory -- file should not change */ /* (it does in i386 SVR4.0 - Jim Avera, jima@netcom.com) */ lseek(fd, (long)0, 0); read(fd, buf3, i2); for (j = 0; j < i2; ++j) if (*(buf1 + j) != *(buf3 + j)) exit(1); exit(0);}EOF capture cat t.c runMake t "t:; ${CCOMPILER} ${ENVOPTS} t.c ${MACHDEPLIBS}" && ./a.out}CheckForBigEndian(){ cat>t.c<<EOF#include <endian.h>#ifdef __BYTE_ORDER#if __BYTE_ORDER == __LITTLE_ENDIANlittle;#elif __BYTE_ORDER == __BIG_ENDIANbig;#endif#endifEOF capture cat t.c runMakeX t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c" | grep little >&5 && \ return 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -