Build: tidying
authorJeremy Harris <jgh146exb@wizmail.org>
Wed, 25 Oct 2017 17:13:19 +0000 (18:13 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Wed, 25 Oct 2017 17:13:19 +0000 (18:13 +0100)
src/OS/Makefile-Base
src/scripts/MakeLinks
src/src/dkim.c
src/src/macro_predef.c [deleted file]
src/src/macro_predef.h [deleted file]
src/src/predef.c [new file with mode: 0644]
src/src/predef.h [new file with mode: 0644]
src/src/readconf.c
src/src/route.c
src/src/transport.c

index 60c97c210bc02995cea8ec9d166932c9c0a1dd27..26f06eca6eaf45901d2af7d0bb48e00f2d90d28a 100644 (file)
@@ -123,109 +123,39 @@ config.h: Makefile buildconfig ../src/config.h.defaults $(EDITME)
 
 # Build the builtin-macros data struct
 
-MACRO_HSRC = macro_predef.h os.h globals.h config.h \
+MACRO_HSRC = predef.h os.h globals.h config.h \
        routers/accept.h routers/dnslookup.h routers/ipliteral.h \
        routers/iplookup.h routers/manualroute.h routers/queryprogram.h \
        routers/redirect.h
 
-OBJ_MACRO = macro_predef.o \
+OBJ_MACRO_PLAIN = macro-predef.o \
        macro-globals.o macro-readconf.o macro-route.o macro-transport.o macro-drtables.o \
+       macro-dkim.o
+OBJ_MACRO_TP = \
        macro-appendfile.o macro-autoreply.o macro-lmtp.o macro-pipe.o macro-queuefile.o \
-       macro-smtp.o macro-accept.o macro-dnslookup.o macro-ipliteral.o macro-iplookup.o \
-       macro-manualroute.o macro-queryprogram.o macro-redirect.o \
+       macro-smtp.o
+OBJ_MACRO_RT = \
+       macro-accept.o macro-dnslookup.o macro-ipliteral.o macro-iplookup.o \
+       macro-manualroute.o macro-queryprogram.o macro-redirect.o
+OBJ_MACRO_AU = \
        macro-auth-spa.o macro-cram_md5.o macro-cyrus_sasl.o macro-dovecot.o macro-gsasl_exim.o \
-       macro-heimdal_gssapi.o macro-plaintext.o macro-spa.o macro-tls.o\
-       macro-dkim.o
+       macro-heimdal_gssapi.o macro-plaintext.o macro-spa.o macro-tls.o
 
+OBJ_MACRO = $(OBJ_MACRO_PLAIN) $(OBJ_MACRO_TP) $(OBJ_MACRO_RT) $(OBJ_MACRO_AU)
 $(OBJ_MACRO):  $(MACRO_HSRC)
 
-macro_predef.o :       macro_predef.c
-       @echo "$(CC) -DMACRO_PREDEF macro_predef.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ macro_predef.c
-macro-globals.o :      globals.c
-       @echo "$(CC) -DMACRO_PREDEF globals.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ globals.c
-macro-readconf.o :     readconf.c
-       @echo "$(CC) -DMACRO_PREDEF readconf.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ readconf.c
-macro-route.o :                route.c
-       @echo "$(CC) -DMACRO_PREDEF route.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ route.c
-macro-transport.o:     transport.c
-       @echo "$(CC) -DMACRO_PREDEF transport.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ transport.c
-macro-drtables.o :     drtables.c
-       @echo "$(CC) -DMACRO_PREDEF drtables.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ drtables.c
-macro-appendfile.o :   transports/appendfile.c
-       @echo "$(CC) -DMACRO_PREDEF transports/appendfile.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ transports/appendfile.c
-macro-autoreply.o :    transports/autoreply.c
-       @echo "$(CC) -DMACRO_PREDEF transports/autoreply.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ transports/autoreply.c
-macro-lmtp.o:          transports/lmtp.c
-       @echo "$(CC) -DMACRO_PREDEF transports/lmtp.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ transports/lmtp.c
-macro-pipe.o :         transports/pipe.c
-       @echo "$(CC) -DMACRO_PREDEF transports/pipe.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ transports/pipe.c
-macro-queuefile.o :    transports/queuefile.c
-       @echo "$(CC) -DMACRO_PREDEF transports/queuefile.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ transports/queuefile.c
-macro-smtp.o :         transports/smtp.c
-       @echo "$(CC) -DMACRO_PREDEF transports/smtp.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ transports/smtp.c
-macro-accept.o :       routers/accept.c
-       @echo "$(CC) -DMACRO_PREDEF routers/accept.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ routers/accept.c
-macro-dnslookup.o :    routers/dnslookup.c
-       @echo "$(CC) -DMACRO_PREDEF routers/dnslookup.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ routers/dnslookup.c
-macro-ipliteral.o :    routers/ipliteral.c
-       @echo "$(CC) -DMACRO_PREDEF routers/ipliteral.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ routers/ipliteral.c
-macro-iplookup.o :     routers/iplookup.c
-       @echo "$(CC) -DMACRO_PREDEF routers/iplookup.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ routers/iplookup.c
-macro-manualroute.o :  routers/manualroute.c
-       @echo "$(CC) -DMACRO_PREDEF routers/manualroute.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ routers/manualroute.c
-macro-queryprogram.o : routers/queryprogram.c
-       @echo "$(CC) -DMACRO_PREDEF routers/queryprogram.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ routers/queryprogram.c
-macro-redirect.o :     routers/redirect.c
-       @echo "$(CC) -DMACRO_PREDEF routers/redirect.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ routers/redirect.c
-macro-auth-spa.o :     auths/auth-spa.c
-       @echo "$(CC) -DMACRO_PREDEF auths/auth-spa.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/auth-spa.c
-macro-cram_md5.o :     auths/cram_md5.c
-       @echo "$(CC) -DMACRO_PREDEF auths/cram_md5.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/cram_md5.c
-macro-cyrus_sasl.o :   auths/cyrus_sasl.c
-       @echo "$(CC) -DMACRO_PREDEF auths/cyrus_sasl.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/cyrus_sasl.c
-macro-dovecot.o:       auths/dovecot.c
-       @echo "$(CC) -DMACRO_PREDEF auths/dovecot.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/dovecot.c
-macro-gsasl_exim.o :   auths/gsasl_exim.c
-       @echo "$(CC) -DMACRO_PREDEF auths/gsasl_exim.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/gsasl_exim.c
-macro-heimdal_gssapi.o:        auths/heimdal_gssapi.c
-       @echo "$(CC) -DMACRO_PREDEF auths/heimdal_gssapi.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/heimdal_gssapi.c
-macro-plaintext.o :    auths/plaintext.c
-       @echo "$(CC) -DMACRO_PREDEF auths/plaintext.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/plaintext.c
-macro-spa.o :          auths/spa.c
-       @echo "$(CC) -DMACRO_PREDEF auths/spa.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/spa.c
-macro-tls.o:           auths/tls.c
-       @echo "$(CC) -DMACRO_PREDEF auths/tls.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/tls.c
-macro-dkim.o:          dkim.c
-       @echo "$(CC) -DMACRO_PREDEF dkim.c"
-       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ dkim.c
+$(OBJ_MACRO_PLAIN):    macro-%.o : %.c
+       @echo "$(CC) -DMACRO_PREDEF $<"
+       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ $<
+$(OBJ_MACRO_TP):       macro-%.o : transports/%.c
+       @echo "$(CC) -DMACRO_PREDEF $<"
+       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ $<
+$(OBJ_MACRO_RT):       macro-%.o : routers/%.c
+       @echo "$(CC) -DMACRO_PREDEF $<"
+       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ $<
+$(OBJ_MACRO_AU):       macro-%.o : auths/%.c
+       @echo "$(CC) -DMACRO_PREDEF $<"
+       $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ $<
 
 macro_predef: $(OBJ_MACRO)
        @echo "$(LNCC) -o $@"
index 22e5a4bd74b087572213995ea35b138bbc7e6f5b..f29d160ede3df3821de0ac154faa1f46f9423399 100755 (executable)
@@ -110,7 +110,7 @@ for f in blob.h dbfunctions.h dbstuff.h exim.h functions.h globals.h \
   tod.c transport.c tree.c verify.c version.c \
   dkim.c dkim.h dkim_transport.c dmarc.c dmarc.h \
   valgrind.h memcheck.h \
-  macro_predef.c macro_predef.h
+  predef.c predef.h
 do
   ln -s ../src/$f $f
 done
index 41540b39d396d71a300394c27baa764ff33d491a..dd176127a506598d1cac7d6652eaeb14738d815e 100644 (file)
@@ -15,7 +15,7 @@
 # include "pdkim/pdkim.h"
 
 # ifdef MACRO_PREDEF
-#  include "macro_predef.h"
+#  include "predef.h"
 
 void
 dkim_params(void)
diff --git a/src/src/macro_predef.c b/src/src/macro_predef.c
deleted file mode 100644 (file)
index ba19348..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
-/*************************************************
-*     Exim - an Internet mail transport agent    *
-*************************************************/
-
-/* Copyright (c) Jeremy Harris 2017 */
-/* See the file NOTICE for conditions of use and distribution. */
-
-/* Create a static data structure with the predefined macros, to be
-included in the main Exim build */
-
-#include "exim.h"
-#include "macro_predef.h"
-
-unsigned mp_index = 0;
-
-/* Global dummy variables */
-
-void fn_smtp_receive_timeout(const uschar * name, const uschar * str) {}
-uschar * syslog_facility_str;
-
-/******************************************************************************/
-
-void
-builtin_macro_create_var(const uschar * name, const uschar * val)
-{
-printf ("static macro_item p%d = { ", mp_index);
-if (mp_index == 0)
-  printf(".next=NULL,");
-else
-  printf(".next=&p%d,", mp_index-1);
-
-printf(" .command_line=FALSE, .namelen=%d, .replen=%d,"
-       " .name=US\"%s\", .replacement=US\"%s\" };\n",
-       Ustrlen(name), Ustrlen(val), CS name, CS val);
-mp_index++;
-}
-
-
-void
-builtin_macro_create(const uschar * name)
-{
-builtin_macro_create_var(name, US"y");
-}
-
-
-void
-spf(uschar * buf, int len, const uschar * fmt, ...)
-{
-va_list ap;
-va_start(ap, fmt);
-
-while (*fmt && len > 1)
-  if (*fmt == '%' && fmt[1] == 'T')
-    {
-    uschar * s = va_arg(ap, uschar *);
-    while (*s && len-- > 1)
-      *buf++ = toupper(*s++);
-    fmt += 2;
-    }
-  else
-    {
-    *buf++ = *fmt++; len--;
-    }
-*buf = '\0';
-va_end(ap);
-}
-
-void
-options_from_list(optionlist * opts, unsigned nopt,
-  const uschar * section, uschar * group)
-{
-int i;
-const uschar * s;
-uschar buf[64];
-
-/* The 'previously-defined-substring' rule for macros in config file
-lines is done thus for these builtin macros: we know that the table
-we source from is in strict alpha order, hence the builtins portion
-of the macros list is in reverse-alpha (we prepend them) - so longer
-macros that have substrings are always discovered first during
-expansion. */
-
-for (i = 0; i < nopt; i++)  if (*(s = US opts[i].name) && *s != '*')
-  {
-  if (group)
-    spf(buf, sizeof(buf), CUS"_OPT_%T_%T_%T", section, group, s);
-  else
-    spf(buf, sizeof(buf), CUS"_OPT_%T_%T", section, s);
-  builtin_macro_create(buf);
-  }
-}
-
-
-/******************************************************************************/
-
-
-/* Create compile-time feature macros */
-static void
-features(void)
-{
-/* Probably we could work out a static initialiser for wherever
-macros are stored, but this will do for now. Some names are awkward
-due to conflicts with other common macros. */
-
-#ifdef SUPPORT_CRYPTEQ
-  builtin_macro_create(US"_HAVE_CRYPTEQ");
-#endif
-#if HAVE_ICONV
-  builtin_macro_create(US"_HAVE_ICONV");
-#endif
-#if HAVE_IPV6
-  builtin_macro_create(US"_HAVE_IPV6");
-#endif
-#ifdef HAVE_SETCLASSRESOURCES
-  builtin_macro_create(US"_HAVE_SETCLASSRESOURCES");
-#endif
-#ifdef SUPPORT_PAM
-  builtin_macro_create(US"_HAVE_PAM");
-#endif
-#ifdef EXIM_PERL
-  builtin_macro_create(US"_HAVE_PERL");
-#endif
-#ifdef EXPAND_DLFUNC
-  builtin_macro_create(US"_HAVE_DLFUNC");
-#endif
-#ifdef USE_TCP_WRAPPERS
-  builtin_macro_create(US"_HAVE_TCPWRAPPERS");
-#endif
-#ifdef SUPPORT_TLS
-  builtin_macro_create(US"_HAVE_TLS");
-# ifdef USE_GNUTLS
-  builtin_macro_create(US"_HAVE_GNUTLS");
-# else
-  builtin_macro_create(US"_HAVE_OPENSSL");
-# endif
-#endif
-#ifdef SUPPORT_TRANSLATE_IP_ADDRESS
-  builtin_macro_create(US"_HAVE_TRANSLATE_IP_ADDRESS");
-#endif
-#ifdef SUPPORT_MOVE_FROZEN_MESSAGES
-  builtin_macro_create(US"_HAVE_MOVE_FROZEN_MESSAGES");
-#endif
-#ifdef WITH_CONTENT_SCAN
-  builtin_macro_create(US"_HAVE_CONTENT_SCANNING");
-#endif
-#ifndef DISABLE_DKIM
-  builtin_macro_create(US"_HAVE_DKIM");
-#endif
-#ifndef DISABLE_DNSSEC
-  builtin_macro_create(US"_HAVE_DNSSEC");
-#endif
-#ifndef DISABLE_EVENT
-  builtin_macro_create(US"_HAVE_EVENT");
-#endif
-#ifdef SUPPORT_I18N
-  builtin_macro_create(US"_HAVE_I18N");
-#endif
-#ifndef DISABLE_OCSP
-  builtin_macro_create(US"_HAVE_OCSP");
-#endif
-#ifndef DISABLE_PRDR
-  builtin_macro_create(US"_HAVE_PRDR");
-#endif
-#ifdef SUPPORT_PROXY
-  builtin_macro_create(US"_HAVE_PROXY");
-#endif
-#ifdef SUPPORT_SOCKS
-  builtin_macro_create(US"_HAVE_SOCKS");
-#endif
-#ifdef TCP_FASTOPEN
-  builtin_macro_create(US"_HAVE_TCP_FASTOPEN");
-#endif
-#ifdef EXPERIMENTAL_LMDB
-  builtin_macro_create(US"_HAVE_LMDB");
-#endif
-#ifdef EXPERIMENTAL_SPF
-  builtin_macro_create(US"_HAVE_SPF");
-#endif
-#ifdef EXPERIMENTAL_SRS
-  builtin_macro_create(US"_HAVE_SRS");
-#endif
-#ifdef EXPERIMENTAL_BRIGHTMAIL
-  builtin_macro_create(US"_HAVE_BRIGHTMAIL");
-#endif
-#ifdef EXPERIMENTAL_DANE
-  builtin_macro_create(US"_HAVE_DANE");
-#endif
-#ifdef EXPERIMENTAL_DCC
-  builtin_macro_create(US"_HAVE_DCC");
-#endif
-#ifdef EXPERIMENTAL_DMARC
-  builtin_macro_create(US"_HAVE_DMARC");
-#endif
-#ifdef EXPERIMENTAL_DSN_INFO
-  builtin_macro_create(US"_HAVE_DSN_INFO");
-#endif
-
-#ifdef LOOKUP_LSEARCH
-  builtin_macro_create(US"_HAVE_LOOKUP_LSEARCH");
-#endif
-#ifdef LOOKUP_CDB
-  builtin_macro_create(US"_HAVE_LOOKUP_CDB");
-#endif
-#ifdef LOOKUP_DBM
-  builtin_macro_create(US"_HAVE_LOOKUP_DBM");
-#endif
-#ifdef LOOKUP_DNSDB
-  builtin_macro_create(US"_HAVE_LOOKUP_DNSDB");
-#endif
-#ifdef LOOKUP_DSEARCH
-  builtin_macro_create(US"_HAVE_LOOKUP_DSEARCH");
-#endif
-#ifdef LOOKUP_IBASE
-  builtin_macro_create(US"_HAVE_LOOKUP_IBASE");
-#endif
-#ifdef LOOKUP_LDAP
-  builtin_macro_create(US"_HAVE_LOOKUP_LDAP");
-#endif
-#ifdef EXPERIMENTAL_LMDB
-  builtin_macro_create(US"_HAVE_LOOKUP_LMDB");
-#endif
-#ifdef LOOKUP_MYSQL
-  builtin_macro_create(US"_HAVE_LOOKUP_MYSQL");
-#endif
-#ifdef LOOKUP_NIS
-  builtin_macro_create(US"_HAVE_LOOKUP_NIS");
-#endif
-#ifdef LOOKUP_NISPLUS
-  builtin_macro_create(US"_HAVE_LOOKUP_NISPLUS");
-#endif
-#ifdef LOOKUP_ORACLE
-  builtin_macro_create(US"_HAVE_LOOKUP_ORACLE");
-#endif
-#ifdef LOOKUP_PASSWD
-  builtin_macro_create(US"_HAVE_LOOKUP_PASSWD");
-#endif
-#ifdef LOOKUP_PGSQL
-  builtin_macro_create(US"_HAVE_LOOKUP_PGSQL");
-#endif
-#ifdef LOOKUP_REDIS
-  builtin_macro_create(US"_HAVE_LOOKUP_REDIS");
-#endif
-#ifdef LOOKUP_SQLITE
-  builtin_macro_create(US"_HAVE_LOOKUP_SQLITE");
-#endif
-#ifdef LOOKUP_TESTDB
-  builtin_macro_create(US"_HAVE_LOOKUP_TESTDB");
-#endif
-#ifdef LOOKUP_WHOSON
-  builtin_macro_create(US"_HAVE_LOOKUP_WHOSON");
-#endif
-
-#ifdef TRANSPORT_APPENDFILE
-# ifdef SUPPORT_MAILDIR
-  builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILDIR");
-# endif
-# ifdef SUPPORT_MAILSTORE
-  builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILSTORE");
-# endif
-# ifdef SUPPORT_MBX
-  builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MBX");
-# endif
-#endif
-}
-
-
-static void
-options(void)
-{
-options_main();
-options_routers();
-options_transports();
-options_auths();
-}
-
-static void
-params(void)
-{
-#ifndef DISABLE_DKIM
-dkim_params();
-#endif
-}
-
-
-int
-main(void)
-{
-printf("#include \"exim.h\"\n");
-features();
-options();
-params();
-
-printf("macro_item * macros = &p%d;\n", mp_index-1);
-printf("macro_item * mlast = &p0;\n");
-exit(0);
-}
diff --git a/src/src/macro_predef.h b/src/src/macro_predef.h
deleted file mode 100644 (file)
index aece28c..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*************************************************
-*     Exim - an Internet mail transport agent    *
-*************************************************/
-
-/* Copyright (c) Jeremy Harris 2017 */
-/* See the file NOTICE for conditions of use and distribution. */
-
-/* Global functions */
-
-extern void spf(uschar *, int, const uschar *, ...);
-extern void builtin_macro_create(const uschar *);
-extern void builtin_macro_create_var(const uschar *, const uschar *);
-extern void options_from_list(optionlist *, unsigned, const uschar *, uschar *);
-
-extern void options_main(void);
-extern void options_routers(void);
-extern void options_transports(void);
-extern void options_auths(void);
-
diff --git a/src/src/predef.c b/src/src/predef.c
new file mode 100644 (file)
index 0000000..8ef1127
--- /dev/null
@@ -0,0 +1,296 @@
+/*************************************************
+*     Exim - an Internet mail transport agent    *
+*************************************************/
+
+/* Copyright (c) Jeremy Harris 2017 */
+/* See the file NOTICE for conditions of use and distribution. */
+
+/* Create a static data structure with the predefined macros, to be
+included in the main Exim build */
+
+#include "exim.h"
+#include "predef.h"
+
+unsigned mp_index = 0;
+
+/* Global dummy variables */
+
+void fn_smtp_receive_timeout(const uschar * name, const uschar * str) {}
+uschar * syslog_facility_str;
+
+/******************************************************************************/
+
+void
+builtin_macro_create_var(const uschar * name, const uschar * val)
+{
+printf ("static macro_item p%d = { ", mp_index);
+if (mp_index == 0)
+  printf(".next=NULL,");
+else
+  printf(".next=&p%d,", mp_index-1);
+
+printf(" .command_line=FALSE, .namelen=%d, .replen=%d,"
+       " .name=US\"%s\", .replacement=US\"%s\" };\n",
+       Ustrlen(name), Ustrlen(val), CS name, CS val);
+mp_index++;
+}
+
+
+void
+builtin_macro_create(const uschar * name)
+{
+builtin_macro_create_var(name, US"y");
+}
+
+
+void
+spf(uschar * buf, int len, const uschar * fmt, ...)
+{
+va_list ap;
+va_start(ap, fmt);
+
+while (*fmt && len > 1)
+  if (*fmt == '%' && fmt[1] == 'T')
+    {
+    uschar * s = va_arg(ap, uschar *);
+    while (*s && len-- > 1)
+      *buf++ = toupper(*s++);
+    fmt += 2;
+    }
+  else
+    {
+    *buf++ = *fmt++; len--;
+    }
+*buf = '\0';
+va_end(ap);
+}
+
+void
+options_from_list(optionlist * opts, unsigned nopt,
+  const uschar * section, uschar * group)
+{
+int i;
+const uschar * s;
+uschar buf[64];
+
+/* The 'previously-defined-substring' rule for macros in config file
+lines is done thus for these builtin macros: we know that the table
+we source from is in strict alpha order, hence the builtins portion
+of the macros list is in reverse-alpha (we prepend them) - so longer
+macros that have substrings are always discovered first during
+expansion. */
+
+for (i = 0; i < nopt; i++)  if (*(s = US opts[i].name) && *s != '*')
+  {
+  if (group)
+    spf(buf, sizeof(buf), CUS"_OPT_%T_%T_%T", section, group, s);
+  else
+    spf(buf, sizeof(buf), CUS"_OPT_%T_%T", section, s);
+  builtin_macro_create(buf);
+  }
+}
+
+
+/******************************************************************************/
+
+
+/* Create compile-time feature macros */
+static void
+features(void)
+{
+/* Probably we could work out a static initialiser for wherever
+macros are stored, but this will do for now. Some names are awkward
+due to conflicts with other common macros. */
+
+#ifdef SUPPORT_CRYPTEQ
+  builtin_macro_create(US"_HAVE_CRYPTEQ");
+#endif
+#if HAVE_ICONV
+  builtin_macro_create(US"_HAVE_ICONV");
+#endif
+#if HAVE_IPV6
+  builtin_macro_create(US"_HAVE_IPV6");
+#endif
+#ifdef HAVE_SETCLASSRESOURCES
+  builtin_macro_create(US"_HAVE_SETCLASSRESOURCES");
+#endif
+#ifdef SUPPORT_PAM
+  builtin_macro_create(US"_HAVE_PAM");
+#endif
+#ifdef EXIM_PERL
+  builtin_macro_create(US"_HAVE_PERL");
+#endif
+#ifdef EXPAND_DLFUNC
+  builtin_macro_create(US"_HAVE_DLFUNC");
+#endif
+#ifdef USE_TCP_WRAPPERS
+  builtin_macro_create(US"_HAVE_TCPWRAPPERS");
+#endif
+#ifdef SUPPORT_TLS
+  builtin_macro_create(US"_HAVE_TLS");
+# ifdef USE_GNUTLS
+  builtin_macro_create(US"_HAVE_GNUTLS");
+# else
+  builtin_macro_create(US"_HAVE_OPENSSL");
+# endif
+#endif
+#ifdef SUPPORT_TRANSLATE_IP_ADDRESS
+  builtin_macro_create(US"_HAVE_TRANSLATE_IP_ADDRESS");
+#endif
+#ifdef SUPPORT_MOVE_FROZEN_MESSAGES
+  builtin_macro_create(US"_HAVE_MOVE_FROZEN_MESSAGES");
+#endif
+#ifdef WITH_CONTENT_SCAN
+  builtin_macro_create(US"_HAVE_CONTENT_SCANNING");
+#endif
+#ifndef DISABLE_DKIM
+  builtin_macro_create(US"_HAVE_DKIM");
+#endif
+#ifndef DISABLE_DNSSEC
+  builtin_macro_create(US"_HAVE_DNSSEC");
+#endif
+#ifndef DISABLE_EVENT
+  builtin_macro_create(US"_HAVE_EVENT");
+#endif
+#ifdef SUPPORT_I18N
+  builtin_macro_create(US"_HAVE_I18N");
+#endif
+#ifndef DISABLE_OCSP
+  builtin_macro_create(US"_HAVE_OCSP");
+#endif
+#ifndef DISABLE_PRDR
+  builtin_macro_create(US"_HAVE_PRDR");
+#endif
+#ifdef SUPPORT_PROXY
+  builtin_macro_create(US"_HAVE_PROXY");
+#endif
+#ifdef SUPPORT_SOCKS
+  builtin_macro_create(US"_HAVE_SOCKS");
+#endif
+#ifdef TCP_FASTOPEN
+  builtin_macro_create(US"_HAVE_TCP_FASTOPEN");
+#endif
+#ifdef EXPERIMENTAL_LMDB
+  builtin_macro_create(US"_HAVE_LMDB");
+#endif
+#ifdef EXPERIMENTAL_SPF
+  builtin_macro_create(US"_HAVE_SPF");
+#endif
+#ifdef EXPERIMENTAL_SRS
+  builtin_macro_create(US"_HAVE_SRS");
+#endif
+#ifdef EXPERIMENTAL_BRIGHTMAIL
+  builtin_macro_create(US"_HAVE_BRIGHTMAIL");
+#endif
+#ifdef EXPERIMENTAL_DANE
+  builtin_macro_create(US"_HAVE_DANE");
+#endif
+#ifdef EXPERIMENTAL_DCC
+  builtin_macro_create(US"_HAVE_DCC");
+#endif
+#ifdef EXPERIMENTAL_DMARC
+  builtin_macro_create(US"_HAVE_DMARC");
+#endif
+#ifdef EXPERIMENTAL_DSN_INFO
+  builtin_macro_create(US"_HAVE_DSN_INFO");
+#endif
+
+#ifdef LOOKUP_LSEARCH
+  builtin_macro_create(US"_HAVE_LOOKUP_LSEARCH");
+#endif
+#ifdef LOOKUP_CDB
+  builtin_macro_create(US"_HAVE_LOOKUP_CDB");
+#endif
+#ifdef LOOKUP_DBM
+  builtin_macro_create(US"_HAVE_LOOKUP_DBM");
+#endif
+#ifdef LOOKUP_DNSDB
+  builtin_macro_create(US"_HAVE_LOOKUP_DNSDB");
+#endif
+#ifdef LOOKUP_DSEARCH
+  builtin_macro_create(US"_HAVE_LOOKUP_DSEARCH");
+#endif
+#ifdef LOOKUP_IBASE
+  builtin_macro_create(US"_HAVE_LOOKUP_IBASE");
+#endif
+#ifdef LOOKUP_LDAP
+  builtin_macro_create(US"_HAVE_LOOKUP_LDAP");
+#endif
+#ifdef EXPERIMENTAL_LMDB
+  builtin_macro_create(US"_HAVE_LOOKUP_LMDB");
+#endif
+#ifdef LOOKUP_MYSQL
+  builtin_macro_create(US"_HAVE_LOOKUP_MYSQL");
+#endif
+#ifdef LOOKUP_NIS
+  builtin_macro_create(US"_HAVE_LOOKUP_NIS");
+#endif
+#ifdef LOOKUP_NISPLUS
+  builtin_macro_create(US"_HAVE_LOOKUP_NISPLUS");
+#endif
+#ifdef LOOKUP_ORACLE
+  builtin_macro_create(US"_HAVE_LOOKUP_ORACLE");
+#endif
+#ifdef LOOKUP_PASSWD
+  builtin_macro_create(US"_HAVE_LOOKUP_PASSWD");
+#endif
+#ifdef LOOKUP_PGSQL
+  builtin_macro_create(US"_HAVE_LOOKUP_PGSQL");
+#endif
+#ifdef LOOKUP_REDIS
+  builtin_macro_create(US"_HAVE_LOOKUP_REDIS");
+#endif
+#ifdef LOOKUP_SQLITE
+  builtin_macro_create(US"_HAVE_LOOKUP_SQLITE");
+#endif
+#ifdef LOOKUP_TESTDB
+  builtin_macro_create(US"_HAVE_LOOKUP_TESTDB");
+#endif
+#ifdef LOOKUP_WHOSON
+  builtin_macro_create(US"_HAVE_LOOKUP_WHOSON");
+#endif
+
+#ifdef TRANSPORT_APPENDFILE
+# ifdef SUPPORT_MAILDIR
+  builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILDIR");
+# endif
+# ifdef SUPPORT_MAILSTORE
+  builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MAILSTORE");
+# endif
+# ifdef SUPPORT_MBX
+  builtin_macro_create(US"_HAVE_TRANSPORT_APPEND_MBX");
+# endif
+#endif
+}
+
+
+static void
+options(void)
+{
+options_main();
+options_routers();
+options_transports();
+options_auths();
+}
+
+static void
+params(void)
+{
+#ifndef DISABLE_DKIM
+dkim_params();
+#endif
+}
+
+
+int
+main(void)
+{
+printf("#include \"exim.h\"\n");
+features();
+options();
+params();
+
+printf("macro_item * macros = &p%d;\n", mp_index-1);
+printf("macro_item * mlast = &p0;\n");
+exit(0);
+}
diff --git a/src/src/predef.h b/src/src/predef.h
new file mode 100644 (file)
index 0000000..aece28c
--- /dev/null
@@ -0,0 +1,19 @@
+/*************************************************
+*     Exim - an Internet mail transport agent    *
+*************************************************/
+
+/* Copyright (c) Jeremy Harris 2017 */
+/* See the file NOTICE for conditions of use and distribution. */
+
+/* Global functions */
+
+extern void spf(uschar *, int, const uschar *, ...);
+extern void builtin_macro_create(const uschar *);
+extern void builtin_macro_create_var(const uschar *, const uschar *);
+extern void options_from_list(optionlist *, unsigned, const uschar *, uschar *);
+
+extern void options_main(void);
+extern void options_routers(void);
+extern void options_transports(void);
+extern void options_auths(void);
+
index 70ce78f1f3a5c6b766445959a96f3c2886627308..ebadb023316f129821937e8e037884a8b4dd04ac 100644 (file)
@@ -12,7 +12,7 @@ implementation of the conditional .ifdef etc. */
 #include "exim.h"
 
 #ifdef MACRO_PREDEF
-# include "macro_predef.h"
+# include "predef.h"
 #endif
 
 static uschar * syslog_facility_str;
index 1b9676f3f87ffd3aea6017f76b67bea0f2e93a87..f33a1106377faef5219b35df30a0f627198490c1 100644 (file)
@@ -145,7 +145,7 @@ int optionlist_routers_size = nelem(optionlist_routers);
 
 #ifdef MACRO_PREDEF
 
-# include "macro_predef.h"
+# include "predef.h"
 
 void
 options_routers(void)
index 89f1d74bda5828843b279f71600f402a33dfd8c9..6caeeecc9775b383d265a0d11751537d58c3d074 100644 (file)
@@ -90,7 +90,7 @@ int optionlist_transports_size = nelem(optionlist_transports);
 
 #ifdef MACRO_PREDEF
 
-# include "macro_predef.h"
+# include "predef.h"
 
 void
 options_transports(void)