Use GNU Make patterns to regenerate configure scripts
[freeradius.git] / raddb / all.mk
1 #
2 #  The list of files to install.
3 #
4 LOCAL_FILES := acct_users clients.conf dictionary templates.conf \
5                 experimental.conf hints huntgroups \
6                 preproxy_users proxy.conf radiusd.conf trigger.conf \
7                 users README.rst
8
9 DEFAULT_SITES := default inner-tunnel
10 LOCAL_SITES   := $(addprefix raddb/sites-enabled/,$(DEFAULT_SITES))
11
12 DEFAULT_MODULES := always attr_filter attr_rewrite cache_eap chap checkval \
13                 counter cui detail detail.log digest dhcp dynamic_clients eap \
14                 echo exec expiration expr files inner-eap linelog logintime \
15                 mschap ntlm_auth pap passwd preprocess radutmp realm \
16                 replicate soh sradutmp unix utf8 wimax
17
18 LOCAL_MODULES   := $(addprefix raddb/mods-enabled/,$(DEFAULT_MODULES))
19
20 LOCAL_CERT_FILES := Makefile bootstrap README xpextensions \
21                     ca.cnf server.cnf client.cnf
22
23 RADDB_DIRS := sites-available sites-enabled mods-available mods-enabled \
24                 filter policy.d certs
25
26 # Installed directories
27 INSTALL_RADDB_DIRS := $(R)$(raddbdir)/ $(addprefix $(R)$(raddbdir)/, \
28                         $(RADDB_DIRS) $(shell find raddb/sql -type d -print))
29
30 # Grab files from the various subdirectories
31 INSTALL_FILES := $(wildcard raddb/sites-available/* raddb/mods-available/*) \
32                  $(LOCAL_SITES) $(LOCAL_MODULES) \
33                  $(addprefix raddb/,$(LOCAL_FILES)) \
34                  $(addprefix raddb/certs/,$(LOCAL_CERT_FILES)) \
35                  $(wildcard raddb/policy.d/* raddb/filter/*) \
36                  $(shell find raddb/sql -type f -print)
37
38
39 # Re-write local files to installed files, filtering out editor backups
40 INSTALL_RADDB := $(patsubst raddb/%,$(R)$(raddbdir)/%,\
41                         $(filter-out %~,$(INSTALL_FILES)))
42
43 all: build.raddb
44
45 build.raddb: $(LOCAL_SITES) $(LOCAL_MODULES)
46
47 clean: clean.raddb
48
49 install: install.raddb
50
51 # Local build rules
52 raddb/sites-enabled raddb/mods-enabled:
53         @echo MKDIR $@
54         @mkdir -p $@
55
56 # Set up the default modules for running in-source builds
57 raddb/mods-enabled/%: raddb/mods-available/% | raddb/mods-enabled
58         @echo LN-S $@
59         @cd $(dir $@) && ln -sf ../mods-available/$(notdir $@)
60
61 # Set up the default sites for running in-source builds
62 raddb/sites-enabled/%: raddb/sites-available/% | raddb/sites-enabled
63         @echo LN-S $@
64         @cd $(dir $@) && ln -sf ../sites-available/$(notdir $@)
65
66 # Installation rules for directories.  Note permissions are 750!
67 $(INSTALL_RADDB_DIRS):
68         @echo INSTALL $(patsubst $(R)$(raddbdir)%,raddb%,$@)
69         @$(INSTALL) -d -m 750 $@
70
71 #  The installed files have ORDER dependencies.  This means that they
72 #  will be installed if the target doesn't exist.  And they won't be
73 #  installed if the target already exists, even if it is out of date.
74 #
75 #  This dependency lets us install the server on top of an existing
76 #  system, hopefully without breaking anything.
77
78 # Installation rules for mods-enabled.  Note ORDER dependencies
79 $(R)$(raddbdir)/mods-enabled/%: | $(R)$(raddbdir)/mods-available/%
80         @cd $(dir $@) && ln -sf ../mods-available/$(notdir $@)
81
82 # Installation rules for sites-enabled.  Note ORDER dependencies
83 $(R)$(raddbdir)/sites-enabled/%: | $(R)$(raddbdir)/sites-available/%
84         @cd $(dir $@) && ln -sf ../mods-available/$(notdir $@)
85
86 # Installation rules for plain modules.
87 $(R)$(raddbdir)/%: | raddb/%
88         @echo INSTALL $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
89         @$(INSTALL) -m 640 $(patsubst $(R)$(raddbdir)/%,raddb/%,$@) $@
90
91 # Bootstrap is special
92 $(R)$(raddbdir)/certs/bootstrap: | raddb/certs/bootstrap
93         @echo INSTALL $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
94         @$(INSTALL) -m 750 $(patsubst $(R)$(raddbdir)/%,raddb/%,$@) $@
95
96 #  List directories before the file targets.
97 #  It's not clear why GNU Make doesn't deal well with this.
98 install.raddb: $(INSTALL_RADDB_DIRS) $(INSTALL_RADDB)
99
100 clean.raddb:
101         @rm -f *~ $(addprefix raddb/sites-enabled/,$(DEFAULT_SITES)) \
102                 $(addprefix raddb/mods-enabled/,$(DEFAULT_MODULES))
103
104 #
105 #  A handy target to find out which triggers are where.
106 #  Should only be run by SNMP developers.
107 #
108 triggers:
109         @grep exec_trigger `find src -name "*.c" -print` | grep '"' | sed -e 's/.*,//' -e 's/ *"//' -e 's/");.*//'