Search code examples
syntax-errorcross-compilingbinutils

Syntax error when running configure in binutils


Was building a cross compiler from C to the i686 processor with the elf file structure. When I ran configure for binutils, it ran until creating config.status and gave the error:

configure: creating ./config.status
./config.status: line 470: syntax error near unexpected token `)'
./config.status: line 470: `    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;'[

for reference, I am on MacOS 10.14.6, building binutils-2.37, and I am following the OSDev GCC Cross-Compiler Tutorial. These are the configure options I used:

toolchain/i686-elf-source/binutils-2.37/configure --target=i686-elf --prefix="toolchain/i686-elf-build" --with-sysroot --disable-nls --disable-werror (Note that pwd=toolchain/i686-elf-build/binutils-build)

The expected result looks like this:

configure: creating ./config.status
config.status: creating makefile

The syntax error was oddly specific, and I could not find any similar syntax errors while searching. I had previously tried a different prefix, but it still didn't work. I am still a beginner in bash, so I couldn't find what the core of the error was in config.status, and I am still trying to find similar issues.

I would definitely appreciate help. Thanks!


Solution

  • Nevermind, I found that it was a misbehaving quote. Here are some snippets:

    srcdir='../../i686-elf-source/binutils-2.37'
    INSTALL='/usr/bin/install -c'
    'AWK='awk' # The starting single quote is my horrible patch
    test -n "$AWK" || AWK=awk
    

    ^ Code where the error really started

    and

      -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
        ac_cs_recheck=: ;;
      --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
        $as_echo "$ac_cs_version"; exit ;;
      --config | --confi | --conf | --con | --co | --c )
        $as_echo "$ac_cs_config"; exit ;;
      --debug | --debu | --deb | --de | --d | -d )
        debug=: ;;
      --file | --fil | --fi | --f )
        $ac_shift
        case $ac_optarg in
        *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; # The error line
        '') as_fn_error $? "missing file argument" ;;
        esac
    

    ^ Where the error was shown

    Welp, that was 2 weeks I'm never getting back. If someone gets a similar error, I hope this helps!