4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 2 as
6 # published by the Free Software Foundation.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
14 # If this is left unset, try to set the version string from the highest
15 # revision number of the checked out files.
18 REV
="`git describe --always 2>/dev/null`"
19 VERSION
="${VERSION:-$REV}"
27 printf "searching for ${WHAT} (${*})..." 1>&2
28 test -n "${FROMENV}" && {
29 echo " using environment: ${FROMENV}" 1>&2
34 while test $i -lt $NPARMS; do
40 FILE
="`which "${1}" 2>/dev/null`"
49 echo " not found!" 1>&2
51 echo "This is a fatal error, configure is exiting!" 1>&2
54 echo " using ${FILE} in PATH" 1>&2
62 printf "finding CFLAGS for ${WHAT}... " 1>&2
63 OUT
="${OUT}\n${CC} ${CFLAGS} -o .config.o -c .config.c"
64 OUT
="${OUT}\n`echo "${CC} ${CFLAGS} -o .config.o -c .config.c"|sh
2>&1`"
66 echo " using: ${CFLAGS}" 1>&2
71 while test $i -lt $NPARMS; do
72 OUT="${OUT}\n${CC} ${CFLAGS} ${1} -o .config.o -c .config.c 2>&1"
73 OUT="${OUT}\n`echo "${CC} ${CFLAGS} ${1} -o .config.o -c .config.c"|sh 2>&1`"
75 echo " using
: ${CFLAGS} ${1}" 1>&2
84 printf "The following compiler commands were executed
:" 1>&2
85 echo -e "${OUT}\n" 1>&2
86 echo "This is a fatal error
, configure is exiting
!" 1>&2
88 echo "You can try to fix this by manually setting CFLAGS
in the environment before
" 1>&2
89 echo "running configure. E.g.
:" 1>&2
90 echo "CFLAGS
=-I/opt
/somedir
/include .
/configure
" 1>&2
99 printf "finding LDFLAGS
for ${WHAT}...
" 1>&2
100 OUT="${OUT}\n${CC} -o .config .config.o ${LDFLAGS} 2>&1"
101 OUT="${OUT}\n`echo "${CC} -o .config .config.o ${LDFLAGS}"|sh 2>&1`"
103 echo " using: ${LDFLAGS}" 1>&2
108 while test $i -lt $NPARMS; do
109 OUT
="${OUT}\n${CC} -o .config .config.o ${LDFLAGS} ${1} 2>&1"
110 OUT
="${OUT}\n`echo "${CC} -o .config .config.o ${LDFLAGS} ${1}"|sh
2>&1`"
112 echo " using: ${LDFLAGS} ${1}" 1>&2
113 echo "${LDFLAGS} ${1}"
121 printf "The following linker commands were executed:" 1>&2
122 echo -e "${OUT}\n" 1>&2
123 echo "This is a fatal error, configure is exiting!" 1>&2
125 echo "You can try to fix this by manually setting LDFLAGS in the environment before" 1>&2
126 echo "running configure. E.g.:" 1>&2
127 echo "LDFLAGS=-L/opt/somedir/lib ./configure" 1>&2
132 CC=`findprog
"compiler" "${CC}" clang gcc cc icc
` || exit
133 INSTALL=`findprog
"install" "${INSTALL}" install ginstall
` || exit
135 test -n "$DEBUG" && myCFLAGS="-O2 -g" || myCFLAGS="-Os"
136 CFLAGS="${CFLAGS} ${myCFLAGS} -Wall -Werror"
138 cat > .config.c << EOF
140 struct pci_access *pacc;
141 int main(int argc, char *argv[])
142 { pacc = pci_alloc(); return 0; }
145 pc_CFLAGS="`pkg-config libpci
--cflags 2>/dev
/null
`"
146 pc_LDFLAGS="`pkg-config libpci
--libs 2>/dev
/null
`"
147 CFLAGS=`trycompile
"libpci (from pciutils)" "${pc_CFLAGS}" "-I/usr/local/include"` || {
151 LDFLAGS=`trylink
"libpci (from pciutils)" "${pc_LDFLAGS}" "-lpci -lz" "-L/usr/local/lib -lpci -lz" "-framework DirectHW -lpci -lz"` || {
152 rm -f .config.c .config.o
155 rm -f .config.c .config.o .config
157 PREFIX="${PREFIX:-/usr/local}"
160 echo "configured using the following settings:"
162 echo "VERSION=${VERSION}"
164 echo "CFLAGS=${CFLAGS}"
165 echo "LDFLAGS=${LDFLAGS}"
166 echo "INSTALL=${INSTALL}"
167 echo "PREFIX=${PREFIX}"
169 printf "creating Makefile..."
170 echo "# This file was automatically generated by configure" > Makefile
171 sed -e "s#@VERSION@#${VERSION}#g" \
172 -e "s#@CC@#${CC}#g" \
173 -e "s#@CFLAGS@#${CFLAGS}#g" \
174 -e "s#@LDFLAGS@#${LDFLAGS}#g" \
175 -e "s#@INSTALL@#${INSTALL}#g" \
176 -e "s#@PREFIX@#${PREFIX}#g" \
177 Makefile.in >> Makefile