Please note:The SCons wiki is in read-only mode due to ongoing spam/DoS issues. Also, new account creation is currently disabled. We are looking into alternative wiki hosts.

SConstruct file for Fetchmail

Ommited distributing Autotools-related stuff; other obvious missing feature is distributing whole directories -- this is still missing and may be not supported at all in favour of listing specific files. There are also some shortcuts in Autoconf counterparts since replicating Autoconf tests is out of my project's scope.

   1 # -*- Python -*-
   2 
   3 ################################################################################
   4 #### Options
   5 ####
   6 
   7 opts = Options()
   8 opts.Add(BoolOption('FORCE_TRIO', 'Set to 1 to force Trio', 0))
   9 
  10 ################################################################################
  11 #### Configuration
  12 ####
  13 
  14 env = Environment(tools=['default', 'project', 'substitute'],
  15                   options=opts, YACCFLAGS='-y -d')
  16 env.Replace(AWK=env.Detect(['mawk', 'gawk', 'nawk', 'awk']))
  17 env.Append(CPPPATH=['#', '#/libesmtp/'])
  18 
  19 conf = env.Configure(header='config.h')
  20 
  21 ## AC_HEADER_STDC
  22 conf.header['STDC_HEADERS'] = 1
  23 
  24 ## AC_HEADER_TIME
  25 conf.header['HAVE_SYS_TIME_H'] = 1
  26 conf.header['TIME_WITH_SYS_TIME'] = 1
  27 conf.header['PID_DIR'] = "/var/run"
  28 
  29 ## AC_CHECK_HEADERS
  30 for header in ['string.h', ## AC_HEADER_STDC
  31                'unistd.h', 'termios.h', 'termio.h', 'sgtty.h',
  32                'sys/itimer.h', 'fcntl.h', 'sys/fcntl.h', 'memory.h', 'sys/wait.h',
  33                'arpa/inet.h', 'arpa/nameser.h', 'netinet/in.h', 'net/socket.h',
  34                'sys/select.h', 'sys/socket.h', 'sys/time.h', 'langinfo.h',
  35                'resolv.h']:
  36     conf.CheckHeader(header)
  37 
  38 ### AC_TYPE_SIGNAL -> #define RETSIGTYPE
  39 if conf.TryCompile("""
  40 #include <sys/types.h>
  41 #include <signal.h>
  42 
  43 int
  44 main ()
  45 {
  46 return *(signal (0, 0)) (0) == 1;
  47   ;
  48   return 0;
  49 }
  50 """, ".c"):
  51     conf.header.Definition('RETSIGTYPE', 'int', verbatim=True)
  52 else:
  53     conf.header.Definition('RETSIGTYPE', 'void', verbatim=True)
  54 
  55 ### AC_CHECK_LIBS
  56 if not conf.CheckFunc('getaddrinfo'):
  57     conf.CheckLib(['inet6'], 'getaddrinfo')
  58 
  59 if not conf.CheckFunc('res_search'):
  60     # symbol search b0rken
  61     # conf.CheckLib('resolv', 'res_search', header='#include <resolv.h>')
  62     if conf.CheckLib('resolv'):
  63         conf.header['HAVE_RES_SEARCH'] = 1
  64 
  65 ### AC_CHECK_FUNCS
  66 for func in ['tcsetattr', 'stty', 'setsid', 'geteuid', 'seteuid',
  67              'strerror', 'syslog', 'snprintf', 'vprintf', 'vsnprintf', 'vsyslog',
  68              'atexit', 'inet_aton', 'strftime', 'setrlimit', 'socketpair',
  69              'sigprocmask', 'sigaction', 'strdup', 'setlocale', 'getnameinfo']:
  70     conf.CheckFunc(func)
  71 
  72 ## AC_CHECK_FUN + AC_LIBSOURCE + AC_ADD_sth
  73 conf.CheckFunc('MD5Init', add_libobj='md5c.c')
  74 
  75 ### AC_REPLACE_FUNCS (Like `AC_CHECK_FUNCS', but uses
  76 ### `AC_LIBOBJ(FUNCTION)' as ACTION-IF-NOT-FOUND.)
  77 for func in ['strstr', 'strcasecmp', 'memmove', 'stpcpy',
  78              'strlcpy', 'strlcat', 'strsignal']:
  79     conf.CheckFunc(func, add_libobj=True)
  80 
  81 NEED_TRIO = env['FORCE_TRIO']
  82 if not ( conf.header['HAVE_VPRINTF'] and conf.header['HAVE_VSNPRINTF'] ):
  83     NEED_TRIO = True
  84 
  85 env = conf.Finish()
  86 
  87 ################################################################################
  88 #### Project
  89 ####
  90 
  91 proj = env.Project('fetchmail', '6.4.0', 'fetchmail-devel@lists.berlios.de',
  92                    header='config.h', DIST_TYPE='src_tarbz2')
  93 
  94 ## DISTDOCS
  95 proj.Distribute(Split("""
  96     BUGS OLDNEWS design-notes.html esrs-design-notes.html todo.html
  97     fetchmail-features.html README.SSL README.NTLM README.packaging
  98     fetchmail-FAQ.book fetchmail-FAQ.html fetchmail-SA-2005-01.txt
  99     fetchmail-SA-2005-02.txt fetchmail-SA-2005-03.txt"""))
 100 
 101 proj.Distribute(
 102     env.Command('FAQ', ['fetchmail-FAQ.html', 'dist-tools/html2txt'],
 103                 'AWK=$AWK $SHELL ${SOURCES[1]} ${SOURCES[0]} >$TARGET || { rm -f $TARGET ; exit 1 ; }'))
 104 proj.Distribute(
 105     env.Command('FEATURES', ['fetchmail-features.html', 'dist-tools/html2txt'],
 106                 'AWK=$AWK $SHELL ${SOURCES[1]} ${SOURCES[0]} >$TARGET || { rm -f $TARGET ; exit 1 ; }'))
 107 proj.Distribute(
 108     env.Command('NOTES', ['design-notes.html', 'esrs-design-notes.html', 'dist-tools/html2txt'],
 109                 """echo "This file contains two articles reformatted from HTML." > $TARGET \
 110                 && echo "------------------------------------------------------" >> $TARGET \
 111                 && echo "" >> $TARGET \
 112                 && AWK=$AWK $SHELL ${SOURCES[2]} ${SOURCES[0]} >>$TARGET \
 113                 && AWK=$AWK $SHELL ${SOURCES[2]} ${SOURCES[1]} >>$TARGET \
 114                 || { rm -f $TARGET ; exit 1 ; }"""))
 115 proj.Distribute(
 116     env.Command('fetchmail-man.html', ['fetchmail.man', 'dist-tools/manServer.pl'],
 117                 """env - PATH=$PATH ${SOURCES[1]} ${SOURCES[0]} >$TARGET \
 118                 || { rm -f $TARGET ; exit 1 ; }"""))
 119 proj.Distribute(
 120     env.Command("fetchmail-FAQ.pdf", ['fetchmail-FAQ.html', 'fetchmail-FAQ.book', 'bighand.png'],
 121                 """$AWK '/^[ \t]*<h1/ {sec++; } {if (sec < 2 || sec > 3) print $$0;}' <${SOURCES[0]} >fetchmail-FAQ-print.html
 122                 htmldoc --logoimage ${SOURCES[2]} --batch ${SOURCES[1]}
 123                 rm -f fetchmail-FAQ-print.html"""))
 124 
 125 ## TRIO
 126 trio = env.Library('trio', ['trio/triostr.c', 'trio/trio.c', 'trio/trionan.c'])
 127 trio_regression = env.Program('regression', 'trio/regression.c', LIBS=[trio, 'm'])
 128 proj.Attach(trio, trio_regression)
 129 
 130 if NEED_TRIO:
 131     env.Append(LIBS=[trio, 'm'])
 132     proj.Test(trio_regression)
 133 
 134 ## EXTRA_DIST
 135 proj.Distribute(Split("""
 136 fetchmail.spec ucs/README.svn trio/CHANGES trio/README strlcpy.3
 137 bighand.png m4-local/ac-archive-license.txt
 138 m4-local/ac_ma_search_package.m4 m4-local/autobuild.m4 t.smoke t.rc
 139 dist-tools/manServer.pl dist-tools/html2txt"""))
 140 
 141 env.Command('fetchmail.spec', 'specgen.sh',
 142             "$SHELL $SOURCE ${PROJECT['VERSION']} > $TARGET")
 143 
 144 proj.Distribute(
 145     env.Command('TODO', ['todo.html', 'dist-tools/html2txt'],
 146                 'AWK=$AWK $SHELL ${SOURCES[1]} ${SOURCE} >$TARGET || { rm -f $TARGET ; exit 1 ; }'))
 147 
 148 env.Append(LIBS=env.Library('libfm.a',
 149                             ['xmalloc.c', 'base64.c', 'rfc822.c', 'report.c', 'rfc2047e.c',
 150                              'servport.c', 'smbdes.c', 'smbencrypt.c', 'smbmd4.c', 'smbutil.c',
 151                              'libesmtp/gethostbyname.c']))
 152 
 153 proj.AutoInstall(env.Program('fetchmail', Split("""
 154     socket.c getpass.c pop3.c imap.c etrn.c odmr.c fetchmail.c env.c
 155     idle.c options.c daemon.c driver.c transact.c sink.c smtp.c uid.c
 156     mxget.c md5ify.c cram.c kerberos.c gssapi.c opie.c rpa.c
 157     interface.c netrc.c unmime.c conf.c checkalias.c lock.c
 158     rcfile_l.l rcfile_y.y
 159     ucs/norm_charmap.c libesmtp/getaddrinfo.c KAME/getnameinfo.c""")))
 160 Depends('rcfile_l.o', 'rcfile_y.c')
 161 
 162 # Checking for Python is useless
 163 import sys
 164 proj.AutoInstall(
 165     env.Command(
 166         'fetchmailconf', (),
 167         """( echo '#! /bin/sh' && echo 'exec $PYTHON $PYTHONDIR/fetchmailconf.py "$$@"' ) >$TARGET || { rm -f $TARGET ; exit 1; }""",
 168         PYTHON=sys.executable,
 169         PYTHONDIR=proj['DIR'].python),
 170     instal='bin', executable=True)
 171 proj.AutoInstall('fetchmailconf.py', install='python')
 172 proj.AutoInstall('fetchmail.man', install='man1')
 173 
 174 lsm_name = '%s-%s.lsm' % (proj['NAME'], proj['VERSION'])
 175 proj.Attach(
 176     env.Alias('lsm', env.Command(lsm_name, proj.Substitute('genlsm.sh.in'),
 177                                  "$SHELL $SOURCE >$TARGET")))
 178 env.Depends(lsm_name, env.Alias('dist-fetchmail'))
 179 
 180 proj.Test('t.smoke',
 181           ['t.rc',
 182            env.Program('rfc822.c', CFLAGS='-DMAIN', OBJPREFIX='rfc822_'),
 183            env.Program('unmime.c',  CFLAGS='-DSTANDALONE', OBJPREFIX='unmime_'),
 184            env.Program(['netrc.c', 'xmalloc.c', 'report.c'], CFLAGS='-DSTANDALONE', OBJPREFIX='netrc_'),
 185            env.Program('rfc2047e.c',  CFLAGS='-DTEST', OBJPREFIX='rfc2047e_'),
 186            env.Program('mxget.c', CFLAGS='-DSTANDALONE', OBJPREFIX='mxget_')
 187            ],
 188 
 189           environment = {
 190               'srcdir' : env.File('t.rc').dir,
 191               'LC_ALL' : 'C',
 192               'TZ' : 'UTC'
 193               })

GSoC2007/MaciejPasternacki/ModelPrograms/FetchmailSConstruct (last edited 2008-03-12 02:47:10 by localhost)