Move to using phony targets for subdirectories.
authorAlan T. DeKok <aland@freeradius.org>
Tue, 30 Mar 2010 14:04:23 +0000 (16:04 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 30 Mar 2010 14:15:02 +0000 (16:15 +0200)
This removes the explicit shell loop over subdirs, which means that
the main "make" program now tracks all dependencies.  I've also updated
some dependencies to be correct.  Now "make -j 4" will work.

Makefile
src/Makefile
src/modules/Makefile
src/modules/rlm_eap/Makefile.in
src/modules/rlm_eap/types/Makefile

index 6ed7414..8eae3ec 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -88,11 +88,13 @@ install-chown:
 endif
 endif
 
-common:
-       @for dir in $(SUBDIRS); do \
-               echo "Making $(WHAT_TO_MAKE) in $$dir..."; \
-               $(MAKE) $(MFLAGS) -C $$dir $(WHAT_TO_MAKE) || exit $$?; \
-       done
+.PHONY: common $(SUBDIRS)
+
+common: $(SUBDIRS)
+
+$(SUBDIRS):
+       echo "Making $(WHAT_TO_MAKE) in $@..."
+       $(MAKE) $(MFLAGS) -C $@ $(WHAT_TO_MAKE)
 
 distclean: clean
        rm -f config.cache config.log config.status libtool \
index bfd5272..0281c12 100644 (file)
@@ -19,11 +19,13 @@ clean:
 install:
        @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
 
-common:
-       @for dir in $(SUBDIRS); do \
-               echo "Making $(WHAT_TO_MAKE) in $$dir..."; \
-               $(MAKE) $(MFLAGS) -C $$dir $(WHAT_TO_MAKE) || exit $$?; \
-       done
+.PHONY: common $(SUBDIRS)
+
+common: $(SUBDIRS)
+
+$(SUBDIRS): 
+       echo "Making $(WHAT_TO_MAKE) in $@..."
+       $(MAKE) $(MFLAGS) -C $@ $(WHAT_TO_MAKE)
 
 freeradius-devel:
        ln -s include freeradius-devel
index 771cd14..10353d2 100644 (file)
@@ -41,12 +41,15 @@ reconfig:
                )  || exit $$?; \
        done
 
-common:
+# Requires GNU Make, but even older ones will do.
+SUBDIRS := $(patsubst %/,%,$(dir $(wildcard $(addsuffix /Makefile,$(MODULES)))))
+
+.PHONY: common $(SUBDIRS)
+
+common: $(SUBDIRS)
        @[ -d lib/ ] || mkdir lib
        @[ -d lib/.libs ] || mkdir lib/.libs
-       @for mod in $(MODULES); do \
-               if [ -d $$mod ] && [ -f $$mod/Makefile ]; then \
-                       echo "Making $(WHAT_TO_MAKE) in $$mod..."; \
-                       $(MAKE) $(MFLAGS) -C $$mod $(WHAT_TO_MAKE) || exit $$?; \
-               fi; \
-       done
+
+$(SUBDIRS): 
+       echo "Making $(WHAT_TO_MAKE) in $@..."
+       $(MAKE) $(MFLAGS) -C $@ $(WHAT_TO_MAKE)
index 227c3e4..93c2f2d 100644 (file)
@@ -39,14 +39,17 @@ install-subdirs:
        @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=install common
        $(LIBTOOL) --mode=install $(INSTALL) -m 755 $(INSTALLSTRIP) radeapclient$(EXEEXT) $(R)$(bindir)
 
-common:
-       @for dir in $(RLM_SUBDIRS); do  \
-               echo "Making $(WHAT_TO_MAKE) in $$dir..."; \
-               $(MAKE) $(MFLAGS) -C $$dir $(WHAT_TO_MAKE) || exit $$?; \
-       done
-
-libeap/$(LIBPREFIX)freeradius-eap.la:
-       $(MAKE) $(MFLAGS) -C libeap
+.PHONY: common $(RLM_SUBDIRS)
+
+common: $(RLM_SUBDIRS)
+
+types: libeap
+
+$(RLM_SUBDIRS):
+       echo "Making $(WHAT_TO_MAKE) in $@..."
+       $(MAKE) $(MFLAGS) -C $@ $(WHAT_TO_MAKE)
+
+libeap/$(LIBPREFIX)freeradius-eap.la: libeap
 
 ## this uses the RLM_CFLAGS and RLM_LIBS and SRCS defs to make TARGET.
 include ../rules.mak
index 30a6590..d552001 100644 (file)
@@ -16,10 +16,19 @@ install:
 reconfig:
        $(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
 
-common:
-       @for mod in rlm_eap*; do \
-               if [ -d $$mod ] && [ -f $$mod/Makefile ]; then \
-                       echo "Making $(WHAT_TO_MAKE) in $$mod..."; \
-                       $(MAKE) $(MFLAGS) -C $$mod $(WHAT_TO_MAKE) || exit $$?; \
-               fi; \
-       done
+SUBDIRS := $(patsubst %/,%,$(dir $(wildcard rlm_eap*/Makefile)))
+
+.PHONY: common $(SUBDIRS)
+
+common: $(SUBDIRS)
+
+# The PEAP and TTLS sub-modules require eap_tls.
+#
+# If they're not being built, this rule is ignored because they're
+# phony targets.
+# 
+rlm_eap_peap rlm_eap_ttls: rlm_eap_tls
+
+$(PLUGINS): 
+       echo "Making $(WHAT_TO_MAKE) in $@..."
+       $(MAKE) $(MFLAGS) -C $@ $(WHAT_TO_MAKE)