New build path variable
[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
11 all:
12         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
13
14 install:
15         $(INSTALL) -d -m 755 $(R)$(libdir)
16         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
17
18 clean:
19         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
20         @rm -f *~ lib/rlm_* lib/*.o lib/smbencrypt lib/radeapclient
21
22 distclean:
23         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
24
25 # Requires GNU Make, but even older ones will do.
26 SUBDIRS := $(patsubst %/,%,$(dir $(wildcard $(addsuffix /Makefile,$(MODULES)))))
27
28 .PHONY: common libs $(SUBDIRS)
29
30 libs:
31         @[ -d lib/ ] || mkdir lib
32         @[ -d lib/.libs ] || mkdir lib/.libs
33
34 common: libs $(SUBDIRS)
35
36 $(SUBDIRS): 
37         @echo "Making $(WHAT_TO_MAKE) in $@..."
38         $(MAKE) $(MFLAGS) -C $@ $(WHAT_TO_MAKE)
39
40 # The rlm_*/*/* stuff is to catch the configure
41 CONFIG_FILES := $(wildcard rlm_*/configure.in rlm_*/*/*/configure.in)
42
43 .PHONY: reconfig $(CONFIG_FILES)
44
45 #
46 #  Do NOT use "common", because some modules may not be built,
47 #  and therefore their makefiles may be empty or non-existent.
48 #
49 ifeq "$(AUTOCONF)" ""
50 reconfig:
51         @echo autoconf is needed for this target
52 else
53 ifeq "$(AUTOHEADER)" ""
54 reconfig:
55         @echo autoheader is needed for this target
56 else
57 reconfig: $(CONFIG_FILES)
58 endif
59 endif
60
61 # Don't use: $(MAKE) -C $(dir $@) reconfig
62 # The modules may not have a Makefile
63 $(CONFIG_FILES):
64         @echo "Making reconfig in $(dir $@)..."
65         @cd $(dir $@) && $(AUTOCONF) -I $(top_builddir)
66         @if grep AC_CONFIG_HEADERS $@ >/dev/null; then\
67                 cd $(dir $@) && $(AUTOHEADER); \
68          fi