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

Re: [MiNT] mintlib Makefile requires bash as shell



Eero Tamminen wrote:
+INCLUDEPATH = $(shell cat $(top_srcdir)/includepath)
+# The following version is faster, but it works only if SHELL is bash
+# and it does not show the contents of includepath while compiling.
+#INCLUDEPATH = $$(<$(top_srcdir)/includepath)
---------

Use ":=" instead of "=".

Then it's evaluated only when assigned, not on every reference
of the variable.

It was my first idea but unfortunately it does not work :-(
Because := variables are evaluated too soon.
The first time make is run, the file includepath does not exist, so the variable INCLUDEPATH is initialized with an empty value which will never change while make is running. So the compilation fails quickly. But running make a second time probably works.

(And use of "?=" would allow the value to be overridden from environment.)

This would probably be a bad idea, because no INCLUDEPATH variable is usually in the environment. If the user has something to do, the simplest thing is to tell the user to type "make SHELL=/bin/bash" as Thomas suggested.

About the SHELL variable used inside make, I read in the documentation that it is never read from the environment. If it is not set explicitly in the makefile or make command line, /bin/sh is used instead. On Ubuntu, that shell is actually dash, which is very basic (and lightweight) but does not allow the $(<file) syntax used by bash. That syntax is actually a bit better than $(cat file) because the latter case needs to run the "cat" external program.

--
Vincent Rivière