From 31c522842364459c2a240ac87de2d9f9ba07aab3 Mon Sep 17 00:00:00 2001 Message-Id: <31c522842364459c2a240ac87de2d9f9ba07aab3.1365267423.git.dbn.lists@gmail.com> From: Dan Nicholson Date: Thu, 4 Apr 2013 07:39:56 -0700 Subject: [PATCH] Expand paths in configure to avoid MSYS garbage in Makefile The default pkg-config path and system include/library paths are currently defined in the Makefile so that make will expand the variables. Due to MSYS shell mangling paths with forward slashes into Windows style paths, the path separators all need to be escaped before passing to the compiler via -D. This causes warnings in both automake and the compiler about "\/". Expand the variables in configure and set them in config.h to avoid this issue. --- Makefile.am | 13 ------------- check/check-path | 3 +-- configure.ac | 28 ++++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/Makefile.am b/Makefile.am index 41e48e8..b808aa4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,19 +9,6 @@ endif SUBDIRS = $(GLIB_SUBDIR) . check DIST_SUBDIRS = $(SUBDIRS) -# Escape paths properly on windows -if NATIVE_WIN32 -AM_CPPFLAGS = \ - -DPKG_CONFIG_PC_PATH="\"$(subst /,\/,$(pc_path))\"" \ - -DPKG_CONFIG_SYSTEM_INCLUDE_PATH="\"$(subst /,\/,$(system_include_path))\"" \ - -DPKG_CONFIG_SYSTEM_LIBRARY_PATH="\"$(subst /,\/,$(system_library_path))\"" -else -AM_CPPFLAGS = \ - -DPKG_CONFIG_PC_PATH="\"$(pc_path)\"" \ - -DPKG_CONFIG_SYSTEM_INCLUDE_PATH="\"$(system_include_path)\"" \ - -DPKG_CONFIG_SYSTEM_LIBRARY_PATH="\"$(system_library_path)\"" -endif - AM_CFLAGS = \ $(WARN_CFLAGS) \ $(GCOV_CFLAGS) \ diff --git a/check/check-path b/check/check-path index 2a6be75..d50f421 100755 --- a/check/check-path +++ b/check/check-path @@ -7,8 +7,7 @@ set -e RESULT="" PKG_CONFIG_PATH="$srcdir/sub" run_test --exists sub1 -# default pkg-config path, making sure to resolve the variables fully -eval pc_path="$pc_path" +# check default pkg-config path if [ "$native_win32" = yes ]; then # This is pretty hacky. On native win32 (MSYS/MINGW), pkg-config # builds the default path from the installation directory. It diff --git a/configure.ac b/configure.ac index 94666a4..481573b 100644 --- a/configure.ac +++ b/configure.ac @@ -37,6 +37,25 @@ dnl from the make command line if necessary. AC_SUBST([TESTS_PKG_CONFIG], ['${top_builddir}/pkg-config${EXEEXT}']) dnl +dnl Macro to expand variables +dnl +AC_DEFUN([PKG_EXPAND_VAR], +[m4_pushdef([var], [m4_default([$2], [$1])]) +var=[$]$1 +_prefix_save=$prefix +_exec_prefix_save=$exec_prefix +test "x$prefix" = xNONE && prefix=$ac_default_prefix +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' +_prev= +while test "x$var" != "x$_prev"; do + _prev=$var + eval var=\"$var\" +done +prefix=$_prefix_save +exec_prefix=$_exec_prefix_save +m4_popdef([var])]) + +dnl dnl Default pkg-config search path dnl AC_MSG_CHECKING([for default search path for .pc files]) @@ -53,8 +72,11 @@ else pc_path='${libdir}/pkgconfig:${datadir}/pkgconfig' fi ]) +PKG_EXPAND_VAR([pc_path]) AC_MSG_RESULT([$pc_path]) AC_SUBST([pc_path]) +AC_DEFINE_UNQUOTED([PKG_CONFIG_PC_PATH], ["$pc_path"], + [Default pkg-config path]) dnl dnl System default -I paths @@ -65,8 +87,11 @@ AC_ARG_WITH([system_include_path], [avoid -I flags from the given path])], [system_include_path="$withval"], [system_include_path="/usr/include"]) +PKG_EXPAND_VAR([system_include_path]) AC_MSG_RESULT([$system_include_path]) AC_SUBST([system_include_path]) +AC_DEFINE_UNQUOTED([PKG_CONFIG_SYSTEM_INCLUDE_PATH], ["$system_include_path"], + [Default system include path]) dnl dnl System default -L paths @@ -87,8 +112,11 @@ case "$pc_lib_sfx" in ;; esac ]) +PKG_EXPAND_VAR([system_library_path]) AC_MSG_RESULT([$system_library_path]) AC_SUBST([system_library_path]) +AC_DEFINE_UNQUOTED([PKG_CONFIG_SYSTEM_LIBRARY_PATH], ["$system_library_path"], + [Default system library path]) dnl Code taken from gtk+-2.0's configure.in. dnl -- 1.8.1.4