From c7888220b30e5933b76c0d5359c6f56874859fee Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 29 Apr 2019 19:22:48 -0700 Subject: build: allow $(pwd)/configure to work. When the build is being done in the source directory, allow the configure script to be executed via path names other than just ./configure, such as an absolute path. Some distros use this. * configure (build_in_srcdir): New variable. (inode): New function. Rather than checking whether "$source_dir" is ".", we test whether they are the same inode. If they are the same, we now also set the build_in_srcdir variable in addition to generating the usual warning. (gen_config_make): Propagate the build_in_srcdir into config.make. * Makefile: use the build_in_srcdir variable from config.make to determine whether we are building in the source directory, rather than relying on top_srcdir being blank. --- Makefile | 2 +- configure | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 762387a8..90ba219f 100644 --- a/Makefile +++ b/Makefile @@ -203,7 +203,7 @@ notconfigured: $(V)exit 1 endif -ifneq ($(top_srcdir),) +ifneq ($(build_in_srcdir),y) ifneq ($(wildcard $(top_srcdir)/config.h $(top_srcdir)/y.tab.h),) .PHONY: tainted tainted: diff --git a/configure b/configure index f1adb919..d4869452 100755 --- a/configure +++ b/configure @@ -84,6 +84,7 @@ help= # # config # +build_in_srcdir= prefix='/usr/local' install_prefix= bindir='bin' @@ -629,6 +630,12 @@ lndir() done } +inode() +{ + set -- $(ls -idL "$1") + printf "%s\n" "$1" +} + case "$top_srcdir" in " "* | *" "* | *" " ) printf " bad (contains spaces)\n" @@ -639,7 +646,7 @@ case "$top_srcdir" in ;; esac -if [ "$source_dir" != "." ] ; then +if [ $(inode "$source_dir") != $(inode ".") ] ; then for x in Makefile ; do printf "Symlinking %s -> $source_dir/%s\n" $x $x ln -sf "$source_dir/$x" . @@ -650,6 +657,7 @@ if [ "$source_dir" != "." ] ; then done else printf "** Note: it's recommended to build in a separate directory\n" + build_in_srcdir=y fi gen_config_make() @@ -670,6 +678,9 @@ txr_ver := $txr_ver # absolute path to source code directory top_srcdir := $top_srcdir +# build directory is top_srcdir +build_in_srcdir = $build_in_srcdir + # ultimate installation prefix, where the # application will be run. prefix := $prefix -- cgit v1.2.3