I'm trying to make a script which "builds" a configure command line and then runs it, but it fails with an error.
I'm very new to bash script (i'm a Windows user) and i don't know what i'm doing wrong.
This is my script:
#! /bin/sh
# https://www.guru99.com/introduction-to-shell-scripting.html
export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
PARAMS=""
PARAMS="$PARAMS --disable-shared"
PARAMS="$PARAMS --disable-debug"
PARAMS="$PARAMS --with-gtk=2"
PARAMS="$PARAMS --with-libtiff=no"
PARAMS="$PARAMS --with-opengl=no"
PARAMS="$PARAMS --enable-unicode"
PARAMS="$PARAMS --with-libpng=builtin"
PARAMS="$PARAMS --with-libjpeg=builtin"
PARAMS="$PARAMS --enable-std_string_conv_in_wxstring"
PARAMS="$PARAMS --host=arm-linux-gnueabihf"
PARAMS="$PARAMS --build=x86_64-linux-gnu"
GTK_LIBS=$(arm-linux-gnueabihf-pkg-config --libs gtk+-2.0)
echo "GTK_LIBS = " $GTK_LIBS
echo
PARAMS="$PARAMS GTK_LIBS=\"$GTK_LIBS\""
GTK_CFLAGS=$(arm-linux-gnueabihf-pkg-config --cflags gtk+-2.0)
echo "GTK_CFLAGS = " $GTK_CFLAGS
echo
COMMAND="../configure $PARAMS GTK_CFLAGS=\"$GTK_CFLAGS\""
echo "COMMAND = " $COMMAND
echo
echo "Running COMMAND"
$COMMAND
This is the output:
GTK_LIBS = -L/usr/lib/arm-linux-gnueabihf -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype
GTK_CFLAGS = -pthread -I/usr/include/gtk-2.0 -I/usr/lib/arm-linux-gnueabihf/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16
COMMAND = ../configure --disable-shared --disable-debug --with-gtk=2 --with-libtiff=no --with-opengl=no --enable-unicode --with-libpng=builtin --with-libjpeg=builtin --enable-std_string_conv_in_wxstring --host=arm-linux-gnueabihf --build=x86_64-linux-gnu GTK_LIBS="-L/usr/lib/arm-linux-gnueabihf -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype" GTK_CFLAGS="-pthread -I/usr/include/gtk-2.0 -I/usr/lib/arm-linux-gnueabihf/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16"
Running COMMAND
configure: error: unrecognized option: `-lgtk-x11-2.0'
Try `../configure --help' for more information
I don't understand why there's the error: it seems like i didn't add the doublequotes, but they are there and if i just copy/paste the COMMAND from the output in the prompt it works.
I tried searching for answers here... which managed me to add the escaped quotes in the script, but that's all....
What am i missing?