Merge branch 'master' of git://git.postgresql.org/git/postgresql
[pgsql-fdw.git] / config / prep_buildtree
blobf9164cfa2fafa588e378839a471b47680e18d8bf
1 #! /bin/sh
3 # This script prepares a PostgreSQL build tree. It is intended
4 # to be run by the configure script.
6 me=`basename $0`
8 help="\
9 Usage: $me sourcetree [buildtree]"
11 if test -z "$1"; then
12 echo "$help" 1>&2
13 exit 1
14 elif test x"$1" = x"--help"; then
15 echo "$help"
16 exit 0
19 unset CDPATH
21 sourcetree=`cd $1 && pwd`
23 buildtree=`cd ${2:-'.'} && pwd`
25 for item in `find "$sourcetree" -type d \( -name CVS -prune -o -print \)`; do
26 subdir=`expr "$item" : "$sourcetree\(.*\)"`
27 if test ! -d "$buildtree/$subdir"; then
28 mkdir -p "$buildtree/$subdir" || exit 1
30 done
32 for item in `find "$sourcetree" -name Makefile -print -o -name GNUmakefile -print`; do
33 filename=`expr "$item" : "$sourcetree\(.*\)"`
34 if test ! -f "${item}.in"; then
35 if cmp "$item" "$buildtree/$filename" >/dev/null 2>&1; then : ; else
36 ln -fs "$item" "$buildtree/$filename" || exit 1
39 done
41 # We must not auto-create the subdirectories holding built documentation.
42 # If we did, it would interfere with installation of prebuilt docs from
43 # the source tree, if a VPATH build is done from a distribution tarball.
44 # See bug #5595.
45 rmdir "$buildtree/doc/src/sgml/html" 2>/dev/null
46 rmdir "$buildtree/doc/src/sgml/man1" 2>/dev/null
47 rmdir "$buildtree/doc/src/sgml/man3" 2>/dev/null
48 rmdir "$buildtree/doc/src/sgml/man7" 2>/dev/null
50 exit 0