Index: utils/objfw-compile ================================================================== --- utils/objfw-compile +++ utils/objfw-compile @@ -44,11 +44,11 @@ printf "\033[K\033[0;31mFailed to link \033[1;31m$1\033[0;31m!" printf "\033[0m\n" exit $2 } -flags_done="no" +srcs="" out="" objs="" link="no" lib="no" out_prefix="" @@ -59,16 +59,10 @@ -o|--out) shift out="$1" ;; --lib) - if test x"flags_done" = x"yes"; then - printf "The --lib flag needs to be specified " - printf "before any source file!\n" - exit 1 - fi - shift if ! echo "$1" | grep "^[0-9]\+\.[0-9]\+" >/dev/null then echo "$1 is not a valid library version!" @@ -124,32 +118,11 @@ -*) echo "Unknown option: $1" exit 1 ;; *.m) - flags_done="yes" - obj="${1%.m}.o" - objs="$objs $obj" - build="no" - deps=$($OBJC -E -M $CPPFLAGS $ENV_CPPFLAGS $1 | \ - sed 's/.*: //' | sed 's/\\//g') - - if test -f "$obj"; then - for dep in $deps; do - test "$dep" -nt $obj && build="yes" - done - else - build="yes" - fi - - if test x"$build" = x"yes"; then - link="yes" - status_compiling $1 - $OBJC $CPPFLAGS $OBJCFLAGS -c -o $obj $1 || \ - status_compile_failed $1 $? - status_compiled $1 - fi + srcs="$srcs $1" ;; *) echo "Only .m files can be compiled!" 1>&2 exit 1 ;; @@ -160,14 +133,38 @@ if test x"$out" = x""; then echo "No output name specified! Use -o or --out!" exit 1 fi + +for i in $srcs; do + obj="${i%.m}.o" + objs="$objs $obj" + build="no" + deps=$($OBJC -E -M $CPPFLAGS $ENV_CPPFLAGS $i | \ + sed 's/.*: //' | sed 's/\\//g') + + if test -f "$obj"; then + for dep in $deps; do + test "$dep" -nt $obj && build="yes" + done + else + build="yes" + fi + + if test x"$build" = x"yes"; then + link="yes" + status_compiling $i + $OBJC $CPPFLAGS $OBJCFLAGS -c -o $obj $i || \ + status_compile_failed $i $? + status_compiled $i + fi +done test x"$lib" = x"no" && out_suffix="$($OBJFW_CONFIG --prog-suffix)" if test ! -f "$out_prefix$out$out_suffix" -o x"$link" = x"yes"; then status_linking $out_prefix$out$out_suffix $OBJC -o $out_prefix$out$out_suffix $objs $LIBS $ENV_LIBS $LDFLAGS \ $ENV_LDFLAGS || status_link_failed $out $? status_linked $out_prefix$out$out_suffix fi