@@ -76,18 +76,18 @@ test -z "$1" && show_help 1 package_description() { if test "$1" != "1"; then - echo "Unsupported package description version: $1" + echo "Unsupported package description version: $1" 1>&2 exit 1 fi } package_depends_on() { if ! test -f "$packagesdir/$1.oc"; then - echo "No such package: $1" + echo "No such package: $1" 1>&2 exit 1 fi set -e source "$packagesdir/$1.oc" @@ -104,123 +104,131 @@ esac shift done } parse_packages "$@" + +flag_printed="no" +output_flag() { + if test x"$flag_printed" = x"yes"; then + printf " %s" "$1" + else + printf "%s" "$1" + flag_printed="yes" + fi +} while test x"$1" != "x"; do case "$1" in --all) - printf "%s %s %s " "$CFLAGS" "$CPPFLAGS" "$CXXFLAGS" - printf "%s %s " "$OBJCFLAGS" "$LDFLAGS" - printf "%s %s " "$LDFLAGS_REEXPORT" "$LDFLAGS_RPATH" - printf "%s" "$LIBS" + output_flag "$CFLAGS $CPPFLAGS $CXXFLAGS $OBJCFLAGS" + output_flag "$LDFLAGS $LDFLAGS_REEXPORT $LDFLAGS_RPATH" + output_flag "$LIBS" ;; --arc) - printf "%s" "-fobjc-arc -fobjc-arc-exceptions" + output_flag "-fobjc-arc -fobjc-arc-exceptions" ;; --cflags) - printf "%s" "$CFLAGS" + output_flag "$CFLAGS" ;; --cppflags) - printf "%s" "$CPPFLAGS" + output_flag "$CPPFLAGS" ;; --cxxflags) - printf "%s" "$CXXFLAGS" + output_flag "$CXXFLAGS" ;; --framework-libs) - printf "%s" "$FRAMEWORK_LIBS" + output_flag "$FRAMEWORK_LIBS" ;; --help) show_help 0 ;; --objc) - printf "%s" "$OBJC" + output_flag "$OBJC" ;; --objcflags) - printf "%s" "$OBJCFLAGS" + output_flag "$OBJCFLAGS" ;; --libs) - printf "%s" "$LIBS" + output_flag "$LIBS" ;; --lib-cflags) if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then echo "LIB_MAJOR and LIB_MINOR need to be set!" \ 1>&2 exit 1 fi - printf "%s" "$LIB_CFLAGS" + output_flag "$LIB_CFLAGS" ;; --lib-ldflags) if test x"$SHARED_LIB" = x"" -o x"$LIB_MAJOR" = x"" \ -o x"$LIB_MINOR" = x""; then printf "SHARED_LIB, LIB_MAJOR and " 2>&1 - echo "and LIB_MINOR to be set!" 1>&2 + echo "LIB_MINOR need to be set!" 1>&2 exit 1 fi - printf "%s" "$LIB_LDFLAGS" + output_flag "$LIB_LDFLAGS" ;; --lib-prefix) if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then echo "LIB_MAJOR and LIB_MINOR need to be set!" \ 1>&2 exit 1 fi - printf "%s" "$LIB_PREFIX" + output_flag "$LIB_PREFIX" ;; --lib-suffix) if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then echo "LIB_MAJOR and LIB_MINOR need to be set!" \ 1>&2 exit 1 fi - printf "%s" "$LIB_SUFFIX" + output_flag "$LIB_SUFFIX" ;; --ldflags) - printf "%s" "$LDFLAGS" + output_flag "$LDFLAGS" ;; --reexport) - printf "%s" "$LDFLAGS_REEXPORT" + output_flag "$LDFLAGS_REEXPORT" ;; --rpath) - printf "%s" "$LDFLAGS_RPATH" + output_flag "$LDFLAGS_RPATH" ;; --package) # Already included into the flags. shift ;; --packages-dir) - printf "%s" "$packagesdir" + output_flag "$packagesdir" ;; --plugin-cflags) - printf "%s" "$PLUGIN_CFLAGS" + output_flag "$PLUGIN_CFLAGS" ;; --plugin-ldflags) - printf "%s" "$PLUGIN_LDFLAGS" + output_flag "$PLUGIN_LDFLAGS" ;; --plugin-suffix) - printf "%s" "$PLUGIN_SUFFIX" + output_flag "$PLUGIN_SUFFIX" ;; --prog-suffix) - printf "%s" "$PROG_SUFFIX" + output_flag "$PROG_SUFFIX" ;; --static-libs) - printf "%s" "$STATIC_LIBS" + output_flag "$STATIC_LIBS" ;; --version) - printf "%s" "$VERSION" + output_flag "$VERSION" ;; *) echo "Invalid option: $1" 1>&2 exit 1 ;; esac shift - - test -n "$1" && printf " " done -echo +test x"$flag_printed" = x"yes" && echo +exit 0