You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SConscript 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. # This file is part of Netsukuku
  2. # (c) Copyright 2005 Andrea Lo Pumo aka AlpT <alpt@freaknet.org>
  3. #
  4. # This source code is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Public License as published
  6. # by the Free Software Foundation; either version 2 of the License,
  7. # or (at your option) any later version.
  8. #
  9. # This source code is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. # Please refer to the GNU Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Public License along with
  15. # this source code; if not, write to:
  16. # Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. import sys
  18. import os
  19. Import("env")
  20. NTK_VERSION="0.0.9b"
  21. #
  22. # Sources and libs
  23. #
  24. sources_common = ['xmalloc.c', 'log.c', 'misc.c', 'buffer.c', 'endianness.c']
  25. sources_qspn = ['qspn-empiric.c'] + sources_common
  26. sources_netsukuku = ['accept.c', 'llist.c', 'ipv6-gmp.c', 'inet.c', 'request.c',
  27. 'map.c', 'gmap.c', 'bmap.c', 'pkts.c', 'radar.c', 'hook.c',
  28. 'rehook.c', 'tracer.c', 'qspn.c', 'hash.c', 'daemon.c',
  29. 'crypto.c', 'snsd_cache.c', 'andna_cache.c', 'andna.c',
  30. 'andns_lib.c', 'err_errno.c', 'dnslib.c', 'andns.c',
  31. 'andns_net.c', 'andns_snsd.c', 'll_map.c', 'libnetlink.c',
  32. 'if.c', 'krnl_route.c', 'krnl_rule.c', 'iptunnel.c',
  33. 'route.c', 'conf.c', 'dns_wrapper.c', 'igs.c', 'mark.c',
  34. 'libiptc/libip4tc.c', 'libping.c', 'ntk-console-server.c',
  35. 'netsukuku.c'] + sources_common
  36. sources_ntkresolv = ['andns_lib.c', 'andns_net.c', 'crypto.c', 'snsd_cache.c',
  37. 'inet.c', 'll_map.c', 'libnetlink.c', 'err_errno.c',
  38. 'ntkresolv.c'] + sources_common
  39. sources_ntkconsole = ['ntk-console.c']
  40. libs = ['gmp', 'pthread', 'crypto', 'z']
  41. if ("yes" in env['debug']) or ("1" in env['debug']):
  42. debug = 1
  43. env.Append(CPPDEFINES={'DEBUG' : '${debug}'}, CCFLAGS = ' -ggdb -Wall', CXXFLAGS = '-g')
  44. #CCFLAGS = ' -ggdb -Wall -DDMALLOC_FUNC_CHECK'
  45. # libs+=['dmalloc', 'dmallocth']
  46. os.system("echo Cscoping and ctagging...; cscope -b; ctags *")
  47. else:
  48. debug = 0
  49. if ("yes" in env['static']) or ("1" in env['static']):
  50. static = 1
  51. env.Append(CCFLAGS = ' -static', CXXFLAGS = '-static')
  52. else:
  53. static = 0
  54. if (env['destdir'] == "/"):
  55. env['destdir']=""
  56. if os.path.exists("conf/netsukuku.conf") and env.GetOption('clean'):
  57. Execute(Delete('conf/netsukuku.conf'))
  58. if os.path.exists("config.h") and env.GetOption('clean'):
  59. Execute(Delete('config.h'))
  60. if os.path.exists("config.log") and env.GetOption('clean'):
  61. Execute(Delete('config.log'))
  62. if ARGUMENTS.get('install'):
  63. print "you aren't root"
  64. #
  65. # Configure
  66. #
  67. if not os.path.exists("config.log") and not env.GetOption('clean'):
  68. print 'Configuring... '
  69. conf = Configure(env)
  70. if not conf.CheckLib('gmp'):
  71. print 'Did not find libgmp.a or gmp.lib, exiting!'
  72. Execute(Delete('config.log'))
  73. Exit(1)
  74. if not conf.CheckCHeader([ "gmp.h" ]):
  75. print 'Did not find the gmp headers, exiting!'
  76. Execute(Delete('config.log'))
  77. Exit(1)
  78. if not conf.CheckCHeader([ "zlib.h" ]):
  79. print 'Did not find the zlib headers, exiting!'
  80. Execute(Delete('config.log'))
  81. Exit(1)
  82. if not conf.CheckLib('pthread'):
  83. print 'Did not find pthread.a or pthread.lib, exiting!'
  84. Execute(Delete('config.log'))
  85. Exit(1)
  86. if not conf.CheckLib('crypto'):
  87. print 'Did not find the openssl libcrypto.a or libcrypto.lib, exiting!'
  88. Execute(Delete('config.log'))
  89. Exit(1)
  90. if not conf.CheckCHeader([ "openssl/bio.h", "openssl/evp.h",
  91. "openssl/crypto.h", "openssl/x509.h",
  92. "openssl/engine.h", "openssl/err.h", "openssl/rand.h",
  93. "openssl/rsa.h", "openssl/pem.h" ]):
  94. print 'Did not find the openssl headers, exiting!'
  95. Execute(Delete('config.log'))
  96. Exit(1)
  97. if not conf.CheckCHeader(["net/if.h", "netinet/in.h"]):
  98. print 'Did not find the net/if.h and netinet/in.h headers, exiting!'
  99. Execute(Delete('config.log'))
  100. Exit(1)
  101. env = conf.Finish()
  102. def conf_build(target, source, env):
  103. conf_defines = {
  104. "CONF_DIR": env["CONF_DIR"],
  105. "DATA_DIR": env["DATA_DIR"],
  106. "PID_DIR": env["PID_DIR"],
  107. "VERSION": NTK_VERSION,
  108. "debug": debug # this is an int. 1 for true, 0 for false
  109. }
  110. conf = file(str(target), "w")
  111. conf_in = file(str(source), "r")
  112. conf.write(conf_in.read() % conf_defines)
  113. conf_in.close()
  114. conf.close()
  115. def build_config_files(target = None, source = None, env = None):
  116. if not os.path.exists("config.h") and not env.GetOption('clean'):
  117. print 'Generating config.h from config_scons.h.in'
  118. conf_build('config.h', 'config_scons.h.in', env)
  119. conf = file("config.h", "a")
  120. if sys.platform == 'linux2' or sys.platform == 'linux-i386':
  121. conf.write("#define GNU_LINUX\n")
  122. elif sys.platform == 'darwin':
  123. conf.write("#define DARWIN\n")
  124. elif string.find (sys.platform, 'sunos') != -1:
  125. conf.write("#define SUNOS\n")
  126. elif sys.platform=='openbsd3':
  127. conf.write("#define OPEN_BSD\n")
  128. elif string.find (sys.platform, 'irix') != -1:
  129. conf.write("#define IRIX\n")
  130. conf.close()
  131. if not os.path.exists("conf/netsukuku.conf") and not env.GetOption('clean'):
  132. print 'Generating conf/netsukuku.conf from conf/ntk_scons.conf.in'
  133. conf_build('conf/netsukuku.conf', 'conf/ntk_scons.conf.in', env)
  134. return 0
  135. build_config_files(env = env)
  136. #
  137. # Build
  138. #
  139. ntkd = env.Program('ntkd', env.Object(sources_netsukuku), LIBS = libs, CPPPATH = '.')
  140. qspn = env.Program('qspn-empiric', env.Object(sources_qspn), LIBS = libs, CPPPATH = '.')
  141. ntkresolv = env.Program('ntk-resolv', env.Object(sources_ntkresolv), LIBS = libs, CPPPATH = '.')
  142. ntkconsole = env.Program('ntk-console', env.Object(sources_ntkconsole), LIBS = libs, CPPPATH = '.', CFLAGS = '-std=c99')
  143. Default(ntkd, ntkresolv, ntkconsole, qspn)
  144. #
  145. # Install
  146. #
  147. SConscript(['man/SConscript', 'scripts/SConscript', 'conf/SConscript'], 'env')
  148. # Here are our installation paths:
  149. idir_bin = '$destdir' + '$BIN_DIR'
  150. idir_data = '$destdir' + '$DATA_DIR'
  151. idir_conf = '$destdir' + '$CONF_DIR'
  152. idir_pid = '$destdir' + '$PID_DIR'
  153. env.Install(idir_bin, [ntkd])
  154. env.Install(idir_bin, [ntkresolv])
  155. env.Install(idir_bin, [ntkconsole])
  156. env.Alias('install', [idir_bin, idir_conf])
  157. #Dirty hack ;( Why GetOption("install") doesn't work?
  158. #if not os.path.exists(env["DATA_DIR"]) and os.path.exists(env["CONF_DIR"]):
  159. # Execute(Mkdir(env["DATA_DIR"]))