Fix typo
[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
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 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                         $(LOCAL_SITES) $(LOCAL_MODULES) \
36                         $(addprefix raddb/,$(LOCAL_FILES)) \
37                         $(addprefix raddb/certs/,$(LOCAL_CERT_FILES)) \
38                         $(shell find raddb/mods-config -type f -print) \
39                         $(shell find raddb/policy.d -type f -print)
40
41 # Re-write local files to installed files, filtering out editor backups
42 INSTALL_RADDB :=        $(patsubst raddb/%,$(R)$(raddbdir)/%,\
43                         $(filter-out %~,$(INSTALL_FILES)))
44
45 all: build.raddb
46
47 build.raddb: $(LOCAL_SITES) $(LOCAL_MODULES)
48
49 clean: clean.raddb
50
51 install: install.raddb
52
53 # Local build rules
54 raddb/sites-enabled raddb/mods-enabled:
55         @echo INSTALL $@
56         @$(INSTALL) -d -m 750 $@
57
58 # Set up the default modules for running in-source builds
59 raddb/mods-enabled/%: raddb/mods-available/% | raddb/mods-enabled
60         @echo "LN-S $@"
61         @cd $(dir $@) && ln -sf ../mods-available/$(notdir $@)
62
63 # Set up the default sites for running in-source builds
64 raddb/sites-enabled/%: raddb/sites-available/% | raddb/sites-enabled
65         @echo "LN-S $@"
66         @cd $(dir $@) && ln -sf ../sites-available/$(notdir $@)
67
68 # Installation rules for directories.  Note permissions are 750!
69 $(INSTALL_RADDB_DIRS):
70         @echo INSTALL $(patsubst $(R)$(raddbdir)%,raddb%,$@)
71         @$(INSTALL) -d -m 750 $@
72
73 #  The installed files have ORDER dependencies.  This means that they
74 #  will be installed if the target doesn't exist.  And they won't be
75 #  installed if the target already exists, even if it is out of date.
76 #
77 #  This dependency lets us install the server on top of an existing
78 #  system, hopefully without breaking anything.
79
80 ifeq "$(wildcard $(R)$(raddbdir)/mods-available/)" ""
81 # Installation rules for mods-enabled.  Note ORDER dependencies
82 $(R)$(raddbdir)/mods-enabled/%: | $(R)$(raddbdir)/mods-available/%
83         @cd $(dir $@) && ln -sf ../mods-available/$(notdir $@)
84
85 # Installation rules for sites-enabled.  Note ORDER dependencies
86 $(R)$(raddbdir)/sites-enabled/%: | $(R)$(raddbdir)/sites-available/%
87         @cd $(dir $@) && ln -sf ../sites-available/$(notdir $@)
88 endif
89
90 # Installation rules for plain modules.
91 $(R)$(raddbdir)/%: | raddb/%
92         @echo INSTALL $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
93         @$(INSTALL) -m 640 $(patsubst $(R)$(raddbdir)/%,raddb/%,$@) $@
94
95 # Create symbolic links for legacy files
96 $(R)$(raddbdir)/huntgroups: $(R)$(modconfdir)/preprocess/huntgroups
97         @[ -e $@ ] || echo LN-S $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
98         @[ -e $@ ] || ln -s $(patsubst $(R)$(raddbdir)/%,./%,$<) $@
99
100 $(R)$(raddbdir)/hints: $(R)$(modconfdir)/preprocess/hints
101         @[ -e $@ ] || echo LN-S $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
102         @[ -e $@ ] || ln -s $(patsubst $(R)$(raddbdir)/%,./%,$<) $@
103
104 $(R)$(raddbdir)/users: $(R)$(modconfdir)/files/authorize
105         @[ -e $@ ] || echo LN-S $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
106         @[ -e $@ ] || ln -s $(patsubst $(R)$(raddbdir)/%,./%,$<) $@
107
108 $(LOCAL_CERT_PRODUCTS):
109         @echo BOOTSTRAP raddb/certs/
110         @$(MAKE) -C $(R)$(raddbdir)/certs/
111
112 # Bootstrap is special
113 $(R)$(raddbdir)/certs/bootstrap: | raddb/certs/bootstrap $(LOCAL_CERT_PRODUCTS)
114         @echo INSTALL $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
115         @$(INSTALL) -m 750 $(patsubst $(R)$(raddbdir)/%,raddb/%,$@) $@
116
117 #  List directories before the file targets.
118 #  It's not clear why GNU Make doesn't deal well with this.
119 install.raddb: | $(INSTALL_RADDB_DIRS) $(INSTALL_RADDB) $(LEGACY_LINKS)
120
121 clean.raddb:
122         @rm -f *~ $(addprefix raddb/sites-enabled/,$(DEFAULT_SITES)) \
123                 $(addprefix raddb/mods-enabled/,$(DEFAULT_MODULES))
124
125 #
126 #  A handy target to find out which triggers are where.
127 #  Should only be run by SNMP developers.
128 #
129 triggers:
130         @grep exec_trigger `find src -name "*.c" -print` | grep '"' | sed -e 's/.*,//' -e 's/ *"//' -e 's/");.*//'