2 # The list of files to install.
4 LOCAL_FILES := clients.conf dictionary templates.conf experimental.conf \
5 proxy.conf radiusd.conf trigger.conf README.rst panic.gdb
7 DEFAULT_SITES := default inner-tunnel
8 LOCAL_SITES := $(addprefix raddb/sites-enabled/,$(DEFAULT_SITES))
10 DEFAULT_MODULES := always attr_filter cache_eap chap date \
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
16 LOCAL_MODULES := $(addprefix raddb/mods-enabled/,$(DEFAULT_MODULES))
18 LOCAL_CERT_FILES := Makefile README xpextensions \
19 ca.cnf server.cnf client.cnf bootstrap
22 # We don't create the installed certs if we're building a package,
23 # OR if OpenSSL is not available.
26 ifneq "$(OPENSSL_LIBS)" ""
27 LOCAL_CERT_PRODUCTS := $(addprefix $(R)$(raddbdir)/certs/,ca.key ca.pem \
28 client.key client.pem server.key server.pem)
32 LEGACY_LINKS := $(addprefix $(R)$(raddbdir)/,users huntgroups hints)
34 RADDB_DIRS := certs mods-available mods-enabled policy.d \
35 sites-available sites-enabled \
36 $(patsubst raddb/%,%,$(shell find raddb/mods-config -type d -print))
38 # Installed directories
39 INSTALL_RADDB_DIRS := $(R)$(raddbdir)/ $(addprefix $(R)$(raddbdir)/, $(RADDB_DIRS))
41 # Grab files from the various subdirectories
42 INSTALL_FILES := $(wildcard raddb/sites-available/* raddb/mods-available/*) \
43 $(addprefix raddb/,$(LOCAL_FILES)) \
44 $(addprefix raddb/certs/,$(LOCAL_CERT_FILES)) \
45 $(shell find raddb/mods-config -type f -print) \
46 $(shell find raddb/policy.d -type f -print)
48 # Re-write local files to installed files, filtering out editor backups
49 INSTALL_RADDB := $(patsubst raddb/%,$(R)$(raddbdir)/%,\
50 $(filter-out %~,$(INSTALL_FILES)))
54 build.raddb: $(LOCAL_SITES) $(LOCAL_MODULES)
58 install: install.raddb
61 raddb/sites-enabled raddb/mods-enabled:
63 @$(INSTALL) -d -m 750 $@
65 # Set up the default modules for running in-source builds
66 raddb/mods-enabled/%: raddb/mods-available/% | raddb/mods-enabled
68 @cd $(dir $@) && ln -sf ../mods-available/$(notdir $@)
70 # Set up the default sites for running in-source builds
71 raddb/sites-enabled/%: raddb/sites-available/% | raddb/sites-enabled
73 @cd $(dir $@) && ln -sf ../sites-available/$(notdir $@)
75 # Installation rules for directories. Note permissions are 750!
76 $(INSTALL_RADDB_DIRS):
77 @echo INSTALL $(patsubst $(R)$(raddbdir)%,raddb%,$@)
78 @$(INSTALL) -d -m 750 $@
80 # The installed files have ORDER dependencies. This means that they
81 # will be installed if the target doesn't exist. And they won't be
82 # installed if the target already exists, even if it is out of date.
84 # This dependency lets us install the server on top of an existing
85 # system, hopefully without breaking anything.
87 ifeq "$(wildcard $(R)$(raddbdir)/mods-available/)" ""
88 INSTALL_RADDB += $(patsubst raddb/%,$(R)$(raddbdir)/%,\
89 $(filter-out %~,$(LOCAL_MODULES)))
91 # Installation rules for mods-enabled. Note ORDER dependencies
92 $(R)$(raddbdir)/mods-enabled/%: | $(R)$(raddbdir)/mods-available/%
93 @cd $(dir $@) && ln -sf ../mods-available/$(notdir $@)
96 ifeq "$(wildcard $(R)$(raddbdir)/sites-available/)" ""
97 INSTALL_RADDB += $(patsubst raddb/%,$(R)$(raddbdir)/%,\
98 $(filter-out %~,$(LOCAL_SITES)))
100 # Installation rules for sites-enabled. Note ORDER dependencies
101 $(R)$(raddbdir)/sites-enabled/%: | $(R)$(raddbdir)/sites-available/%
102 @cd $(dir $@) && ln -sf ../sites-available/$(notdir $@)
105 # Installation rules for plain modules.
106 $(R)$(raddbdir)/%: | raddb/%
107 @echo INSTALL $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
108 @$(INSTALL) -m 640 $(patsubst $(R)$(raddbdir)/%,raddb/%,$@) $@
110 # Create symbolic links for legacy files
111 $(R)$(raddbdir)/huntgroups: $(R)$(modconfdir)/preprocess/huntgroups
112 @[ -e $@ ] || echo LN-S $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
113 @[ -e $@ ] || ln -s $(patsubst $(R)$(raddbdir)/%,./%,$<) $@
115 $(R)$(raddbdir)/hints: $(R)$(modconfdir)/preprocess/hints
116 @[ -e $@ ] || echo LN-S $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
117 @[ -e $@ ] || ln -s $(patsubst $(R)$(raddbdir)/%,./%,$<) $@
119 $(R)$(raddbdir)/users: $(R)$(modconfdir)/files/authorize
120 @[ -e $@ ] || echo LN-S $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
121 @[ -e $@ ] || ln -s $(patsubst $(R)$(raddbdir)/%,./%,$<) $@
123 ifneq "$(LOCAL_CERT_PRODUCTS)" ""
124 $(LOCAL_CERT_PRODUCTS):
125 @echo BOOTSTRAP raddb/certs/
126 @$(MAKE) -C $(R)$(raddbdir)/certs/
128 # Bootstrap is special
129 $(R)$(raddbdir)/certs/bootstrap: | raddb/certs/bootstrap $(LOCAL_CERT_PRODUCTS)
130 @echo INSTALL $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
131 @$(INSTALL) -m 750 $(patsubst $(R)$(raddbdir)/%,raddb/%,$@) $@
133 $(R)$(raddbdir)/certs/bootstrap:
134 @echo INSTALL $(patsubst $(R)$(raddbdir)/%,raddb/%,$@)
135 @$(INSTALL) -m 750 $(patsubst $(R)$(raddbdir)/%,raddb/%,$@) $@
138 # List directories before the file targets.
139 # It's not clear why GNU Make doesn't deal well with this.
140 install.raddb: | $(INSTALL_RADDB_DIRS) $(INSTALL_RADDB) $(LEGACY_LINKS)
143 @rm -f *~ $(addprefix raddb/sites-enabled/,$(DEFAULT_SITES)) \
144 $(addprefix raddb/mods-enabled/,$(DEFAULT_MODULES))
147 # A handy target to find out which triggers are where.
148 # Should only be run by SNMP developers.
151 @grep exec_trigger `find src -name "*.c" -print` | grep '"' | sed -e 's/.*,//' -e 's/ *"//' -e 's/");.*//'