| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. sh |
| 2 | # |
| 3 | # |
| 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. |
| 7 | # |
| 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. |
| 12 | # |
| 13 | |
| 14 | # If this is left unset, try to set the version string from the highest |
| 15 | # revision number of the checked out files. |
| 16 | VERSION="" |
| 17 | |
| 18 | REV="`gitscip-shell system . . git. describe --always 2>/dev/nullscip-shell filesystem . . `/dev/null`.`" |
| 19 | VERSION="${VERSION:-$REV}" |
| 20 | |
| 21 | findprogscip-shell shell coreboot 25.09+dfsg-1 findprog().() { |
| 22 | NPARMS=$# |
| 23 | WHAT="${1}" |
| 24 | shift |
| 25 | FROMENV="${1}" |
| 26 | shift |
| 27 | printfscip-shell system . . printf. "searching for ${WHAT} (${*})..." 1>&2 |
| 28 | testscip-shell system . . test. -n "${FROMENV}" && { |
| 29 | echoscip-shell system . . echo. " using environment: ${FROMENV}" 1>&2 |
| 30 | echoscip-shell system . . echo. "${FROMENV}" |
| 31 | exit 0 |
| 32 | } |
| 33 | i=2 |
| 34 | while testscip-shell system . . test. $i -lt $NPARMS; do |
| 35 | testscip-shell system . . test. -z "${1}" && { |
| 36 | shift |
| 37 | i=$(($i+1)) |
| 38 | continue |
| 39 | } |
| 40 | FILE="`whichscip-shell system . . which. "${1}" 2>/dev/nullscip-shell filesystem . . `/dev/null`.`" |
| 41 | testscip-shell system . . test. $? -eq 0 && { |
| 42 | echoscip-shell system . . echo. "${1}" |
| 43 | break |
| 44 | } |
| 45 | shift |
| 46 | i=$(($i+1)) |
| 47 | done |
| 48 | testscip-shell system . . test. -z "${1}" && { |
| 49 | echoscip-shell system . . echo. " not found!" 1>&2 |
| 50 | echoscip-shell system . . echo. 1>&2 |
| 51 | echoscip-shell system . . echo. "This is a fatal error, configure is exiting!" 1>&2 |
| 52 | exit 1 |
| 53 | } |
| 54 | echoscip-shell system . . echo. " using ${FILE} in PATH" 1>&2 |
| 55 | exit 0 |
| 56 | } |
| 57 | |
| 58 | trycompilescip-shell shell coreboot 25.09+dfsg-1 trycompile().() { |
| 59 | NPARMS=$# |
| 60 | WHAT="${1}" |
| 61 | shift |
| 62 | printfscip-shell system . . printf. "finding CFLAGS for ${WHAT}... " 1>&2 |
| 63 | OUT="${OUT}\n${CC} ${CFLAGS} -o .config.o -c .config.c" |
| 64 | OUT="${OUT}\n`echoscip-shell system . . echo. "${CC} ${CFLAGS} -o .config.o -c .config.c"|shscip-shell system . . sh. 2>&1`" |
| 65 | testscip-shell system . . test. $? -eq 0 && { |
| 66 | echoscip-shell system . . echo. " using: ${CFLAGS}" 1>&2 |
| 67 | echoscip-shell system . . echo. "${CFLAGS}" |
| 68 | exit 0 |
| 69 | } |
| 70 | i=1 |
| 71 | while testscip-shell system . . test. $i -lt $NPARMS; do |
| 72 | OUT="${OUT}\n${CC} ${CFLAGS} ${1} -o .config.o -c .config.c 2>&1" |
| 73 | OUT="${OUT}\n`echoscip-shell system . . echo. "${CC} ${CFLAGS} ${1} -o .config.o -c .config.c"|shscip-shell system . . sh. 2>&1`" |
| 74 | testscip-shell system . . test. $? -eq 0 && { |
| 75 | echoscip-shell system . . echo. " using: ${CFLAGS} ${1}" 1>&2 |
| 76 | echoscip-shell system . . echo. "${CFLAGS} ${1}" |
| 77 | exit 0 |
| 78 | } |
| 79 | shift |
| 80 | i=$(($i+1)) |
| 81 | done |
| 82 | echoscip-shell system . . echo. "failed!" 1>&2 |
| 83 | echoscip-shell system . . echo. 1>&2 |
| 84 | printfscip-shell system . . printf. "The following compiler commands were executed:" 1>&2 |
| 85 | echoscip-shell system . . echo. -e "${OUT}\n" 1>&2 |
| 86 | echoscip-shell system . . echo. "This is a fatal error, configure is exiting!" 1>&2 |
| 87 | echoscip-shell system . . echo. 1>&2 |
| 88 | echoscip-shell system . . echo. "You can try to fix this by manually setting CFLAGS in the environment before" 1>&2 |
| 89 | echoscip-shell system . . echo. "running configure. E.g.:" 1>&2 |
| 90 | echoscip-shell system . . echo. "CFLAGS=-I/opt/somedir/include ./configure" 1>&2 |
| 91 | echoscip-shell system . . echo. 1>&2 |
| 92 | exit 1 |
| 93 | } |
| 94 | |
| 95 | trylinkscip-shell shell coreboot 25.09+dfsg-1 trylink().() { |
| 96 | NPARMS=$# |
| 97 | WHAT="${1}" |
| 98 | shift |
| 99 | printfscip-shell system . . printf. "finding LDFLAGS for ${WHAT}... " 1>&2 |
| 100 | OUT="${OUT}\n${CC} -o .config .config.o ${LDFLAGS} 2>&1" |
| 101 | OUT="${OUT}\n`echoscip-shell system . . echo. "${CC} -o .config .config.o ${LDFLAGS}"|shscip-shell system . . sh. 2>&1`" |
| 102 | testscip-shell system . . test. $? -eq 0 && { |
| 103 | echoscip-shell system . . echo. " using: ${LDFLAGS}" 1>&2 |
| 104 | echoscip-shell system . . echo. "${LDFLAGS}" |
| 105 | exit 0 |
| 106 | } |
| 107 | i=1 |
| 108 | while testscip-shell system . . test. $i -lt $NPARMS; do |
| 109 | OUT="${OUT}\n${CC} -o .config .config.o ${LDFLAGS} ${1} 2>&1" |
| 110 | OUT="${OUT}\n`echoscip-shell system . . echo. "${CC} -o .config .config.o ${LDFLAGS} ${1}"|shscip-shell system . . sh. 2>&1`" |
| 111 | testscip-shell system . . test. $? -eq 0 && { |
| 112 | echoscip-shell system . . echo. " using: ${LDFLAGS} ${1}" 1>&2 |
| 113 | echoscip-shell system . . echo. "${LDFLAGS} ${1}" |
| 114 | exit 0 |
| 115 | } |
| 116 | shift |
| 117 | i=$(($i+1)) |
| 118 | done |
| 119 | echoscip-shell system . . echo. "failed!" 1>&2 |
| 120 | echoscip-shell system . . echo. 1>&2 |
| 121 | printfscip-shell system . . printf. "The following linker commands were executed:" 1>&2 |
| 122 | echoscip-shell system . . echo. -e "${OUT}\n" 1>&2 |
| 123 | echoscip-shell system . . echo. "This is a fatal error, configure is exiting!" 1>&2 |
| 124 | echoscip-shell system . . echo. 1>&2 |
| 125 | echoscip-shell system . . echo. "You can try to fix this by manually setting LDFLAGS in the environment before" 1>&2 |
| 126 | echoscip-shell system . . echo. "running configure. E.g.:" 1>&2 |
| 127 | echoscip-shell system . . echo. "LDFLAGS=-L/opt/somedir/lib ./configure" 1>&2 |
| 128 | echoscip-shell system . . echo. 1>&2 |
| 129 | exit 1 |
| 130 | } |
| 131 | |
| 132 | CC=`findprogscip-shell shell coreboot 25.09+dfsg-1 findprog(). "compiler" "${CC}" clang gcc cc icc` || exit |
| 133 | INSTALL=`findprogscip-shell shell coreboot 25.09+dfsg-1 findprog(). "install" "${INSTALL}" install ginstall` || exit |
| 134 | |
| 135 | testscip-shell system . . test. -n "$DEBUG" && myCFLAGS="-O2 -g" || myCFLAGS="-Os" |
| 136 | CFLAGS="${CFLAGS} ${myCFLAGS} -Wall -Werror" |
| 137 | |
| 138 | catscip-shell system . . cat. > .config.c << EOF |
| 139 | #include <pci/pci.h> |
| 140 | struct pci_access *pacc; |
| 141 | int main(int argc, char *argv[]) |
| 142 | { pacc = pci_alloc(); return 0; } |
| 143 | EOF |
| 144 | |
| 145 | pc_CFLAGS="`pkg-config libpci --cflags 2>/dev/nullscip-shell filesystem . . `/dev/null`.`" |
| 146 | pc_LDFLAGS="`pkg-config libpci --libs 2>/dev/nullscip-shell filesystem . . `/dev/null`.`" |
| 147 | CFLAGS=`trycompilescip-shell shell coreboot 25.09+dfsg-1 trycompile(). "libpci (from pciutils)" "${pc_CFLAGS}" "-I/usr/local/include"` || { |
| 148 | rmscip-shell system . . rm. -f .config.c |
| 149 | exit 1 |
| 150 | } |
| 151 | LDFLAGS=`trylinkscip-shell shell coreboot 25.09+dfsg-1 trylink(). "libpci (from pciutils)" "${pc_LDFLAGS}" "-lpci -lz" "-L/usr/local/lib -lpci -lz" "-framework DirectHW -lpci -lz"` || { |
| 152 | rmscip-shell system . . rm. -f .config.c .config.o |
| 153 | exit 1 |
| 154 | } |
| 155 | rmscip-shell system . . rm. -f .config.c .config.o .config |
| 156 | |
| 157 | PREFIX="${PREFIX:-/usr/local}" |
| 158 | |
| 159 | echoscip-shell system . . echo. |
| 160 | echoscip-shell system . . echo. "configured using the following settings:" |
| 161 | echoscip-shell system . . echo. |
| 162 | echoscip-shell system . . echo. "VERSION=${VERSION}" |
| 163 | echoscip-shell system . . echo. "CC=${CC}" |
| 164 | echoscip-shell system . . echo. "CFLAGS=${CFLAGS}" |
| 165 | echoscip-shell system . . echo. "LDFLAGS=${LDFLAGS}" |
| 166 | echoscip-shell system . . echo. "INSTALL=${INSTALL}" |
| 167 | echoscip-shell system . . echo. "PREFIX=${PREFIX}" |
| 168 | echoscip-shell system . . echo. |
| 169 | printfscip-shell system . . printf. "creating Makefile..." |
| 170 | echoscip-shell system . . echo. "# This file was automatically generated by configure" > Makefile |
| 171 | sedscip-shell system . . 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 |
| 178 | echoscip-shell system . . echo. " done" |
| 179 | echoscip-shell system . . echo. |