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