Changeset 612b49d


Ignore:
Timestamp:
2023-04-16T03:18:07Z (12 months ago)
Author:
GitHub <noreply@…>
Branches:
master
Children:
53cd518
Parents:
08964da
git-author:
Robert Scheck <robert-scheck@…> (16-04-23 03:18:07)
git-committer:
GitHub <noreply@…> (16-04-23 03:18:07)
Message:

configure: address ShellCheck reports and add ShellCheck job (#189)

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • .github/workflows/test.yaml

    r08964da r612b49d  
    1010
    1111jobs:
     12  shellcheck:
     13    runs-on: ubuntu-latest
     14    steps:
     15    - name: Checkout code
     16      uses: actions/checkout@v3
     17    - name: Run ShellCheck
     18      uses: ludeeus/action-shellcheck@master
    1219  tests:
     20    needs: shellcheck
    1321    runs-on: ubuntu-latest
    14 
    1522    steps:
    1623    - uses: actions/checkout@v3
  • configure

    r08964da r612b49d  
    88##############################
    99
     10# shellcheck disable=SC2016,SC2164,SC2181
    1011prefix='/usr/local/'
    1112bindir='$prefix/bin/'
     
    2728sysroot=''
    2829
    29 configure_args="$@"
     30configure_args="$*"
    3031
    3132# Set these to default-on to let it be overriden by either the user or purple
     
    7879
    7980get_version() {
    80         REAL_BITLBEE_VERSION=$(grep '^#define BITLBEE_VERSION ' $srcdir/bitlbee.h | sed 's/.*\"\(.*\)\".*/\1/')
     81        REAL_BITLBEE_VERSION=$(grep '^#define BITLBEE_VERSION ' "$srcdir/bitlbee.h" | sed 's/.*\"\(.*\)\".*/\1/')
    8182
    8283        if [ -n "$BITLBEE_VERSION" ]; then
     
    8889        BITLBEE_VERSION=$REAL_BITLBEE_VERSION
    8990
    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)
     91        if [ -d "$srcdir/.git" ] && type git > /dev/null 2> /dev/null; then
     92                timestamp=$(cd "$srcdir"; git show -s --format=%ci HEAD | sed 's/ .*$//; s/-//g')
     93                branch=$(cd "$srcdir"; git rev-parse --abbrev-ref HEAD)
    9394
    9495                search='\(.*\)-\([0-9]*\)-\(g[0-9a-f]*\)'
    9596                replace="\1+$timestamp+$branch+\2-\3-git"
    9697
    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)
     98                if ! (cd "$srcdir"; git describe --long --tags 2>/dev/null); then
     99                        describe=${REAL_BITLBEE_VERSION}-0-g$(cd "$srcdir"; git rev-parse --short HEAD)
    100100                fi
    101101
    102                 BITLBEE_VERSION=$(echo $describe | sed "s#$search#$replace#")
     102                BITLBEE_VERSION=$(echo "$describe" | sed "s#$search#$replace#")
    103103
    104104                unset timestamp branch search replace describe
     
    107107
    108108if [ "$1" = "--dump-version" ]; then
    109         srcdir=$(cd $(dirname $0);pwd)
     109        srcdir=$(cd "$(dirname "$0")"; pwd)
    110110        get_version
    111         echo $BITLBEE_VERSION
     111        echo "$BITLBEE_VERSION"
    112112        exit
    113113fi
     
    167167--sysroot=...   Cross compilation sysroot               $sysroot
    168168EOF
    169                 exit;
     169                exit
    170170        fi
    171171        eval "$e"
    172         shift;
     172        shift
    173173done
    174174
     
    217217EOF
    218218
    219 srcdir=$(cd $(dirname $0);pwd)
     219srcdir=$(cd "$(dirname "$0")"; pwd)
    220220currdir=$(pwd)
    221 if [ "$srcdir" != "$currdir" ]; then 
     221if [ "$srcdir" != "$currdir" ]; then
    222222        echo
    223223        echo "configure script run from a different directory. Will create some symlinks..."
    224         if [ ! -e Makefile -o -L Makefile ]; then
     224        if [ ! -e Makefile ] || [ -L Makefile ]; then
    225225                COPYDIRS="doc lib protocols tests utils"
     226                # shellcheck disable=SC2046,SC2086
    226227                mkdir -p $(cd "$srcdir"; find $COPYDIRS -type d)
    227228                find . -name Makefile -type l -print0 | xargs -0 rm 2> /dev/null
    228229                dst="$PWD"
    229230                cd "$srcdir"
     231                # shellcheck disable=SC2044
    230232                for i in $(find . -name Makefile -type f); do
    231                         ln -s "$PWD${i#.}" "$dst/$i";
     233                        ln -s "$PWD${i#.}" "$dst/$i"
    232234                done
    233235                cd "$dst"
     
    243245cat<<EOF >config.h
    244246/* BitlBee settings, generated by configure
    245    
     247
    246248   Do *NOT* use any of these defines in your code without thinking twice, most
    247249   of them can/will be overridden at run-time */
     
    273275
    274276        if [ -z "$PKG_CONFIG_LIBDIR" ]; then
    275                 PKG_CONFIG_LIBDIR=/usr/$target/lib/pkgconfig
     277                PKG_CONFIG_LIBDIR="/usr/$target/lib/pkgconfig"
    276278                export PKG_CONFIG_LIBDIR
    277279        fi
    278280
    279         if [ -d /usr/$target/bin ]; then
    280                 PATH=/usr/$target/bin:$PATH
    281         fi
    282 
    283         if [ -d /usr/$target/lib ]; then
     281        if [ -d "/usr/$target/bin" ]; then
     282                PATH="/usr/$target/bin:$PATH"
     283        fi
     284
     285        if [ -d "/usr/$target/lib" ]; then
    284286                systemlibdirs="$systemlibdirs /usr/$target/lib"
    285287        fi
     
    327329fi
    328330
    329 echo LDFLAGS=$LDFLAGS >> Makefile.settings
    330 
    331 echo CFLAGS=$CFLAGS $CPPFLAGS >> Makefile.settings
    332 
    333 echo CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE >> Makefile.settings
     331cat<<EOF >>Makefile.settings
     332LDFLAGS=$LDFLAGS
     333CFLAGS=$CFLAGS $CPPFLAGS
     334CFLAGS+=-DHAVE_CONFIG_H -D_GNU_SOURCE
     335EOF
    334336
    335337if [ -n "$CC" ]; then
    336         CC=$CC
     338        :
    337339elif type gcc > /dev/null 2> /dev/null; then
    338340        CC=gcc
     
    341343else
    342344        echo 'Cannot find a C compiler, aborting.'
    343         exit 1;
    344 fi
    345 
    346 echo "CC=$CC" >> Makefile.settings;
    347 if echo $CC | grep -qw 'gcc\|clang'; then
     345        exit 1
     346fi
     347
     348echo "CC=$CC" >> Makefile.settings
     349if echo "$CC" | grep -qw 'gcc\|clang'; then
    348350        # Apparently -Wall is gcc-specific?
    349         echo CFLAGS+=-Wall -Wformat -Werror=format-security >> Makefile.settings
     351        echo 'CFLAGS+=-Wall -Wformat -Werror=format-security' >> Makefile.settings
    350352fi
    351353
     
    355357        else
    356358                echo 'Cannot find ld, aborting.'
    357                 exit 1;
     359                exit 1
    358360        fi
    359361fi
     
    379381        else
    380382                echo
    381                 echo 'Found glib2 '$($PKG_CONFIG glib-2.0 --modversion)', but version '$GLIB_MIN_VERSION' or newer is required.'
     383                echo "Found glib2 $($PKG_CONFIG glib-2.0 --modversion), but version $GLIB_MIN_VERSION or newer is required."
    382384                exit 1
    383385        fi
     
    420422echo "EXTERNAL_JSON_PARSER=$external_json_parser" >> Makefile.settings
    421423if [ "$external_json_parser" = "1" ]; then
    422     echo "CFLAGS+=$(pkg-config --cflags json-parser)" >> Makefile.settings
    423     echo "CFLAGS+=-DUSE_EXTERNAL_JSON_PARSER" >> Makefile.settings
    424     echo "LDFLAGS_BITLBEE+=$(pkg-config --libs json-parser)" >> Makefile.settings
    425     echo "LDFLAGS_TESTS+=$(pkg-config --libs json-parser)" >> Makefile.settings
     424        cat <<EOF >>Makefile.settings
     425CFLAGS+=$(pkg-config --cflags json-parser)
     426CFLAGS+=-DUSE_EXTERNAL_JSON_PARSER
     427LDFLAGS_BITLBEE+=$(pkg-config --libs json-parser)
     428LDFLAGS_TESTS+=$(pkg-config --libs json-parser)
     429EOF
    426430fi
    427431
     
    448452               
    449453                ssl=gnutls
    450                 ret=1;
     454                ret=1
    451455        else
    452                 ret=0;
    453         fi;
     456                ret=0
     457        fi
    454458}
    455459
     
    463467               
    464468                ssl=nss
    465                 ret=1;
     469                ret=1
    466470        else
    467                 ret=0;
    468         fi;
     471                ret=0
     472        fi
    469473}
    470474
     
    473477#include <netinet/in.h>
    474478#include <arpa/nameser.h>
    475 #include <resolv.h> 
     479#include <resolv.h>
    476480
    477481int main()
     
    487491#include <netinet/in.h>
    488492#include <arpa/nameser.h>
    489 #include <resolv.h> 
     493#include <resolv.h>
    490494
    491495int main()
     
    539543        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
    540544        ret=1
    541         echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
     545        echo "$RESOLV_TESTCODE" | $CC -o "$TMPFILE" -x c - $LIBRESOLV >/dev/null 2>/dev/null
    542546        if [ "$?" = "0" ]; then
    543547                echo "EFLAGS+=$LIBRESOLV" >> Makefile.settings
     
    545549        fi
    546550
    547         rm -f $TMPFILE
     551        rm -f "$TMPFILE"
    548552        return $ret
    549553}
     
    554558        ret=1
    555559        for i in $systemlibdirs; do
    556                 if [ -f $i/libresolv.a ]; then
    557                         echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
     560                if [ -f "$i/libresolv.a" ]; then
     561                        echo "$RESOLV_TESTCODE" | $CC -o "$TMPFILE" -x c - -Wl,"$i/libresolv.a" >/dev/null 2>/dev/null
    558562                        if [ "$?" = "0" ]; then
    559                                 echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
     563                                echo "EFLAGS+=$i/libresolv.a" >> Makefile.settings
    560564                                ret=0
    561565                        fi
     
    563567        done
    564568
    565         rm -f $TMPFILE
     569        rm -f "$TMPFILE"
    566570        return $ret
    567571}
     
    578582        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
    579583        ret=1
    580         echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null
     584        echo "$RESOLV_NS_TESTCODE" | $CC -o "$TMPFILE" -x c - $LIBRESOLV >/dev/null 2>/dev/null
    581585        if [ "$?" = "0" ]; then
    582586                ret=0
    583587        fi
    584588
    585         rm -f $TMPFILE
     589        rm -f "$TMPFILE"
    586590        return $ret
    587591}
     
    592596        ret=1
    593597        for i in $systemlibdirs; do
    594                 if [ -f $i/libresolv.a ]; then
    595                         echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null
     598                if [ -f "$i/libresolv.a" ]; then
     599                        echo "$RESOLV_NS_TESTCODE" | $CC -o "$TMPFILE" -x c - -Wl,"$i/libresolv.a" >/dev/null 2>/dev/null
    596600                        if [ "$?" = "0" ]; then
    597601                                ret=0
     
    600604        done
    601605
    602         rm -f $TMPFILE
     606        rm -f "$TMPFILE"
    603607        return $ret
    604608}
     
    610614        # since we aren't actually linking with ns_* routines
    611615        # we can just compile the test code
    612         echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c - >/dev/null 2>/dev/null
     616        echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o "$TMPFILE" -x c - >/dev/null 2>/dev/null
    613617        if [ "$?" = "0" ]; then
    614618                ret=0
    615619        fi
    616620
    617         rm -f $TMPFILE
     621        rm -f "$TMPFILE"
    618622        return $ret
    619623}
     
    623627        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
    624628        ret=1
    625         echo "$BACKTRACE_TESTCODE" | $CC -o $TMPFILE -x c - >/dev/null 2>/dev/null
     629        echo "$BACKTRACE_TESTCODE" | $CC -o "$TMPFILE" -x c - >/dev/null 2>/dev/null
    626630        if [ "$?" = "0" ]; then
    627631                ret=0
    628632        fi
    629633
    630         rm -f $TMPFILE
     634        rm -f "$TMPFILE"
    631635        return $ret
    632636}
     
    681685       
    682686        exit 1
    683 fi;
     687fi
    684688
    685689echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings
     
    699703if detect_backtrace; then
    700704        echo '#define HAVE_BACKTRACE' >> config.h
    701         echo '#define CRASHFILE "'$config'crash.log"' >> config.h
     705        echo '#define CRASHFILE "'"$config"'crash.log"' >> config.h
    702706fi
    703707
     
    707711        STORAGE_OBJS="$STORAGE_OBJS storage_$i.o"
    708712done
    709 echo "STORAGE_OBJS="$STORAGE_OBJS >> Makefile.settings
     713echo "STORAGE_OBJS=$STORAGE_OBJS" >> Makefile.settings
    710714
    711715authobjs=
     
    719723        fi
    720724        echo '#define WITH_PAM' >> config.h
    721         authobjs=$authobjs'auth_pam.o '
    722         authlibs=$authlibs'-lpam '
     725        authobjs="${authobjs}auth_pam.o "
     726        authlibs="${authlibs}-lpam "
    723727fi
    724728if [ "$ldap" = 0 ]; then
     
    730734        fi
    731735        echo '#define WITH_LDAP' >> config.h
    732         authobjs=$authobjs'auth_ldap.o '
    733         authlibs=$authlibs'-lldap '
    734 fi
    735 echo AUTH_OBJS=$authobjs >> Makefile.settings
    736 echo EFLAGS+=$authlibs >> Makefile.settings
     736        authobjs="${authobjs}auth_ldap.o "
     737        authlibs="${authlibs}-lldap "
     738fi
     739echo "AUTH_OBJS=$authobjs" >> Makefile.settings
     740echo "EFLAGS+=$authlibs" >> Makefile.settings
    737741
    738742if [ "$strip" = 0 ]; then
    739         echo "STRIP=\# skip strip" >> Makefile.settings;
     743        echo "STRIP=\# skip strip" >> Makefile.settings
    740744else
    741745        if [ "$debug" = 1 ]; then
     
    743747                echo 'Stripping binaries does not make sense when debugging. Stripping disabled.'
    744748                echo 'STRIP=\# skip strip' >> Makefile.settings
    745                 strip=0;
     749                strip=0
    746750        elif [ -n "$STRIP" ]; then
    747                 echo "STRIP=$STRIP" >> Makefile.settings;
     751                echo "STRIP=$STRIP" >> Makefile.settings
    748752        elif type strip > /dev/null 2> /dev/null; then
    749                 echo "STRIP=strip" >> Makefile.settings;
     753                echo "STRIP=strip" >> Makefile.settings
    750754        else
    751755                echo
    752756                echo 'No strip utility found, cannot remove unnecessary parts from executable.'
    753757                echo 'STRIP=\# skip strip' >> Makefile.settings
    754                 strip=0;
    755         fi;
     758                strip=0
     759        fi
    756760fi
    757761
    758762if [ ! "$systemd" = "0" ]; then
    759     if ! $PKG_CONFIG --exists systemd; then
    760         if [ "$systemd" = "1" ]; then
    761             echo "systemd requested but not found"
    762             exit 1
    763         else
    764             systemd=0
    765         fi
    766     elif [ "$systemd" = "auto" ]; then
    767         systemd=1
    768     fi
     763        if ! $PKG_CONFIG --exists systemd; then
     764                if [ "$systemd" = "1" ]; then
     765                        echo "systemd requested but not found"
     766                        exit 1
     767                else
     768                        systemd=0
     769                fi
     770        elif [ "$systemd" = "auto" ]; then
     771                systemd=1
     772        fi
    769773fi
    770774
    771775pkgconf_systemd_var() {
    772     # First try deprecated variable, use newer variable if not found
    773     if $PKG_CONFIG --print-variables systemd | grep -q "$1"; then
    774         $PKG_CONFIG --variable="$1" systemd
    775     else
    776         $PKG_CONFIG --variable="$2" systemd
    777     fi
     776        # First try deprecated variable, use newer variable if not found
     777        if $PKG_CONFIG --print-variables systemd | grep -q "$1"; then
     778                $PKG_CONFIG --variable="$1" systemd
     779        else
     780                $PKG_CONFIG --variable="$2" systemd
     781        fi
    778782}
    779783
     
    806810fi
    807811
    808 otrprefix=""
    809812if [ "$otr" = "auto" ]; then
    810813        ! $PKG_CONFIG --exists libotr
     
    819822        # BI == built-in
    820823        echo '#define OTR_BI' >> config.h
    821         echo "EFLAGS+=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
    822         echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
    823         echo 'OTR_BI=otr.o' >> Makefile.settings
     824        cat <<EOF >>Makefile.settings
     825EFLAGS+=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)
     826CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)
     827OTR_BI=otr.o
     828EOF
    824829elif [ "$otr" = "plugin" ]; then
    825830        # for some mysterious reason beyond the comprehension of my mortal mind,
    826831        # the libgcrypt flags aren't needed when building as plugin. add them anyway.
    827832        echo '#define OTR_PI' >> config.h
    828         echo "OTRFLAGS=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)" >> Makefile.settings
    829         echo "CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)" >> Makefile.settings
    830         echo 'OTR_PI=otr.so' >> Makefile.settings
     833        cat <<EOF >>Makefile.settings
     834OTRFLAGS=$($PKG_CONFIG --libs libotr) $(libgcrypt-config --libs)
     835CFLAGS+=$($PKG_CONFIG --cflags libotr) $(libgcrypt-config --cflags)
     836OTR_PI=otr.so
     837EOF
    831838fi
    832839
     
    842849if [ "$doc" = "1" ]; then
    843850        # check this here just in case someone tries to install it in python2.4...
    844         if [ ! -e $srcdir/doc/user-guide/help.txt ] && ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then
     851        if [ ! -e "$srcdir/doc/user-guide/help.txt" ] && ! $PYTHON -m xml.etree.ElementTree > /dev/null 2>&1; then
    845852                echo
    846853                echo 'ERROR: Python (>=2.5 or 3.x) is required to generate docs'
     
    857864        echo "Spoofing version number: $BITLBEE_VERSION"
    858865        echo "#undef BITLBEE_VERSION" >> config.h
    859         echo '#define BITLBEE_VERSION "'$BITLBEE_VERSION'"' >> config.h
     866        echo '#define BITLBEE_VERSION "'"$BITLBEE_VERSION"'"' >> config.h
    860867        echo
    861868fi
     
    878885case "$arch" in
    879886CYGWIN* )
     887        # shellcheck disable=SC2016
    880888        pkgconfiglibs='-L${libdir} -lbitlbee -no-undefined'
    881889esac
     
    915923        echo '#define WITH_PURPLE' >> config.h
    916924        cat<<EOF >>Makefile.settings
    917 EFLAGS += $($PKG_CONFIG purple --libs)
    918 PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
     925EFLAGS+=$($PKG_CONFIG purple --libs)
     926PURPLE_CFLAGS+=$($PKG_CONFIG purple --cflags)
    919927EOF
    920928        protocols=$protocols'purple '
     
    937945case "$CC" in
    938946*gcc* )
    939         echo CFLAGS+=-MMD -MF .depend/\$@.d >> Makefile.settings
     947        echo "CFLAGS+=-MMD -MF .depend/\$@.d" >> Makefile.settings
    940948        for i in . lib tests protocols protocols/*/; do
    941                 mkdir -p $i/.depend
     949                mkdir -p "$i/.depend"
    942950        done
    943951esac
     
    967975echo "PROTOOBJS = $protoobjs" >> Makefile.settings
    968976
    969 echo Architecture: $arch
     977echo "Architecture: $arch"
    970978case "$arch" in
    971979Linux )
     
    10491057fi
    10501058
    1051 echo '  Using python: '$PYTHON
     1059echo "  Using python: $PYTHON"
    10521060
    10531061if [ "$external_json_parser" = "1" ]; then
    1054     echo '  Using system JSON parser.'
    1055 else
    1056     echo '  Using bundled JSON parser.'
    1057 fi
    1058 
    1059 echo '  Using event handler: '$events
    1060 echo '  Using SSL library: '$ssl
     1062        echo '  Using system JSON parser.'
     1063else
     1064        echo '  Using bundled JSON parser.'
     1065fi
     1066
     1067echo "  Using event handler: $events"
     1068echo "  Using SSL library: $ssl"
    10611069#echo '  Building with these storage backends: '$STORAGES
    10621070
    10631071if [ -n "$protocols" ]; then
    1064         echo '  Building with these protocols:' $protocols$protocols_mods
     1072        echo "  Building with these protocols: $protocols$protocols_mods"
    10651073        case "$protocols" in
    10661074        *purple*)
Note: See TracChangeset for help on using the changeset viewer.