[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] mintlib Makefile requires bash as shell
Hi,
On Sunday 18 October 2009, Vincent Rivière wrote:
> This fragment contains multiple syntax errors.
Sorry, it was untested.
> But I understand your method.
> Because the makefiles variables are read-only at runtime, you fork
> another make instance with an overridden variable value.
>
> I fixed the syntax and added a trace, the following works:
>
> RESULT := false
>
> all:
> echo Trace MAKELEVEL=$(MAKELEVEL) RESULT=$(RESULT)
> ifeq ($(RESULT), false)
> $(MAKE) RESULT=true
> endif
It works, but I think it's better to have configuring and actual building
split into separate steps and Makefiles.
Something like this is used in the W Window System[1] top Makefile:
------------------------------
CONFIG = .config
ifeq ($(CONFIG),$(wildcard $(CONFIG)))
include $(CONFIG)
else
help:
@echo "First you have to 'make config'!"
@false
endif
$(CONFIG):
@echo "You need to 'make config' first before doing the real
@false
---------------------------
As "help" is first target in Makefile, when .config file is missing (i.e.
help is interpreted by make as the default target), doing "make" will
just show help until "make config" is run succesfully.
The sub makes just include .config without any checks:
include ../.config
So their builds just stop to error if .config is missing. (Alternatively
they could tell user to run "make config" at top level first, or do it
for the user.)
In the top Makefile, the .config file is then built with something like
this:
--------------
configpaths:
@echo "# installation directories" >> $(CONFIG)
@echo "MANDIR = " $(DESTDIR)$(PREFIX)/share/man >> $(CONFIG)
@echo "INCDIR = " $(DESTDIR)$(PREFIX)/include >> $(CONFIG)
@echo "BINDIR = " $(DESTDIR)$(PREFIX)/bin >> $(CONFIG)
@echo "LIBDIR = " $(DESTDIR)$(PREFIX)/lib >> $(CONFIG)
showwelcome:
@echo "A file '.config' has been created for you in the main
directory. This one will"
@echo "be included by all the other Makefiles to customize to your
setup . You should"
@echo "check that compiling options, shell utilities and
installation paths there are"
@echo "suitable for your setup."
@echo
@echo "Makefiles offers the standard 'install', 'clean'
and 'distclean' targets."
# MiNT's "uname" seems to always print a \n even with -n
ARCH = $(shell echo -n `uname -s`)
config: $(ARCH) configpaths showwelcome
--------------
Even better would be if Makefiles would be aware of all the dependencies for
the project while parts of the project would still be buildable by entering
their source directory and typing "make". All this is doable by suitable
dependencies, includes and default targets, but a huge amount of work
for larger projects.
- Eero