1#! /bin/sh
2#
3# Licensed to the Apache Software Foundation (ASF) under one or more
4# contributor license agreements.  See the NOTICE file distributed with
5# this work for additional information regarding copyright ownership.
6# The ASF licenses this file to You under the Apache License, Version 2.0
7# (the "License"); you may not use this file except in compliance with
8# the License.  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#
19# The build environment was provided by Sascha Schumann.
20
21srcdir=$1
22shift
23
24mkdir_p=$1
25shift
26
27bsd_makefile=$1
28shift
29
30top_srcdir=`(cd $srcdir; pwd)`
31top_builddir=`pwd`
32
33if test "$mkdir_p" = "yes"; then
34  mkdir_p="mkdir -p"
35else
36  mkdir_p="$top_srcdir/build/mkdir.sh"
37fi
38
39if test "$bsd_makefile" = "yes"; then
40  (cd $top_srcdir; ./build/bsd_makefile)
41
42  for makefile in $@; do
43    echo "creating $makefile"
44    dir=`echo $makefile|sed 's%/*[^/][^/]*$%%'`
45
46    if test -z "$dir"; then
47        real_srcdir=$top_srcdir
48        real_builddir=$top_builddir
49        dir="."
50    else
51        $mkdir_p "$dir/"
52        real_srcdir=$top_srcdir/$dir
53        real_builddir=$top_builddir/$dir
54    fi
55    cat - $top_srcdir/$makefile.in <<EOF |sed 's/^include \(.*\)/.include "\1"/' >$makefile 
56top_srcdir   = $top_srcdir
57top_builddir = $top_builddir
58srcdir       = $real_srcdir
59builddir     = $real_builddir
60VPATH        = $real_srcdir
61EOF
62
63    touch $dir/.deps
64  done
65else
66  for makefile in $@; do
67    echo "creating $makefile"
68    dir=`echo $makefile|sed 's%/*[^/][^/]*$%%'`
69
70    if test -z "$dir"; then
71        real_srcdir=$top_srcdir
72        real_builddir=$top_builddir
73        dir="."
74    else
75        $mkdir_p "$dir/"
76        real_srcdir=$top_srcdir/$dir
77        real_builddir=$top_builddir/$dir
78    fi
79    cat - $top_srcdir/$makefile.in <<EOF >$makefile
80top_srcdir   = $top_srcdir
81top_builddir = $top_builddir
82srcdir       = $real_srcdir
83builddir     = $real_builddir
84VPATH        = $real_srcdir
85EOF
86
87    touch $dir/.deps
88  done
89fi
90