blob: 2baefa2ee00021c08a289fcc26cc349730366e11 [file] [log] [blame]
Denys Vlasenko7fb68f12010-05-09 04:22:48 +02001#!/bin/sh
2
Denys Vlasenko572b9a32010-05-09 16:20:52 +02003test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
Denys Vlasenko7fb68f12010-05-09 04:22:48 +02004
5# cd to objtree
Denys Vlasenko8e3aff02010-05-10 11:00:11 +02006cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
Denys Vlasenko7fb68f12010-05-09 04:22:48 +02007
8srctree="$1"
9
Denys Vlasenko572b9a32010-05-09 16:20:52 +020010find -type d | while read; do
Denys Vlasenko8e3aff02010-05-10 11:00:11 +020011 d="$REPLY"
Denys Vlasenko7fb68f12010-05-09 04:22:48 +020012
Denys Vlasenko8e3aff02010-05-10 11:00:11 +020013 src="$srctree/$d/Kbuild.src"
14 dst="$d/Kbuild"
15 if test -f "$src"; then
16 echo " CHK $dst"
Denys Vlasenko7fb68f12010-05-09 04:22:48 +020017
Denys Vlasenko8e3aff02010-05-10 11:00:11 +020018 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c`
19 echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp"
20 while read; do
21 test x"$REPLY" = x"INSERT" && REPLY="$s"
22 printf "%s\n" "$REPLY"
23 done <"$src" >>"$dst.$$.tmp"
Denys Vlasenko7fb68f12010-05-09 04:22:48 +020024
Denys Vlasenko8e3aff02010-05-10 11:00:11 +020025 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
26 rm -- "$dst.$$.tmp"
27 else
28 echo " GEN $dst"
29 mv -- "$dst.$$.tmp" "$dst"
30 fi
Denys Vlasenko7fb68f12010-05-09 04:22:48 +020031 fi
Denys Vlasenko7fb68f12010-05-09 04:22:48 +020032
Denys Vlasenko8e3aff02010-05-10 11:00:11 +020033 src="$srctree/$d/Config.src"
34 dst="$d/Config.in"
35 if test -f "$src"; then
36 echo " CHK $dst"
Denys Vlasenko7fb68f12010-05-09 04:22:48 +020037
Denys Vlasenko8e3aff02010-05-10 11:00:11 +020038 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c`
39 echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp"
40 while read; do
41 test x"$REPLY" = x"INSERT" && REPLY="$s"
42 printf "%s\n" "$REPLY"
43 done <"$src" >>"$dst.$$.tmp"
Denys Vlasenko7fb68f12010-05-09 04:22:48 +020044
Denys Vlasenko8e3aff02010-05-10 11:00:11 +020045 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
46 rm -- "$dst.$$.tmp"
47 else
48 echo " GEN $dst"
49 mv -- "$dst.$$.tmp" "$dst"
50 fi
Denys Vlasenko7fb68f12010-05-09 04:22:48 +020051 fi
Denys Vlasenko7fb68f12010-05-09 04:22:48 +020052
53done
54
55# Last read failed. This is normal. Don't exit with its error code:
56exit 0