Move to using phony targets for subdirectories.
[freeradius.git] / src / modules / Makefile
1 #
2 # Makefile
3 #
4 # Version:      $Id$
5 #
6
7 include ../../Make.inc
8
9 WHAT_TO_MAKE    = all
10 FRS_MODULES     = $(shell echo frs_*/Makefile | sed 's,/Makefile,,g')
11
12 all:
13         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
14
15 install:
16         $(INSTALL) -d -m 755 $(R)$(libdir)
17         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
18
19 clean:
20         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
21         @rm -f *~ lib/rlm_* lib/frs_* lib/*.o lib/*.la lib/*.lo
22         @rm -f lib/smbencrypt lib/radeapclient
23         @rm -rf lib/.libs
24
25 distclean:
26         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
27
28 #
29 #  Do NOT use "common", because some modules may not be built,
30 #  and therefore their makefiles may be empty or non-existent.
31 #
32 reconfig:
33         @[ "x$(AUTOCONF)" != "x" ] || exit 0
34         @[ "x$(AUTOHEADER)" != "x" ] || exit 0
35         @for x in `find . -name "configure.in" -print`; do \
36                 ( \
37                  cd `dirname $$x` || exit $$?; \
38                  if [ -f configure.in ]; then \
39                         $(AUTOCONF) -I $(top_builddir); \
40                  fi; \
41                  if grep AC_CONFIG_HEADERS configure.in >/dev/null; then\
42                         $(AUTOHEADER); \
43                  fi; \
44                 )  || exit $$?; \
45         done
46
47 # Requires GNU Make, but even older ones will do.
48 SUBDIRS := $(patsubst %/,%,$(dir $(wildcard $(addsuffix /Makefile,$(MODULES)))))
49
50 .PHONY: common $(SUBDIRS)
51
52 common: $(SUBDIRS)
53         @[ -d lib/ ] || mkdir lib
54         @[ -d lib/.libs ] || mkdir lib/.libs
55
56 $(SUBDIRS): 
57         echo "Making $(WHAT_TO_MAKE) in $@..."
58         $(MAKE) $(MFLAGS) -C $@ $(WHAT_TO_MAKE)