synch with TL 38272
[luatex.git] / source / am / recurse.am
blob158fb658655b88f1e4674822ff155c00a33110b1
1 ## am/recurse.am: Makefile fragment to configure and build subdirs.
2 ##
3 ## Copyright (C) 2013 Peter Breitenlohner <tex-live@tug.org>
4 ## You may freely use, modify and/or distribute this file.
5 ##
6 ## requires $(recurse_this) and $(recurse_top).
7 ##
8 # We must configure all subdirs since 'make dist' needs the Makefile.
9 # For those not required for the current set of configure options
10 # we append '--disable-build' so they can skip tests that would
11 # fail because, e.g., some required libraries were not built.
12 # Code inspired by automake's way to handle recursive targets.
14 cf_silent = $(cf_silent_@AM_V@)
15 cf_silent_ = $(cf_silent_@AM_DEFAULT_V@)
16 cf_silent_0 = --silent
17 cf_silent_1 =
19 CONFIG_AUX = $(recurse_top)subsubdir-conf.cmd
21 all-local: recurse
23 .PHONY: recurse
24 recurse: $(CONFIG_AUX)
25         @fail= failcom='exit 1'; \
26         for f in x $$MAKEFLAGS; do \
27           case $$f in \
28             *=* | --[!k]*);; \
29             *k*) failcom='fail=yes';; \
30           esac; \
31         done; \
32         list='$(CONF_SUBDIRS)'; for one_dir in $$list; do \
33           if test ! -f $$one_dir/Makefile; then \
34             test -d $$one_dir || $(MKDIR_P) $$one_dir; \
35             cmd=`cat $(CONFIG_AUX) | sed "s,auxdir/auxsub,$(recurse_this)$$one_dir,g"`; \
36             case " $(MAKE_SUBDIRS) " in \
37               *" $$one_dir "*) skip=;; \
38               *) skip=' --disable-build';; \
39             esac; \
40             (cd $$one_dir && echo "=== configuring in $$one_dir (`pwd`)" && \
41               if $(AM_V_P); then echo "make: running $(SHELL) $$cmd$$skip"; fi && \
42               CONFIG_SHELL=$(SHELL) && export CONFIG_SHELL && \
43               eval $(SHELL) $$cmd$$skip $(cf_silent) || \
44                 { echo "=== configuring in $$one_dir failed"; exit 1; }) && \
45             if test "x$$skip" = x; then \
46               echo "Making all in $$one_dir" && \
47               (cd $$one_dir && $(MAKE) $(AM_MAKEFLAGS) all); \
48             fi || eval $$failcom; \
49           fi; \
50         done; test -z "$$fail"
52 $(CONFIG_AUX):
53         @echo "configure in $(recurse_top)auxdir/auxsub failed to create the file $@"
54         exit 1