update NOTICE and LICENSE
[nit.git] / src / mkcsrc
1 #!/bin/sh
2 # This file is part of NIT ( http://www.nitlanguage.org ).
3 #
4 # Copyright 2008 Jean Privat <jean@pryen.org>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 # NAME
19 #       mkcsrc - generate a new c_src directory from a current nitc bootstrap
20 # SYNOPSIS
21 #       ./mkcsrc [number]
22 # DESCRIPTION
23 #       transform a bootstrap result (generated by the nc tool) into a new
24 #       c_src in the current directory (previous one will be errased).
25 #       One c_src generated, you can replace the old one in the root.
26 #       Before commiting, do not forget to:
27 #        * verify any regression
28 #        * add/remove files in c_src
29 # OPTION
30 #       number is the bootstrap level to use.  It corresponds to the nc
31 #       level.  By default, the lastest generated nitc is used.
32
33 # prefix
34 p=$1
35
36 if [ "x$p" = "x" ]; then
37         p=`ls .nit_compile*/nitc._build.sh -t | head -1 | sed 's!\.nit_compile\(.*\)/nitc\._build\.sh!\1!'`
38         if [ "x$p" = "x" ]; then
39                 echo "No generated nitc"
40                 exit 1
41         fi
42         echo "Lastest generated nitc is bootstrap level $p"
43 fi
44
45 rm -r c_src 2> /dev/null
46 mkdir c_src
47
48 sed -n '/^ *.nit_compile/{s!\\$!!;p}' .nit_compile3/nitc._build.sh | while read -r file; do
49         cp $file c_src
50         [ -r ${file%.c}.h ] && cp ${file%.c}.h c_src
51 done
52 sed -e "s|.nit_compile${p}|.|g;s|/\[a-z\]+/../|/|g;s|nitc_${p}|nitc|" -e 's/^CLIBDIR=.*/CLIBDIR="clib"/' .nit_compile${p}/nitc._build.sh > c_src/nitc._build.sh
53 chmod +x c_src/nitc._build.sh
54 cp -r ../c_src/Makefile ../c_src/README ../clib c_src
55