#!/bin/bash
cd ..
-out=c_src2
+out=c_src
rm -r "$out/" 2> /dev/null
set -e
set -x
-src/nitg src/nitg.nit -v "$@" --compile-dir "$out" -o "$out/nitg" --no-cc
-cp "$out/nitg.mk" "$out/Makefile"
+src/nitg src/nith.nit --semi-global -v "$@" --compile-dir "$out" -o "$out/nitg" --no-cc
+cp "$out/nith.mk" "$out/Makefile"
sed -i -e "s#../$out/##g" "$out/Makefile"
# Copy all direct dependencies
# Update references in file
perl -i -npe 's#"\.\./.*?([^/]*.h)"#"\1"#' "$out"/*.[ch]
perl -i -npe 's#\S*/([^/]*.[ch])#\1#' "$out/Makefile"
-perl -i -npe 's#../clib#.#' "$out/Makefile"
+perl -i -npe 's#\.\./clib#.#' "$out/Makefile"
+
+# Remove old compilation flags
+sed -i -e 's/OLDNITCOPT=.*/OLDNITCOPT=/' src/Makefile