dnl ** Settings
dnl **
-dnl get a list of setting .[ch] files, but list .h files first
-FILES1=`find $srcdir/src -name '*settings.[[ch]]'|grep "$srcdir/src/lib-" | sed 's/^\(.*\)\(.\)$/\2 \1\2/' | grep -E -v 'lib-(master|smtp|settings).*c$' | sort -r | sed s/^..//`
-FILES2=`find $srcdir/src -name '*settings.[[ch]]'|grep -v "$srcdir/src/lib-" | sed 's/^\(.*\)\(.\)$/\2 \1\2/' | grep -v all-settings | sort -r | sed s/^..//`
-SETTING_FILES=`echo $FILES1 $FILES2 | sed -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g'`
+libdovecot_dirs=`echo "$LIBDOVECOT_LA_LIBS" | sed -e "s:\\$(top_builddir):$srcdir:g" -e 's:/[[^/]]*\\.la::g'`
+
+libdovecot_headers=
+libdovecot_c_files=
+non_libdovecot_headers=
+non_libdovecot_c_files=
+all_files=`find $srcdir/src -name '*.[[ch]]' | grep -v '/src/config/all-settings.c' | grep -v '/src/lib-settings/' | grep -v '/test-' | xargs grep '\\(struct setting_parser_info [[a-z]]\\)\\|\\(struct service_settings [[a-z]]\\)\\|\\(<settings checks>\\)' | sed 's/:.*//' | sort | uniq`
+for file in $all_files; do
+ dir=`echo "$file" | sed 's:/[[^/]]*$::'`
+ if echo "$libdovecot_dirs" | grep "$dir" >/dev/null; then
+ dnl lib-dovecot
+ if echo "$file" | grep '\.h$' >/dev/null; then
+ libdovecot_headers="$libdovecot_headers $file"
+ else
+ libdovecot_c_files="$libdovecot_c_files $file"
+ fi
+ else
+ dnl not lib-dovecot
+ if echo "$file" | grep '\.h$' >/dev/null; then
+ non_libdovecot_headers="$non_libdovecot_headers $file"
+ else
+ non_libdovecot_c_files="$non_libdovecot_c_files $file"
+ fi
+ fi
+done
+
+dnl libdovecot is linked to doveconf/config binaries, so don't duplicate the .c
+dnl file contents. However, we still need to scan the .c files for any
+dnl setting_parser_infos that aren't elsewhere.
+
+# list headers first, C files last
+SETTING_FILES=`echo $libdovecot_headers $non_libdovecot_headers $non_libdovecot_c_files | sed -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g'`
+SETTING_LINKED_FILES=`echo $libdovecot_c_files | sed -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g'`
AC_SUBST(SETTING_FILES)
+AC_SUBST(SETTING_LINKED_FILES)
dnl **
dnl ** capabilities
config-parser-private.h \
config-request.h
-all-settings.c: $(SETTING_FILES) $(top_srcdir)/src/config/settings-get.pl
- $(AM_V_GEN)$(top_srcdir)/src/config/settings-get.pl $(SETTING_FILES) > all-settings.c || rm -f all-settings.c
+all-settings.c: $(SETTING_FILES) $(SETTING_LINKED_FILES) $(top_srcdir)/src/config/settings-get.pl
+ $(AM_V_GEN)$(top_srcdir)/src/config/settings-get.pl $(SETTING_FILES) -- $(SETTING_LINKED_FILES) > all-settings.c || rm -f all-settings.c
EXTRA_DIST = \
config-settings.c \
my @service_ifdefs = ();
my %parsers = {};
+my $linked_file = 0;
foreach my $file (@ARGV) {
+ if ($file eq "--") {
+ $linked_file = 1;
+ next;
+ }
my $f;
open($f, $file) || die "Can't open $file: $@";
push @service_ifdefs, $ifdef;
} elsif (/^(static )?const struct setting_parser_info (.*) = \{/) {
$cur_name = $2;
+ if (/^const/ && $cur_name !~ /^\*/) {
+ $parsers{$cur_name} = 1;
+ if ($linked_file) {
+ $externs .= "extern const struct setting_parser_info $cur_name;\n";
+ }
+ }
$state++ if ($cur_name !~ /^\*default_/);
} elsif (/^extern const struct setting_parser_info (.*);/) {
+ $parsers{$1} = 1;
$externs .= "extern const struct setting_parser_info $1;\n";
} elsif (/\/\* <settings checks> \*\//) {
$state = 4;
if ($state == 1 || $state == 3) {
if ($state == 1 && $cur_name ne "") {
- if (/\.name = "(.*)"/) {
- $parsers{$cur_name} = $1;
- }
if (/\.parent = /) {
delete($parsers{$cur_name});
}
print "/* $file */\n";
print $externs;
- print $code;
- print $file_contents;
+ if (!$linked_file) {
+ print $code;
+ print $file_contents;
+ }
close $f;
}
print "};\n";
print "const struct setting_parser_info *all_default_roots[] = {\n";
-print "\t&master_service_setting_parser_info,\n";
-print "\t&master_service_ssl_setting_parser_info,\n";
-print "\t&master_service_ssl_server_setting_parser_info,\n";
-print "\t&smtp_submit_setting_parser_info,\n";
foreach my $name (sort(keys %parsers)) {
my $module = $parsers{$name};
next if (!$module);