How do I access the custom variable defined at the beginning of the Makefile.am?
Specifically, I want to do something in the following lines. For a Makefile.am script that defines how the library file should be created, I want to be able to access the shared name of the library. For example, if I wanted the library name to be named "name", I could start with the following variable:
LIBNAME = name
Then I might have something like this:
lib_LTLIBRARIES = lib$(LIBNAME).la
But then automake starts to complain when I want to do something like the following:
lib$(LIBNAME)_la_SOURCES = file1.cpp file2.cpp lib$(LIBNAME)_la_LIBADD = ...
Is it possible to similarly use some other syntax so that I don't have to repeat the library name many times?
Greetings,
Ben.
You can do this if you define your variable in configure
and not in the Makefile itself.
For example, in configure.ac
:
LIBNAME=name AC_SUBST(LIBNAME)
Then you can access it in the Makefile.am
following way:
lib_LTLIBRARIES = lib@LIBNAME@.la
Then I might have something like this:
LIBNAME = name lib_LTLIBRARIES = lib $ (LIBNAME) .la lib $ (LIBNAME) _la_SOURCES = file1.cpp file2.cpp lib $ (LIBNAME) _la_LIBADD = ...
IFAIK, this won't work with automake. I don't think it is possible to do this using any other syntax.