bug-automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#37499: Wrong location of deps directory when using AC_SUBST


From: Fabrizio Bertocci
Subject: bug#37499: Wrong location of deps directory when using AC_SUBST
Date: Tue, 24 Sep 2019 08:55:50 -0400

Package: automake
Version: 1.15.1

I have noticed a strange/wrong behavior when using AC_SUBST to pass a path to Makefile.am to be used to include additional source files.
In my configure.ac I allow definition of a MYLIB_PATH variable through --with-mylib=...
The path identify a directory where I have additional common sources that I want to include in my final build (I know I should build that as a separate lib, but this is not the point).

This is the configure.ac:
-----------------------------------------
AC_INIT(testApp, 1.0, address@hidden)
AC_CONFIG_SRCDIR([src/main.c])
AM_INIT_AUTOMAKE([subdir-objects])
AC_PROG_CC
AC_CONFIG_MACRO_DIRS([m4])

AC_ARG_WITH(mylib,
[  --with-mylib=PATH     Sets PATH where my lib is checked out (../mylib) ],
[
        MYLIB_PATH="${withval}"
        AC_MSG_RESULT(Using MYLib library from ${withval})
],[
        MYLIB_PATH="../mylib"
])

dnl Verify the common lib dir is found
AC_CHECK_FILE("$MYLIB_PATH/mylib.h",
      [     AC_MSG_RESULT(Successfully found mylib.h under "${MYLIB_PATH}")
      ],[   AC_MSG_ERROR(Cannot find MyLibrary. Use --with-mylib parameter to specify where lib is checked out)
] )

dnl Use relative path:
dnl MYLIB_PATH=`realpath --relative-to src "${MYLIB_PATH}"`

dnl Use absolute path of lib
MYLIB_PATH=`readlink -f ${MYLIB_PATH}`

AC_MSG_RESULT(Using MyLibrary relative to src: ${MYLIB_PATH})
AC_SUBST(MYLIB_PATH)
AC_OUTPUT(Makefile src/Makefile)
-----------------------------------
Then in my src/Makefile.am, I add to my sources, the files from @MYLI_PATH@:
-----------------------------------
bin_PROGRAMS = testApp
testApp_SOURCES = main.c @MYLIB_PATH@/mylib_log.c
testApp_CFLAGS = -I@MYLIB_PATH@/lib
------------------------------------

Problem:
If I define MYLIB_PATH as RELATIVE path to the 'src' directory (inside my project), everything works fine (in the configure.ac, use the realpath utility to convert any MYLIB_PATH to relative to the 'src' dir).
Unfortunately if MYLIB_PATH is an ABSOLUTE PATH (as in the example above), it doesn't work.
After running configure, the .deps directory is created under src like if the MYLIB_PATH is stripped out of the first '/':
So for example if I have my project under:
/home/fabrizio/test/autotool-issue/lib
/home/fabrizio/test/autotool-issue/proj   <- this is where is configure.ac
/home/fabrizio/test/autotool-issue/proj/src   <- This is where are the sources 
After running configure, I get the .deps directory created here:
/home/fabrizio/test/autotool-issue/proj/src/home/fabrizio/test/autotool-issue/lib/.deps/testApp-mylib_log.Po

The workaround is to use always relative path.
I have a full reproducible project I could attach. Just let me know.
I have used this pattern for more than 10 years, but I don't remember ever seeing this issue (although I attempted to use absolute paths only now). Tested with newer systems like Linux Mint 19.2 as well as a bit older systems like CentOS 7. Same problem on both.

Regards,
Fabrizio Bertocci



reply via email to

[Prev in Thread] Current Thread [Next in Thread]