-EXTRA_DIST = strongswan.conf
+# make this relative to the location of strongswan.conf
+strongswanconfdir = `dirname $(strongswan_conf)`
+strongswanddir = $(strongswanconfdir)/strongswan.d
+charonconfdir = $(strongswanddir)/charon
-install-exec-local :
- test -e "$(DESTDIR)${sysconfdir}" || $(INSTALL) -d "$(DESTDIR)$(sysconfdir)"
- test -e "$(DESTDIR)$(sysconfdir)/strongswan.conf" || $(INSTALL) -m 640 $(srcdir)/strongswan.conf $(DESTDIR)$(sysconfdir)/strongswan.conf || true
- test -e "$(DESTDIR)${sysconfdir}/strongswan.d" || $(INSTALL) -d "$(DESTDIR)$(sysconfdir)/strongswan.d"
+options = \
+ options/charon.opt
+
+plugins = \
+ plugins/test.opt
+
+alloptions = $(options) $(plugins)
+
+confsnippets = $(alloptions:opt=conf)
+
+# we only install snippets for enabled plugins
+plugins_install_tmp = $(charon_plugins:%=plugins/%.tmp)
+plugins_install_src = $(charon_plugins:%=plugins/%.conf)
+
+strongswand_DATA = $(options:opt=conf)
+charonconf_DATA = $(plugins_install_src)
+
+BUILT_SOURCES = default.conf $(confsnippets)
+EXTRA_DIST = format-options.py strongswan.conf default.opt \
+ default.conf $(alloptions) $(confsnippets)
+
+.opt.conf:
+ $(AM_V_GEN) \
+ case "$<" in \
+ *plugins/*) \
+ sed \
+ -e "s:\@PLUGIN_NAME\@:`basename $< .opt`:" \
+ $(srcdir)/default.opt | cat - $< | \
+ $(PYTHON) $(srcdir)/format-options.py -f conf -r charon.plugins > $(srcdir)/$@ \
+ ;; \
+ *) \
+ $(PYTHON) $(srcdir)/format-options.py -f conf -r charon.plugins $< > $(srcdir)/$@ \
+ ;; \
+ esac
+
+# we need another implicit rule to generate files from the generic template only
+# if the rules above did not catch it. this requires an intermediate step that
+# generates a copy of the generic config template.
+$(plugins_install_tmp):
+ @cp $(srcdir)/default.conf $(srcdir)/$@
+
+.tmp.conf:
+ $(AM_V_GEN) \
+ sed \
+ -e "s:\@PLUGIN_NAME\@:`basename $< .tmp`:" \
+ $(srcdir)/$< > $(srcdir)/$@
+
+maintainer-clean-local:
+ cd $(srcdir) && \
+ rm -f $(confsnippets) default.conf plugins/*.conf plugins/*.tmp
+
+install-exec-local:
+ test -e "$(DESTDIR)${strongswanconfdir}" || $(INSTALL) -d "$(DESTDIR)$(strongswanconfdir)"
+ test -e "$(DESTDIR)$(strongswanconfdir)/strongswan.conf" || $(INSTALL) -m 640 $(srcdir)/strongswan.conf $(DESTDIR)$(strongswanconfdir)/strongswan.conf || true
+
+install-data-hook:
+ chmod 0640 $(DESTDIR)$(strongswanddir)/*.conf
+ chmod 0640 $(DESTDIR)$(charonconfdir)/*.conf
--- /dev/null
+charon.plugins.test.opt
+ This is a normal option without default
+
+charon.plugins.test.noncomment := set this
+ This will not be commented out
+
+charon.plugins.test.def = default
+ Option with default
+
+charon.plugins.test.sectionnocomment.opt = val
+ The section this is in has no description
+
+charon.plugins.test.sub {}
+ This section has comments
+
+charon.plugins.test.sub.opt = option in sub
+ Section option
+
+charon.plugins.test.<commented> { # }
+ Commented example section
+
+charon.plugins.test.<commented>.val = value
+ This is commented anyway
+
+charon.plugins.test.<commented>.assign := value
+ This is commented too because of the commented section
+
+charon.plugins.test.sub = value
+ Sections can also be options with values
+ Longer description with **bold** and _italic_.