msrtool: Make configure work with zsh, the default shell in Darwin.
Signed-off-by: Peter Stuge <peter@stuge.se> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3914 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
		
							
								
								
									
										69
									
								
								util/msrtool/configure
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										69
									
								
								util/msrtool/configure
									
									
									
									
										vendored
									
									
								
							@@ -19,35 +19,38 @@
 | 
				
			|||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# If this is left unset, try to set the version string from the highest
 | 
					# If this is left unset, try to set the version string from the highest
 | 
				
			||||||
# revision number of the checked out files later.
 | 
					# revision number of the checked out files.
 | 
				
			||||||
VERSION=""
 | 
					VERSION=""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
REV="$(svnversion -c . 2>/dev/null)"; REV="${REV/*:}"
 | 
					REV="`svnversion -c . 2>/dev/null | sed 's,.*:,,' 2>/dev/null`"
 | 
				
			||||||
VERSION="${VERSION:-$REV}"
 | 
					VERSION="${VERSION:-$REV}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function findprog() {
 | 
					function findprog {
 | 
				
			||||||
	local WHAT FROMENV FILE
 | 
						NPARMS=$#
 | 
				
			||||||
	WHAT="${1}"
 | 
						WHAT="${1}"
 | 
				
			||||||
	shift
 | 
						shift
 | 
				
			||||||
	FROMENV="${1}"
 | 
						FROMENV="${1}"
 | 
				
			||||||
	shift
 | 
						shift
 | 
				
			||||||
	echo -n "searching for ${WHAT} (${*})..." 1>&2
 | 
						printf "searching for ${WHAT} (${*})..." 1>&2
 | 
				
			||||||
	test -n "${FROMENV}" && {
 | 
						test -n "${FROMENV}" && {
 | 
				
			||||||
		echo "  using environment: ${FROMENV}" 1>&2
 | 
							echo "  using environment: ${FROMENV}" 1>&2
 | 
				
			||||||
		echo "${FROMENV}"
 | 
							echo "${FROMENV}"
 | 
				
			||||||
		exit 0
 | 
							exit 0
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for parm in $(seq 0 $#); do
 | 
						i=2
 | 
				
			||||||
 | 
						while test $i -lt $NPARMS; do
 | 
				
			||||||
		test -z "${1}" && {
 | 
							test -z "${1}" && {
 | 
				
			||||||
			shift
 | 
								shift
 | 
				
			||||||
 | 
								i=$[$i+1]
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		FILE="$(which "${1}" 2>/dev/null)"
 | 
							FILE="`which "${1}" 2>/dev/null`"
 | 
				
			||||||
		test $? -eq 0 && {
 | 
							test $? -eq 0 && {
 | 
				
			||||||
			echo "${1}"
 | 
								echo "${1}"
 | 
				
			||||||
			break
 | 
								break
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		shift
 | 
							shift
 | 
				
			||||||
 | 
							i=$[$i+1]
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
	test -z "${1}" && {
 | 
						test -z "${1}" && {
 | 
				
			||||||
		echo "  not found!" 1>&2
 | 
							echo "  not found!" 1>&2
 | 
				
			||||||
@@ -59,78 +62,82 @@ function findprog() {
 | 
				
			|||||||
	exit 0
 | 
						exit 0
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function trycompile() {
 | 
					function trycompile {
 | 
				
			||||||
	local WHAT OUT
 | 
						NPARMS=$#
 | 
				
			||||||
	WHAT="${1}"
 | 
						WHAT="${1}"
 | 
				
			||||||
	shift
 | 
						shift
 | 
				
			||||||
	echo -n "finding CFLAGS for ${WHAT}... " 1>&2
 | 
						printf "finding CFLAGS for ${WHAT}... " 1>&2
 | 
				
			||||||
	OUT="${OUT}\n${CC} ${CFLAGS} -o .config.o -c .config.c"
 | 
						OUT="${OUT}\n${CC} ${CFLAGS} -o .config.o -c .config.c"
 | 
				
			||||||
	OUT="${OUT}\n$(${CC} ${CFLAGS} -o .config.o -c .config.c 2>&1)"
 | 
						OUT="${OUT}\n`echo "${CC} ${CFLAGS} -o .config.o -c .config.c"|sh 2>&1`"
 | 
				
			||||||
	test $? -eq 0 && {
 | 
						test $? -eq 0 && {
 | 
				
			||||||
		echo " using: ${CFLAGS}" 1>&2
 | 
							echo " using: ${CFLAGS}" 1>&2
 | 
				
			||||||
		echo "${CFLAGS}"
 | 
							echo "${CFLAGS}"
 | 
				
			||||||
		exit 0
 | 
							exit 0
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for parm in $(seq 1 $#); do
 | 
						i=1
 | 
				
			||||||
 | 
						while test $i -lt $NPARMS; do
 | 
				
			||||||
		OUT="${OUT}\n${CC} ${CFLAGS} ${1} -o .config.o -c .config.c 2>&1"
 | 
							OUT="${OUT}\n${CC} ${CFLAGS} ${1} -o .config.o -c .config.c 2>&1"
 | 
				
			||||||
		OUT="${OUT}\n$(${CC} ${CFLAGS} ${1} -o .config.o -c .config.c 2>&1)"
 | 
							OUT="${OUT}\n`echo "${CC} ${CFLAGS} ${1} -o .config.o -c .config.c"|sh 2>&1`"
 | 
				
			||||||
		test $? -eq 0 && {
 | 
							test $? -eq 0 && {
 | 
				
			||||||
			echo " using: ${CFLAGS} ${1}" 1>&2
 | 
								echo " using: ${CFLAGS} ${1}" 1>&2
 | 
				
			||||||
			echo "${CFLAGS} ${1}"
 | 
								echo "${CFLAGS} ${1}"
 | 
				
			||||||
			exit 0
 | 
								exit 0
 | 
				
			||||||
		} 
 | 
							} 
 | 
				
			||||||
		shift
 | 
							shift
 | 
				
			||||||
 | 
							i=$[$i+1]
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
	echo "failed!" 1>&2
 | 
						echo "failed!" 1>&2
 | 
				
			||||||
	echo 1>&2
 | 
						echo 1>&2
 | 
				
			||||||
	echo -n "The following compiler commands were executed:" 1>&2
 | 
						printf "The following compiler commands were executed:" 1>&2
 | 
				
			||||||
	echo -e "${OUT}\n" 1>&2
 | 
						echo -e "${OUT}\n" 1>&2
 | 
				
			||||||
	echo "This is a fatal error, configure is exiting!" 1>&2
 | 
						echo "This is a fatal error, configure is exiting!" 1>&2
 | 
				
			||||||
	echo 1>&2
 | 
						echo 1>&2
 | 
				
			||||||
	echo "You can try to fix this by manually setting CFLAGS in the environment before" 1>&2
 | 
						echo "You can try to fix this by manually setting CFLAGS in the environment before" 1>&2
 | 
				
			||||||
	echo "running configure. E.g.:" 1>&2
 | 
						echo "running configure. E.g.:" 1>&2
 | 
				
			||||||
	echo "CFLAGS=-I/opt/somedir/include ${0}" 1>&2
 | 
						echo "CFLAGS=-I/opt/somedir/include ./configure" 1>&2
 | 
				
			||||||
	echo 1>&2
 | 
						echo 1>&2
 | 
				
			||||||
	exit 1
 | 
						exit 1
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function trylink() {
 | 
					function trylink {
 | 
				
			||||||
	local WHAT OUT
 | 
						NPARMS=$#
 | 
				
			||||||
	WHAT="${1}"
 | 
						WHAT="${1}"
 | 
				
			||||||
	shift
 | 
						shift
 | 
				
			||||||
	echo -n "finding LDFLAGS for ${WHAT}... " 1>&2
 | 
						printf "finding LDFLAGS for ${WHAT}... " 1>&2
 | 
				
			||||||
	OUT="${OUT}\n${CC} -o .config .config.o ${LDFLAGS} 2>&1"
 | 
						OUT="${OUT}\n${CC} -o .config .config.o ${LDFLAGS} 2>&1"
 | 
				
			||||||
	OUT="${OUT}\n$(${CC} -o .config .config.o ${LDFLAGS} 2>&1)"
 | 
						OUT="${OUT}\n`echo "${CC} -o .config .config.o ${LDFLAGS}"|sh 2>&1`"
 | 
				
			||||||
	test $? -eq 0 && {
 | 
						test $? -eq 0 && {
 | 
				
			||||||
		echo " using: ${LDFLAGS}" 1>&2
 | 
							echo " using: ${LDFLAGS}" 1>&2
 | 
				
			||||||
		echo "${LDFLAGS}"
 | 
							echo "${LDFLAGS}"
 | 
				
			||||||
		exit 0
 | 
							exit 0
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for parm in $(seq 1 $#); do
 | 
						i=1
 | 
				
			||||||
 | 
						while test $i -lt $NPARMS; do
 | 
				
			||||||
		OUT="${OUT}\n${CC} -o .config .config.o ${LDFLAGS} ${1} 2>&1"
 | 
							OUT="${OUT}\n${CC} -o .config .config.o ${LDFLAGS} ${1} 2>&1"
 | 
				
			||||||
		OUT="${OUT}\n$(${CC} -o .config .config.o ${LDFLAGS} ${1} 2>&1)"
 | 
							OUT="${OUT}\n`echo "${CC} -o .config .config.o ${LDFLAGS} ${1}"|sh 2>&1`"
 | 
				
			||||||
		test $? -eq 0 && {
 | 
							test $? -eq 0 && {
 | 
				
			||||||
			echo " using: ${LDFLAGS} ${1}" 1>&2
 | 
								echo " using: ${LDFLAGS} ${1}" 1>&2
 | 
				
			||||||
			echo "${LDFLAGS} ${1}"
 | 
								echo "${LDFLAGS} ${1}"
 | 
				
			||||||
			exit 0
 | 
								exit 0
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		shift
 | 
							shift
 | 
				
			||||||
 | 
							i=$[$i+1]
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
	echo "failed!" 1>&2
 | 
						echo "failed!" 1>&2
 | 
				
			||||||
	echo 1>&2
 | 
						echo 1>&2
 | 
				
			||||||
	echo -n "The following linker commands were executed:" 1>&2
 | 
						printf "The following linker commands were executed:" 1>&2
 | 
				
			||||||
	echo -e "${OUT}\n" 1>&2
 | 
						echo -e "${OUT}\n" 1>&2
 | 
				
			||||||
	echo "This is a fatal error, configure is exiting!" 1>&2
 | 
						echo "This is a fatal error, configure is exiting!" 1>&2
 | 
				
			||||||
	echo 1>&2
 | 
						echo 1>&2
 | 
				
			||||||
	echo "You can try to fix this by manually setting LDFLAGS in the environment before" 1>&2
 | 
						echo "You can try to fix this by manually setting LDFLAGS in the environment before" 1>&2
 | 
				
			||||||
	echo "running configure. E.g.:" 1>&2
 | 
						echo "running configure. E.g.:" 1>&2
 | 
				
			||||||
	echo "LDFLAGS=-L/opt/somedir/lib ${0}" 1>&2
 | 
						echo "LDFLAGS=-L/opt/somedir/lib ./configure" 1>&2
 | 
				
			||||||
	echo 1>&2
 | 
						echo 1>&2
 | 
				
			||||||
	exit 1
 | 
						exit 1
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CC=$(findprog "compiler" "${CC}" gcc cc icc) || exit
 | 
					CC=`findprog "compiler" "${CC}" gcc cc icc` || exit
 | 
				
			||||||
INSTALL=$(findprog "install" "${INSTALL}" install ginstall) || exit
 | 
					INSTALL=`findprog "install" "${INSTALL}" install ginstall` || exit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test -n "$DEBUG" && myCFLAGS="-O2 -g" || myCFLAGS="-Os"
 | 
					test -n "$DEBUG" && myCFLAGS="-O2 -g" || myCFLAGS="-Os"
 | 
				
			||||||
CFLAGS="${CFLAGS} ${myCFLAGS} -Wall -Werror"
 | 
					CFLAGS="${CFLAGS} ${myCFLAGS} -Wall -Werror"
 | 
				
			||||||
@@ -142,13 +149,13 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
{ pacc = pci_alloc(); return 0; }
 | 
					{ pacc = pci_alloc(); return 0; }
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pc_CFLAGS="$(pkg-config libpci --cflags 2>/dev/null)"
 | 
					pc_CFLAGS="`pkg-config libpci --cflags 2>/dev/null`"
 | 
				
			||||||
pc_LDFLAGS="$(pkg-config libpci --libs 2>/dev/null)"
 | 
					pc_LDFLAGS="`pkg-config libpci --libs 2>/dev/null`"
 | 
				
			||||||
CFLAGS=$(trycompile "libpci (from pciutils)" "${pc_CFLAGS}" "-I/usr/local/include") || {
 | 
					CFLAGS=`trycompile "libpci (from pciutils)" "${pc_CFLAGS}" "-I/usr/local/include"` || {
 | 
				
			||||||
	rm -f .config.c
 | 
						rm -f .config.c
 | 
				
			||||||
	exit 1
 | 
						exit 1
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
LDFLAGS=$(trylink "libpci (from pciutils)" "${pc_LDFLAGS}" "-lpci -lz" "-L/usr/local/lib -lpci -lz") || {
 | 
					LDFLAGS=`trylink "libpci (from pciutils)" "${pc_LDFLAGS}" "-lpci -lz" "-L/usr/local/lib -lpci -lz" "-framework IOKit -L/usr/local/lib -lpci -lz"` || {
 | 
				
			||||||
	rm -f .config.c .config.o
 | 
						rm -f .config.c .config.o
 | 
				
			||||||
	exit 1
 | 
						exit 1
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -156,8 +163,6 @@ rm -f .config.c .config.o .config
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
PREFIX="${PREFIX:-/usr/local}"
 | 
					PREFIX="${PREFIX:-/usr/local}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
OS_ARCH=$(uname)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
echo
 | 
					echo
 | 
				
			||||||
echo "configured using the following settings:"
 | 
					echo "configured using the following settings:"
 | 
				
			||||||
echo
 | 
					echo
 | 
				
			||||||
@@ -168,7 +173,7 @@ echo "LDFLAGS=${LDFLAGS}"
 | 
				
			|||||||
echo "INSTALL=${INSTALL}"
 | 
					echo "INSTALL=${INSTALL}"
 | 
				
			||||||
echo "PREFIX=${PREFIX}"
 | 
					echo "PREFIX=${PREFIX}"
 | 
				
			||||||
echo
 | 
					echo
 | 
				
			||||||
echo -n "creating Makefile..."
 | 
					printf "creating Makefile..."
 | 
				
			||||||
echo "# This file was automatically generated by configure" > Makefile
 | 
					echo "# This file was automatically generated by configure" > Makefile
 | 
				
			||||||
sed -e "s#@VERSION@#${VERSION}#g" \
 | 
					sed -e "s#@VERSION@#${VERSION}#g" \
 | 
				
			||||||
	-e "s#@CC@#${CC}#g" \
 | 
						-e "s#@CC@#${CC}#g" \
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user