Changeset 2bd8f39


Ignore:
Timestamp:
2023-01-30T19:27:28Z (21 months ago)
Author:
GitHub <noreply@…>
Branches:
master
Children:
b6df23d
Parents:
8ca172f
git-author:
David Cantrell <dcantrell@…> (30-01-23 19:27:28)
git-committer:
GitHub <noreply@…> (30-01-23 19:27:28)
Message:

Fix up a lot of shell errors in the configure script (#167)

I ran in to a number of parse errors and problems, so I spent time
fixing up the configure script.

Signed-off-by: David Cantrell <dcantrell@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • configure

    r8ca172f r2bd8f39  
    88##############################
    99
    10 prefix='/usr/local/'
    11 bindir='$prefix/bin/'
    12 sbindir='$prefix/sbin/'
    13 etcdir='$prefix/etc/bitlbee/'
    14 mandir='$prefix/share/man/'
    15 datadir='$prefix/share/bitlbee/'
    16 config='/var/lib/bitlbee/'
    17 libdir='$prefix/lib/'
    18 plugindir='$prefix/lib/bitlbee/'
    19 includedir='$prefix/include/bitlbee/'
    20 systemdsystemunitdir=''
    21 sysusersdir=''
    22 libevent='/usr/'
    23 pidfile='/var/run/bitlbee.pid'
    24 ipcsocket=''
    25 pcdir='$prefix/lib/pkgconfig'
     10prefix="/usr/local/"
     11bindir="$prefix/bin/"
     12sbindir="$prefix/sbin/"
     13etcdir="$prefix/etc/bitlbee/"
     14mandir="$prefix/share/man/"
     15datadir="$prefix/share/bitlbee/"
     16config="/var/lib/bitlbee/"
     17libdir="$prefix/lib/"
     18plugindir="$prefix/lib/bitlbee/"
     19includedir="$prefix/include/bitlbee/"
     20systemdsystemunitdir=""
     21sysusersdir=""
     22libevent="/usr/"
     23pidfile="/var/run/bitlbee.pid"
     24ipcsocket=""
     25pcdir="$prefix/lib/pkgconfig"
    2626systemlibdirs="/lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib"
    27 sysroot=''
    28 
    29 configure_args="$@"
     27sysroot=""
     28
     29configure_args="$*"
    3030
    3131# Set these to default-on to let it be overriden by either the user or purple
     
    7878
    7979get_version() {
    80         REAL_BITLBEE_VERSION=$(grep '^#define BITLBEE_VERSION ' $srcdir/bitlbee.h | sed 's/.*\"\(.*\)\".*/\1/')
     80        REAL_BITLBEE_VERSION=$(grep '^#define BITLBEE_VERSION ' "$srcdir"/bitlbee.h | sed 's/.*\"\(.*\)\".*/\1/')
    8181
    8282        if [ -n "$BITLBEE_VERSION" ]; then
     
    8888        BITLBEE_VERSION=$REAL_BITLBEE_VERSION
    8989
    90         if [ -d $srcdir/.git ] && type git > /dev/null 2> /dev/null; then
    91                 timestamp=$(cd $srcdir; git show -s --format=%ci HEAD | sed 's/ .*$//; s/-//g')
    92                 branch=$(cd $srcdir; git rev-parse --abbrev-ref HEAD)
     90        if [ -d "$srcdir"/.git ] && type git > /dev/null 2> /dev/null; then
     91                timestamp=$(cd "$srcdir" || exit 1; git show -s --format=%ci HEAD | sed 's/ .*$//; s/-//g')
     92                branch=$(cd "$srcdir" || exit 1; git rev-parse --abbrev-ref HEAD)
    9393
    9494                search='\(.*\)-\([0-9]*\)-\(g[0-9a-f]*\)'
    9595                replace="\1+$timestamp+$branch+\2-\3-git"
    9696
    97                 describe=$(cd $srcdir; git describe --long --tags 2>/dev/null)
    98                 if [ $? -ne 0 ]; then
    99                         describe=${REAL_BITLBEE_VERSION}-0-g$(cd $srcdir; git rev-parse --short HEAD)
     97                if ! describe=$(cd "$srcdir" || exit 1; git describe --long --tags 2>/dev/null) ; then
     98                        describe=${REAL_BITLBEE_VERSION}-0-g$(cd "$srcdir" || exit; git rev-parse --short HEAD)
    10099                fi
    101100
    102                 BITLBEE_VERSION=$(echo $describe | sed "s#$search#$replace#")
     101                BITLBEE_VERSION=$(echo "$describe" | sed "s#$search#$replace#")
    103102
    104103                unset timestamp branch search replace describe
     
    107106
    108107if [ "$1" = "--dump-version" ]; then
    109         srcdir=$(cd $(dirname $0);pwd)
     108        srcdir=$(cd "$(dirname "$0")" || exit;pwd)
    110109        get_version
    111         echo $BITLBEE_VERSION
     110        echo "$BITLBEE_VERSION"
    112111        exit
    113112fi
     
    217216EOF
    218217
    219 srcdir=$(cd $(dirname $0);pwd)
     218srcdir=$(cd "$(dirname "$0")" || exit;pwd)
    220219currdir=$(pwd)
    221 if [ "$srcdir" != "$currdir" ]; then
     220if [ ! "$srcdir" = "$currdir" ]; then
    222221        echo
    223222        echo "configure script run from a different directory. Will create some symlinks..."
    224         if [ ! -e Makefile -o -L Makefile ]; then
     223        if [ ! -e Makefile ] || [ -L Makefile ]; then
    225224                COPYDIRS="doc lib protocols tests utils"
    226                 mkdir -p $(cd "$srcdir"; find $COPYDIRS -type d)
     225                mkdir -p "$(cd "$srcdir" || exit 1; find "$COPYDIRS" -type d)"
    227226                find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null
    228227                dst="$PWD"
    229                 cd "$srcdir"
    230                 for i in $(find . -name Makefile -type f); do
     228                cd "$srcdir" || exit 1
     229                find . -type f -name Makefile -print | while read -r i ; do
    231230                        ln -s "$PWD${i#.}" "$dst/$i";
    232231                done
    233                 cd "$dst"
     232                cd "$dst" || exit 1
    234233                rm -rf .bzr
    235234        fi
     
    273272
    274273        if [ -z "$PKG_CONFIG_LIBDIR" ]; then
    275                 PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig
     274                PKG_CONFIG_LIBDIR=/usr/"$target"/lib/pkgconfig
    276275                export PKG_CONFIG_LIBDIR
    277276        fi
    278277
    279         if [ -d /usr/$target/bin ]; then
    280                 PATH=/usr/$target/bin:$PATH
    281         fi
    282 
    283         if [ -d /usr/$target/lib ]; then
     278        if [ -d /usr/"$target"/bin ]; then
     279                PATH=/usr/"$target"/bin:$PATH
     280        fi
     281
     282        if [ -d /usr/"$target"/lib ]; then
    284283                systemlibdirs="$systemlibdirs /usr/$target/lib"
    285284        fi
     
    327326fi
    328327
    329 echo LDFLAGS=$LDFLAGS >> Makefile.settings
    330 
    331 echo CFLAGS=$CFLAGS $CPPFLAGS >> Makefile.settings
    332 echo CFLAGS+=-I${srcdir} -I${srcdir}/lib -I${srcdir}/protocols -I. >> Makefile.settings
     328# shellcheck disable=SC2129
     329echo "LDFLAGS=$LDFLAGS" >> Makefile.settings
     330
     331echo "CFLAGS=$CFLAGS $CPPFLAGS" >> Makefile.settings
     332echo CFLAGS+=-I"${srcdir}" -I"${srcdir}"/lib -I"${srcdir}"/protocols -I. >> Makefile.settings
    333333
    334334echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings
    335335
    336 if [ -n "$CC" ]; then
    337         CC=$CC
    338 elif type gcc > /dev/null 2> /dev/null; then
     336if type gcc > /dev/null 2> /dev/null; then
    339337        CC=gcc
    340338elif type cc > /dev/null 2> /dev/null; then
     
    380378        else
    381379                echo
    382                 echo 'Found glib2 '$($PKG_CONFIG glib-2.0 --modversion)', but version '$GLIB_MIN_VERSION' or newer is required.'
     380                echo "Found glib2 $($PKG_CONFIG glib-2.0 --modversion), but version $GLIB_MIN_VERSION or newer is required."
    383381                exit 1
    384382        fi
     
    421419echo "EXTERNAL_JSON_PARSER=$external_json_parser" >> Makefile.settings
    422420if [ "$external_json_parser" = "1" ]; then
     421    # shellcheck disable=SC2129
    423422    echo "CFLAGS+=$(pkg-config --cflags json-parser)" >> Makefile.settings
    424423    echo "LDFLAGS_BITLBEE+=$(pkg-config --libs json-parser)" >> Makefile.settings
     
    538537        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
    539538        ret=1
    540         echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
    541         if [ "$?" = "0" ]; then
     539        if echo "$RESOLV_TESTCODE" | $CC -o "$TMPFILE" -x c - $LIBRESOLV >/dev/null 2>/dev/null ; then
    542540                echo "EFLAGS+=$LIBRESOLV" >> Makefile.settings
    543541                ret=0
    544542        fi
    545543
    546         rm -f $TMPFILE
     544        rm -f "$TMPFILE"
    547545        return $ret
    548546}
     
    553551        ret=1
    554552        for i in $systemlibdirs; do
    555                 if [ -f $i/libresolv.a ]; then
    556                         echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
    557                         if [ "$?" = "0" ]; then
    558                                 echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
     553                if [ -f "$i"/libresolv.a ]; then
     554                        if echo "$RESOLV_TESTCODE" | $CC -o "$TMPFILE" -x c - -Wl,"$i"/libresolv.a >/dev/null 2>/dev/null ; then
     555                                echo "EFLAGS+=$i/libresolv.a" >> Makefile.settings
    559556                                ret=0
    560557                        fi
     
    562559        done
    563560
    564         rm -f $TMPFILE
     561        rm -f "$TMPFILE"
    565562        return $ret
    566563}
     
    577574        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
    578575        ret=1
    579         echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
    580         if [ "$?" = "0" ]; then
     576        if echo "$RESOLV_NS_TESTCODE" | $CC -o "$TMPFILE" -x c - $LIBRESOLV >/dev/null 2>/dev/null ; then
    581577                ret=0
    582578        fi
    583579
    584         rm -f $TMPFILE
     580        rm -f "$TMPFILE"
    585581        return $ret
    586582}
     
    591587        ret=1
    592588        for i in $systemlibdirs; do
    593                 if [ -f $i/libresolv.a ]; then
    594                         echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
    595                         if [ "$?" = "0" ]; then
     589                if [ -f "$i"/libresolv.a ]; then
     590                        if echo "$RESOLV_NS_TESTCODE" | $CC -o "$TMPFILE" -x c - -Wl,"$i"/libresolv.a >/dev/null 2>/dev/null ; then
    596591                                ret=0
    597592                        fi
     
    599594        done
    600595
    601         rm -f $TMPFILE
     596        rm -f "$TMPFILE"
    602597        return $ret
    603598}
     
    609604        # since we aren't actually linking with ns_* routines
    610605        # we can just compile the test code
    611         echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c -  >/dev/null 2>/dev/null
    612         if [ "$?" = "0" ]; then
     606        if echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o "$TMPFILE" -x c -  >/dev/null 2>/dev/null ; then
    613607                ret=0
    614608        fi
    615609
    616         rm -f $TMPFILE
     610        rm -f "$TMPFILE"
    617611        return $ret
    618612}
     
    622616        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
    623617        ret=1
    624         echo "$BACKTRACE_TESTCODE" | $CC -o $TMPFILE -x c -  >/dev/null 2>/dev/null
    625         if [ "$?" = "0" ]; then
     618        if echo "$BACKTRACE_TESTCODE" | $CC -o "$TMPFILE" -x c -  >/dev/null 2>/dev/null ; then
    626619                ret=0
    627620        fi
    628621
    629         rm -f $TMPFILE
     622        rm -f "$TMPFILE"
    630623        return $ret
    631624}
     
    698691if detect_backtrace; then
    699692        echo '#define HAVE_BACKTRACE' >> config.h
    700         echo '#define CRASHFILE "'$config'crash.log"' >> config.h
     693        echo "#define CRASHFILE \"${config}crash.log\"" >> config.h
    701694fi
    702695
     
    706699        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
    707700done
    708 echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
     701echo "STORAGE_OBJS=$STORAGE_OBJS" >> Makefile.settings
    709702
    710703authobjs=
    711704authlibs=
    712 if [ "$pam" = 0 ]; then
     705if [ "$pam" = "0" ]; then
    713706        echo '#undef WITH_PAM' >> config.h
    714707else
     
    721714        authlibs=$authlibs'-lpam '
    722715fi
    723 if [ "$ldap" = 0 ]; then
     716if [ "$ldap" = "0" ]; then
    724717        echo '#undef WITH_LDAP' >> config.h
    725718else
     
    732725        authlibs=$authlibs'-lldap '
    733726fi
    734 echo AUTH_OBJS=$authobjs >> Makefile.settings
    735 echo EFLAGS+=$authlibs >> Makefile.settings
    736 
    737 if [ "$strip" = 0 ]; then
     727echo AUTH_OBJS="$authobjs" >> Makefile.settings
     728echo EFLAGS+="$authlibs" >> Makefile.settings
     729
     730if [ "$strip" = "0" ]; then
    738731        echo "STRIP=\# skip strip" >> Makefile.settings;
    739732else
    740         if [ "$debug" = 1 ]; then
     733        if [ "$debug" = "1" ]; then
    741734                echo
    742735                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
     
    755748fi
    756749
    757 if [ ! "$systemd" = 0 ]; then
     750if [ ! "$systemd" = "0" ]; then
    758751    if ! $PKG_CONFIG --exists systemd ; then
    759         if [ -n "$systemdsystemunitdir" ] || [ "$systemd" -eq 1 ]; then
     752        if [ -n "$systemdsystemunitdir" ] || [ $systemd -eq 1 ]; then
    760753            echo "systemd requested but not found"
    761754            exit 1
     
    768761pkgconf_systemd_var() {
    769762    # First try deprecated variable, use newer variable if not found
    770     if $PKG_CONFIG --print-variables systemd | grep -q $1 ; then
    771         $PKG_CONFIG --variable=$1 systemd
     763    if $PKG_CONFIG --print-variables systemd | grep -q "$1" ; then
     764        $PKG_CONFIG --variable="$1" systemd
    772765    else
    773         $PKG_CONFIG --variable=$2 systemd
     766        $PKG_CONFIG --variable="$2" systemd
    774767    fi
    775768}
    776769
    777 if [ "$systemd" -eq 1 ]; then
     770if [ "$systemd" = "1" ]; then
    778771        if [ -z "$systemdsystemunitdir" ]; then
    779772                systemdsystemunitdir=$(pkgconf_systemd_var systemdsystemunitdir systemd_system_unit_dir)
    780773        fi
    781     if [ -z "$tmpfiles_dir" ] ; then
    782         tmpfilesdir=$(pkgconf_systemd_var tmpfilesdir tmpfiles_dir)
    783     fi
    784774    if [ -z "$sysusersdir" ] ; then
    785775        sysusersdir=$(pkgconf_systemd_var sysusersdir sysusers_dir)
     
    795785fi
    796786
    797 if [ "$plugins" = 0 ]; then
     787if [ "$plugins" = "0" ]; then
    798788        plugindir=""
    799789        echo '#undef WITH_PLUGINS' >> config.h
     
    802792fi
    803793
    804 otrprefix=""
    805794if [ "$otr" = "auto" ]; then
    806795        ! $PKG_CONFIG --exists libotr
     
    808797fi
    809798
    810 if [ "$otr" != 0 ] && ! $PKG_CONFIG --atleast-version=4.0 --print-errors libotr; then
     799if [ "$otr" != "0" ] && ! $PKG_CONFIG --atleast-version=4.0 --print-errors libotr; then
    811800        exit 1
    812801fi
    813802
    814 if [ "$otr" = 1 ]; then
     803if [ "$otr" = "1" ]; then
    815804        # BI == built-in
    816805        echo '#define OTR_BI' >> config.h
     806        # shellcheck disable=SC2129
    817807        echo "EFLAGS+=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
    818808        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
     
    822812        # the libgcrypt flags aren't needed when building as plugin. add them anyway.
    823813        echo '#define OTR_PI' >> config.h
     814        # shellcheck disable=SC2129
    824815        echo "OTRFLAGS=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
    825816        echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
     
    838829if [ "$doc" = "1" ]; then
    839830        # check this here just in case someone tries to install it in python2.4...
    840         if [ ! -e $srcdir/doc/user-guide/help.txt ] && ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then
     831        if [ ! -e "$srcdir"/doc/user-guide/help.txt ] && ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then
    841832                echo
    842833                echo 'ERROR: Python (>=2.5 or 3.x) is required to generate docs'
     
    850841get_version
    851842
    852 if [ "$BITLBEE_VERSION" != "$REAL_BITLBEE_VERSION" ]; then
    853         echo 'Spoofing version number: '$BITLBEE_VERSION
    854         echo '#undef BITLBEE_VERSION' >> config.h
    855         echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h
     843if [ ! "$BITLBEE_VERSION" = "$REAL_BITLBEE_VERSION" ]; then
     844        echo "Spoofing version number: $BITLBEE_VERSION"
     845        echo "#undef BITLBEE_VERSION" >> config.h
     846        echo "#define BITLBEE_VERSION '$BITLBEE_VERSION'" >> config.h
    856847        echo
    857848fi
     
    874865case "$arch" in
    875866CYGWIN* )
    876         pkgconfiglibs='-L${libdir} -lbitlbee -no-undefined'
     867        pkgconfiglibs="-L${libdir} -lbitlbee -no-undefined"
    877868esac
    878869
     
    896887protoobjs=''
    897888
    898 if [ "$purple" = 0 ]; then
     889if [ "$purple" = "0" ]; then
    899890        echo '#undef WITH_PURPLE' >> config.h
    900891else
     
    930921        echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings
    931922        for i in . lib tests protocols protocols/*/; do
    932                 mkdir -p $i/.depend
     923                mkdir -p "$i"/.depend
    933924        done
    934925esac
    935926
    936 if [ "$jabber" = 0 ]; then
     927if [ "$jabber" = "0" ]; then
    937928        echo '#undef WITH_JABBER' >> config.h
    938929else
     
    942933fi
    943934
    944 if [ "$twitter" = 0 ]; then
     935if [ "$twitter" = "0" ]; then
    945936        echo '#undef WITH_TWITTER' >> config.h
    946937else
     
    958949echo "PROTOOBJS = $protoobjs" >> Makefile.settings
    959950
    960 echo Architecture: $arch
     951echo Architecture: "$arch"
    961952case "$arch" in
    962953Linux )
     
    10341025fi
    10351026
    1036 if [ "$systemd" -eq 1 ]; then
     1027if [ "$systemd" = "1" ]; then
    10371028        echo '  systemd enabled.'
    10381029else
     
    10531044
    10541045if [ -n "$protocols" ]; then
    1055         echo '  Building with these protocols:' $protocols$protocols_mods
     1046        echo '  Building with these protocols:' "$protocols""$protocols_mods"
    10561047        case "$protocols" in
    10571048        *purple*)
Note: See TracChangeset for help on using the changeset viewer.