]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 60378] Don't add duplicate default search directories
authorDmitry Goncharov <dgoncharov@users.sf.net>
Sat, 17 Apr 2021 21:50:07 +0000 (17:50 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 30 May 2021 19:11:30 +0000 (15:11 -0400)
Depending on how make was configured it may add duplicate
directories in the default include search path: avoid this.

(Tweaked by psmith@gnu.org)

* configure.ac: Set AM variable KNOWN_PREFIX if --prefix is known
* Makefile.am: Only set INCLUDEDIR if prefix is not known
* read.c [default_include_directories]: Only add INCLUDEDIR if set

Makefile.am
configure.ac
src/read.c

index 2b5765e36d2040c584e4327f46f0cbd4c29114f4..9be60fec3fb58ea9a1adb82e96a427421c80e7d5 100644 (file)
@@ -73,8 +73,12 @@ make_LDADD = $(LIBOBJS) $(_GUILE_LIBS) lib/libgnu.a $(GETLOADAVG_LIBS) \
 localedir =    $(datadir)/locale
 
 AM_CPPFLAGS =  -Isrc -I$(top_srcdir)/src -Ilib -I$(top_srcdir)/lib \
-               -DLIBDIR=\"$(libdir)\" -DINCLUDEDIR=\"$(includedir)\" \
-               -DLOCALEDIR=\"$(localedir)\"
+               -DLIBDIR=\"$(libdir)\" -DLOCALEDIR=\"$(localedir)\"
+
+# If prefix is not a standard location, look in prefix as well
+if !KNOWN_PREFIX
+  AM_CPPFLAGS += -DINCLUDEDIR=\"$(includedir)\"
+endif
 
 AM_CFLAGS =    $(_GUILE_CFLAGS)
 
index 7d8f9ef91427d873571a25e3e995d196aea00cfb..6ad209491113ba462adb9bd4f191f3b14401fbff 100644 (file)
@@ -523,6 +523,11 @@ AS_IF([test "x$make_cv_posix_spawn" = xno && test "x$user_posix_spawn" = xyes],
   echo
 ])
 
+# autoconf initializes $prefix to NONE.
+AM_CONDITIONAL([KNOWN_PREFIX],
+               [test "x$prefix" = xNONE -o "x$prefix" = x/usr/local \
+                     -o "x$prefix" = x/usr/gnu -o "x$prefix" = x/usr])
+
 # Specify what files are to be created.
 AC_CONFIG_FILES([Makefile build.cfg lib/Makefile po/Makefile.in doc/Makefile \
                  tests/config-flags.pm])
index c0e3315f4139954bd8ee9c9fc5d3186d42167a57..4b285c5778fd4e8f3d66943529a8390332158f7d 100644 (file)
@@ -107,7 +107,9 @@ static const char *default_include_directories[] =
    This is defined as a placeholder.  */
 # define INCLUDEDIR "."
 #endif
+#if defined(INCLUDEDIR)
     INCLUDEDIR,
+#endif
 #ifndef _AMIGA
     "/usr/gnu/include",
     "/usr/local/include",