-# NAME
-# mkcsrc - generate a new c_src directory from a current nitc bootstrap
-# SYNOPSIS
-# ./mkcsrc [number]
-# DESCRIPTION
-# transform a bootstrap result (generated by the nc tool) into a new
-# c_src in the current directory (previous one will be errased).
-# One c_src generated, you can replace the old one in the root.
-# Before commiting, do not forget to:
-# * verify any regression
-# * add/remove files in c_src
-# OPTION
-# number is the bootstrap level (prefix) to use. It correspond to the nc
-# level. By default, the lastest generated nitc is used
-
-# prefix
-p=$1
-
-if [ "x$p" = "x" ]; then
- p=`ls .nit_compile/nitc*.sh -t | head -1 | sed 's!\.nit_compile/nitc\.\(.*\)_build\.sh!\1!'`
- if [ "x$p" = "x" ]; then
- echo "No generated nitc"
- exit 1
- fi
- echo "Lastest generated nitc uses prefix $p"
-fi
-
-rm -r c_src 2> /dev/null
-mkdir c_src
-
-sed -n "s|.nit_compile/\\(.*\\).${p}_sep.c.*|\\1|p" .nit_compile/nitc.${p}_build.sh | while read -r file; do
- echo "* $file"
- sed "/include/s/.${p}_/._/" ".nit_compile/$file.${p}_sep.c" > c_src/${file}._sep.c
- sed "/include/s/.${p}_/._/" ".nit_compile/$file.${p}_sep.h" > c_src/${file}._sep.h
+# Copy all direct dependencies
+for f in `grep -h -o '[^ ]*/[^ /]*\.c' "$out/Makefile" | sort -u`; do
+ cp "$out/$f" "$out/"
+ cp "$out/${f%c}h" "$out/"
+done
+for f in `grep -h -o '\.\..*\.h' "$out"/*.[ch] | sort -u`; do
+ cp "$out/$f" "$out/"