#!/bin/sh # This script was automatically generated by ACR v0.7.2 # @author: pancake # @url: http://news.nopcode.org/pancake/acr.html do_remove() { if [ "${ACR_RMFILES}" ]; then printf "cleaning temporally files... " rm -f ${ACR_RMFILES} echo "done" fi } control_c() { printf "\n\n^C control-c : script execution interrupted.\n" do_remove exit 1 } trap control_c 2 DEBUGGER=1 HAVE_EWF=1 [ -z "${USERCC}" ] && USERCC="gcc" [ -z "${USEROSTYPE}" ] && USEROSTYPE="gnulinux" WANT_VALA=1 split_host() { S="$" while : ; do ENVWORDS="${ENVWORDS} $1_CPU $1_OS" STR=`eval "echo ${S}$1"` SPLIT_CPU="`echo "$STR" | cut -d - -f 1`" SPLIT_OS="`echo "$STR" | cut -d - -f 3`" eval "$1_CPU=\"$SPLIT_CPU\"" eval "$1_OS=\"$SPLIT_OS\"" shift [ -z "$1" ] && break done } VPATH=`dirname ${0}` if [ "${VPATH}" = "." ]; then WODIS=current else if [ "${VPATH}" = "${PWD}" ]; then VPATH=. WODIS=current else WODIS=crosspath CURDIR=$PWD cd $VPATH VPATH="${PWD}/" cd $CURDIR fi fi guess_os() { if [ -e "${VPATH}/config.guess" ]; then sh ${VPATH}/config.guess return fi CPU="`uname -m|sed -e 's, ,,g'`" OS="`uname -s|awk '{print(tolower($0))}'`" GNU="`uname --help 2>&1 | grep gnu`" [ "${GNU}" ] && OS="${OS}-gnu" [ "${CPU}" = ppc ] && CPU="powerpc" echo "${CPU}-unknown-${OS}" } SEARCHPATH="/usr /usr/local /usr/pkg /sw" : ${PREFIX:=/usr/local} CROSSBUILD=0 BUILD=`guess_os` HOST="${BUILD}" TARGET="${HOST}" SYSCONFDIR="" create_environ() { : ${EPREFIX:=${PREFIX}} : ${SPREFIX:=${PREFIX}} : ${BINDIR:=${SPREFIX}/bin} : ${SBINDIR:=${PREFIX}/sbin} : ${SYSCONFDIR:=${SPREFIX}/etc} : ${LIBDIR:=${SPREFIX}/lib} : ${LIBEXECDIR:=${SPREFIX}/libexec} : ${DATADIR:=${SPREFIX}/share} : ${INCLUDEDIR:=${SPREFIX}/include} : ${INFODIR:=${SPREFIX}/info} : ${MANDIR:=${SPREFIX}/man} : ${LOCALSTATEDIR:=${SPREFIX}/var} for A in `echo ${PATH} | sed -e 's,:, ,g'` ; do if [ -e $A/install ]; then : ${INSTALL:=$A/install} fi done : ${INSTALL_DIR:=${INSTALL} -d} : ${INSTALL_DATA:=${INSTALL} -m 644} : ${INSTALL_SCRIPT:=${INSTALL} -m 755} : ${INSTALL_PROGRAM:=${INSTALL} -m 755 -s} : ${INSTALL_MAN:=${INSTALL} -m 444} : ${INSTALL_LIB:=${INSTALL} -c} PKGNAME='radare2' ; VERSION='0.2b' ; CONTACT_MAIL="pancake@nopcode.org" ; CONTACT_NAME="pancake" ; CONTACT="pancake " ; } show_usage() { cat < if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor\n" printf "\nReport bugs to: pancake " echo "" exit 0 } take_environ() { : ${SH:=/bin/sh} : ${CPP:=cpp} : ${CC:=gcc} : ${PREFIX:=/usr/local/} } show_version() { echo "radare2-0.2b configuration script done with acr v0.7.2. The 'Free Software Foundation' message is only for autodetection. Originally written by pancake ." exit 0 } parse_options() { flag=`echo $1| cut -d = -f 1` value=`echo $1| awk 'BEGIN{FS="=";}{print $2}'` flag2=`echo $flag|cut -f2- -d -| sed -e 's,-,_,g' -e 's,^_,,g'|tr '[a-z]' '[A-Z]'` case $flag in "-h"|"--help"|"--hel"|"--h"|"--he"|"-help") show_usage ; ;; "-V"|"-version"|"--version") show_version ; ;; "-r"|"--r"|"--report") echo "PKGNAME: radare2" echo "VERSION: 0.2b" echo "LANGS: c" echo "REQUIRED: lib>=vala-1.0 libvala-1.0>=0.5.0" echo "OPTIONAL: libewf" echo "FLAGS: --without-debugger --without-ewf --with-compiler=gcc --with-ostype=gnulinux --without-vala" exit 0 ;; "--cache-file") # ignored: acr have no cache ;; "--build") BUILD="$value"; ;; "--host") CROSSBUILD=1 HOST="$value"; ;; "--target") TARGET="$value"; ;; "--prefix") PREFIX="$value"; ;; "--exec-prefix") EPREFIX="$value"; ;; "--sandbox"|"--sprefix") SPREFIX="$value"; ;; "--bindir") BINDIR="$value"; ;; "--sbindir") SBINDIR="$value"; ;; "--libexecdir") LIBEXECDIR="$value"; ;; "--datadir") DATADIR="$value"; ;; "--sysconfdir") SYSCONFDIR="$value"; ;; "--sharedstatedir") SHAREDSTATEDIR="$value"; ;; "--localstatedir") LOCALSTATEDIR="$value"; ;; "--libdir") LIBDIR="$value"; LDFLAGS="${LDFLAGS} -L$value -Wl,-R$value"; ;; "--includedir") INCLUDEDIR="$value"; CFLAGS="${CFLAGS} -I$value"; ;; "--infodir") INFODIR="$value"; ;; "--mandir") MANDIR="$value"; ;; "--without-debugger") DEBUGGER="0"; ;; "--without-ewf") HAVE_EWF="0"; ;; --with-compiler) if [ -z "${value}" ]; then USERCC="gcc"; else USERCC="${value}" ; fi ;; --with-ostype) if [ -z "${value}" ]; then USEROSTYPE="gnulinux"; else USEROSTYPE="${value}" ; fi ;; "--without-vala") WANT_VALA="0"; ;; *) if [ "$value" ]; then eval "`echo $flag2=$value`" ; else echo ; echo "WARNING: Unknown flag '$flag'." >&2 ; echo ; fi ;; esac } # MAIN # take_environ split_host BUILD HOST TARGET [ -z "$ACRHOOK" ] && ACRHOOK=./configure.hook [ -e "$ACRHOOK" ] && . ${ACRHOOK} while : ; do [ -z "$1" ] && break parse_options $1 shift done ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_EWF HAVE_EWF HAVE_LIB_TCC USERCC USEROSTYPE WANT_VALA HAVE_VALAC VALAC LIL_ENDIAN BIG_ENDIAN BYTEORDER HAVE_VALA_1_0_VERSION_0_5_0" create_environ echo "checking build system type... ${BUILD}" echo "checking host system type... ${HOST}" echo "checking target system type... ${TARGET}" [ "${CROSSBUILD}" = 1 ] && echo "using crosscompilation mode." #split_host BUILD HOST TARGET [ -n "${prefix}" ] && PREFIX=${prefix} echo "checking for working directories... ${WODIS}" echo "using prefix '${PREFIX}'" ACR_RMFILES=" test.c a.out a.exe" : COMPILER=CC printf "checking for c compiler... " HAVE_LANG_C=1 if [ "${CROSSBUILD}" = 1 ]; then (command -v ${HOST}-${CC} >/dev/null 2>&1) if [ $? = 0 ]; then CC="${HOST}-${CC}"; fi fi echo "main(){}" > test.c (exec ${CC} ${CFLAGS} ${LDFLAGS} test.c >/dev/null 2>&1) if [ $? = 0 ]; then echo ${CC}; else echo no ; HAVE_LANG_C=0 do_remove echo "ERROR: ${CC} cannot create executables" >&2 ; exit 1 ; fi check_library() { VAR=$1 S="$" _REQUIRED=$3 _CHKLIB_NAME=$2 _CHKLIB_LIBS=$(echo "-l${_CHKLIB_NAME}" | sed 's,\+, -l,g') printf "checking for lib${_CHKLIB_NAME} ... " echo "main(){ }" > test.c eval ${S}${COMPILER} ${CFLAGS} ${LDFLAGS} ${_CHKLIB_LIBS} test.c >/dev/null 2>&1 if [ $? = 0 ]; then eval ${VAR}=1 echo yes else eval ${VAR}=0 echo no ; fi } check_library HAVE_LIB_EWF ewf 0 if [ "$HAVE_EWF" = "1" ]; then export HAVE_LIB_EWF="0"; fi check_library HAVE_LIB_TCC tcc 0 printf "checking for valac... " if [ -x "${VALAC}" ]; then FIND=${VALAC} else FIND="" for A in `echo ${PATH} | sed -e 's,:, ,g'`; do if [ -x "${A}/valac" ]; then FIND="${A}/valac" break; fi done fi if [ -n "${FIND}" ]; then echo ${FIND}; HAVE_VALAC=1 VALAC=${FIND} else HAVE_VALAC=0 VALAC=valac echo no ; fi printf "checking host endianness... " echo 'main(){int a=1;char *b=(char*)&a;printf("%d",b[0]);}' > test.c ${CC} ${CFLAGS} ${LDFLAGS} -o a.out test.c >/dev/null 2>&1 if [ ! $? = 0 ]; then echo unexpected error do_remove exit 1 fi LIL_ENDIAN=$(./a.out) if [ "${LIL_ENDIAN}" = 1 ]; then BYTEORDER=1234 BIG_ENDIAN=0 echo little else BYTEORDER=4321 BIG_ENDIAN=1 LIL_ENDIAN=0 echo big fi if [ "$WANT_VALA" = "1" ]; then HAVE_VALA_1_0_VERSION_0_5_0=0 printf "checking version of library vala-1.0 >= 0.5.0... " pkg-config --atleast-version=0.5.0 vala-1.0 >/dev/null 2>&1 if [ $? = 0 ]; then HAVE_VALA_1_0_VERSION_0_5_0=1 ; echo ok; else echo "no" ; fi if [ "$HAVE_VALA_1_0_VERSION_0_5_0" = "0" ]; then echo " Needs vala 0.5.0 at least" >&2 export HAVE_VALAC="0" export VALAC=""; fi else export HAVE_VALAC="0"; fi SEDFLAGS=" -e '" COUNT=0 for A in ${ENVWORDS} ; do [ "${A}" = VPATH ] && continue [ "${A}" = srcdir ] && continue eval "VAR=\$${A}" VAR="`echo ${VAR} | sed -e 's/\,/\\\,/g'`" [ $COUNT = 10 ] && COUNT=0 && SEDFLAGS="${SEDFLAGS}' -e '" COUNT=$(($COUNT+1)) SEDFLAGS="${SEDFLAGS}s,@${A}@,${VAR},g;" done SEDFLAGS="${SEDFLAGS}'" for A in ./config-user.mk libr/include/r_userconf.h pkgcfg/libr.pc pkgcfg/r_io.pc pkgcfg/r_asm.pc pkgcfg/r_bin.pc pkgcfg/r_cons.pc pkgcfg/r_diff.pc pkgcfg/r_core.pc pkgcfg/r_socket.pc pkgcfg/r_line.pc pkgcfg/r_syscall.pc pkgcfg/r_macro.pc pkgcfg/r_util.pc pkgcfg/r_search.pc pkgcfg/r_vm.pc pkgcfg/r_th.pc pkgcfg/r_bp.pc pkgcfg/r_db.pc ; do # SUBDIRS if [ -f "${VPATH}/${A}.acr" ]; then SD_TARGET=${A} else if [ -d "${VPATH}/${A}" ]; then SD_TARGET=${A}/Makefile mkdir -p ${A} else echo "ERROR: Cannot find ${VPATH}/${A}.acr" >&2 exit 1 fi fi echo "creating ${SD_TARGET}" mkdir -p $(echo ${A} | sed -e "s,/`basename ${A}`$,,g") cat ${VPATH}/${SD_TARGET}.acr | \ eval sed -e "s,@VPATH@,${VPATH}/${A},g" ${SEDFLAGS} > ${SD_TARGET}.tmp for A in ${ENVWORDS}; do VALUE=`eval echo "$"${A}` if [ "$VALUE" = "0" ]; then ## FALSE MARK="##${A}##" mv ${SD_TARGET}.tmp ${SD_TARGET}.tmp2 cat ${SD_TARGET}.tmp2 | MARK=$MARK awk 'BEGIN{a=0;}{if($1==ENVIRON["MARK"]){ if(a)a=0;else a=1 }else{if(!a)print;}}' > ${SD_TARGET}.tmp fi done mv ${SD_TARGET}.tmp ${SD_TARGET} && rm -f ${SD_TARGET}.tmp2 if [ $? = 1 ]; then echo Cannot write target file ; control_c ; fi done do_remove echo echo "Final report:" for A in PREFIX HAVE_LIB_EWF HAVE_LIB_TCC HAVE_VALAC DEBUGGER USERCC USEROSTYPE ; do # REPORT eval VAL="\$${A}" [ -z "${VAL}" ] && VAL="(null)" echo " - ${A} = ${VAL}" done