3

I'm new to m4 and am trying to set up a macro which allows the user to specify the location of a library at configure-time ./configure --with-mylib=/path/to/lib.so.

In the m4 macro using AC_ARG_WITH, I'll check that the given file actually exists, and then store the path to said lib. MYLIB_PATH=esyscmd([dirname $withval]). This produces the error:

dirname: missing operand

The shell doesn't seem to know about $withval. How do I get it through to execute this command?

Thanks,

Andrew

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
ajwood
  • 18,227
  • 15
  • 61
  • 104
  • Why not just let the user specify the location of the library by setting LDFLAGS? – William Pursell Jan 14 '11 at 14:54
  • As an environment variable before the build? – ajwood Jan 14 '11 at 15:33
  • As an argument to configure, or in a config.site. "./configure LDFLAGS=-L/path/to/lib" should work. – William Pursell Jan 14 '11 at 15:40
  • Is there any risk of that overriding stuff that needs to be there? – ajwood Jan 14 '11 at 15:47
  • LDFLAGS is intended to be set only by the user. There is a chance that the package maintainer has incorrectly modified LDFLAGS or done something else unusual, but LDFLAGS is a user variable and the user is allowed to set it. If doing so breaks the build, it is a packaging bug. – William Pursell Jan 14 '11 at 15:58

1 Answers1

3

That's because esyscmd is executed by m4 when generating your configure script, i.e. at "compile time". Use

MYLIB_PATH=`dirname $with_mylib`

instead.

Note that $withval "is actually just the value of the shell variable named with_package, with any non-alphanumeric characters in package changed into _", so all occurrences of / will be removed and it will likely not be a valid path.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
  • Heh... that's the intuitive way that I for some reason thought I tried already. Thanks very much! – ajwood Jan 07 '11 at 16:53