Makefile conditionally with automake / autoconf

can someone tell me if there is a way to insert a conditional block into Makefile.am so that it is passed on to the Makfile created using autotools?

Here is an example:

ifeq "$(SOMEVAR)" "" SOMEVAR="default_value" endif 

This seems to be the usual way for a Makefile to do conditional things. Automake disables endif and crashes eventually with this message:

Makefile: 390: * missing `endif '. Stop.

any thoughts?

+4
source share
1 answer

Since it is also marked as Autoconf, I suggest setting the condition in configure.ac, if possible. Similar to this:

 AM_CONDITIONAL([CONDITION_NAME], [test x"${SOMEVAR}" != x]) 

Then your Makefile.am will contain

 if CONDITION_NAME <conditional code> else <else :)> endif 

Update

The problem is related to

 python setup.py --root=$(DESTDIR) --prefix=$(DESTDIR)$(prefix) 

called from somewhere. If DESTDIR empty, the prefix can expand to a relative path that you do not want. You have confirmed that it is being called from your Makefile.am. Then you can do two things.

  • Change the above command to python setup.py --root=${DESTDIR}/// --prefix=${DESTDIR}///$(prefix) . A triple slash may be required because AFAIK, POSIX allows you to use double slashes of special meaning, but not for three or more consecutive slashes.

  • Change the above command to DESTDIR=${DESTDIR:-///} && python setup.py --root=${DESTDIR} --prefix=${DESTDIR}$(prefix)

It can be noted that, in my opinion, and a limited understanding of the whole picture, none of this should be necessary. Since the original configure caller was able to pinpoint exactly which prefix he really wanted to use. If none are specified, Autoconf already by default sets the absolute path ( /usr/local ). So, I think, I do not quite understand why you ran into your problem.

+3
source

All Articles