019eeedcffbb9af2ac5357276b032368e2e4fe7f
[sxemacs] / m4 / sxe-srctree.m4
1 dnl sxe-srctree.m4 -- Checks on source tree and build directory
2
3 AC_DEFUN([SXE_COMPUTE_BLDDIR], [dnl
4         ## Calculate canonical name for sxe_blddir (i.e. current directory).
5         ## PWD may already be the preferable absolute name for ".",
6         ## but we can't trust it - it is sometimes inaccurate.
7         ## defines sxe_blddir
8         absolute_pwd=$(pwd);
9         if test -n "$PWD" -a $(cd $PWD && pwd) = "$absolute_pwd"; then
10                 sxe_blddir="$PWD"
11         else
12                 sxe_blddir="$absolute_pwd"
13                 SXE_CANONICALISE_PATH([sxe_blddir])
14         fi
15 ])dnl SXE_COMPUTE_BLDDIR
16
17 AC_DEFUN([SXE_COMPUTE_SRCDIR], [dnl
18         ## Make srcdir absolute, if not already.  It is important to
19         ## avoid running the path through pwd unnecessary, since pwd can
20         ## give you automounter prefixes, which can go away.
21         ##   so? we want to build at last from our srcdir -hrop
22         ## defines sxe_srcdir
23         case "$srcdir" in
24         /* )
25                 sxe_srcdir="$srcdir"
26                 ;;
27         . )
28                 sxe_srcdir="$sxe_blddir"
29                 ;;
30         * )
31                 sxe_srcdir=$(cd $srcdir && pwd)
32                 SXE_CANONICALISE_PATH([sxe_srcdir])
33                 ;;
34         esac
35 ])dnl SXE_COMPUTE_BLDDIR
36
37 AC_DEFUN([SXE_CHECK_SRCDIR_HEALTH], [dnl
38         ## check whether both sxe_blddir and sxe_srcdir have been set
39         if test "${sxe_blddir-unset}" = "unset"; then
40                 ## run the computation
41                 SXE_COMPUTE_BLDDIR
42         fi
43         if test "${sxe_srcdir-unset}" = "unset"; then
44                 ## run the computation
45                 SXE_COMPUTE_SRCDIR
46         fi
47
48         ## check if source dir and build dir coincide
49         AC_MSG_CHECKING([if source tree coincides with the build tree])
50         if test "$sxe_blddir" = "$sxe_srcdir" -o \
51                 -f "$sxe_blddir/sxemacs_version.m4"; then
52                 AC_MSG_RESULT([yes])
53                 srcdir_equals_blddir_p=yes
54         else
55                 AC_MSG_RESULT([no. Good Boy!])
56                 srcdir_equals_blddir_p=no
57         fi
58
59         ## Check if the source directory already has a configured system in it.
60         if test "$srcdir_equals_blddir_p" = "no" -a \
61                 -f "$sxe_srcdir/src/config.h" -o \
62                 "$srcdir_equals_blddir_p" = "no" -a \
63                 -e "$sxe_srcdir/.sxemacs.source.tree"; then
64                 AC_MSG_WARN([The directory tree `$sxe_srcdir' is being used])
65                 AC_MSG_WARN([as a build directory right now; it has been configured in its own])
66                 AC_MSG_WARN([right.  To configure in another directory as well, you MUST])
67                 AC_MSG_WARN([use GNU make.  If you do not have GNU make, then you must])
68                 AC_MSG_WARN([now do `make distclean' in $sxe_srcdir,])
69                 AC_MSG_WARN([and then run $progbasename again.])
70         fi
71
72 ])dnl SXE_CHECK_SRCDIR_HEALTH
73
74 dnl sxe-srctree.m4 ends here