Parent Directory
|
Revision Log
|
Revision Graph
Sources WoCified: see http://www.freaknet.org/alpt/src/utils/woc/readme
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 18 import sys 19 import os 20 21 NTK_VERSION="0.0.9b" 22 23 # 24 # Sources and libs 25 # 26 27 sources_common = Split('xmalloc.c log.c misc.c rand.c buffer.c endianness.c') 28 sources_qspn = Split('qspn-empiric.c') + sources_common 29 sources_netsukuku = Split("""llist.c xargz.c ipv6-gmp.c inet.c request.c 30 map.c gmap.c bmap.c pkts.c radar.c hook.c rehook.c tracer.c 31 qspn.c module.c opt.c event.c rem.c 32 hash.c daemon.c crypto.c snsd_cache.c 33 andna_cache.c andna.c andns_lib.c err_errno.c 34 dnslib.c andns.c andns_net.c andns_snsd.c 35 ll_map.c libnetlink.c if.c krnl_route.c krnl_rule.c 36 iptunnel.c route.c conf.c dns_wrapper.c igs.c mark.c 37 libiptc/libip4tc.c libping.c netsukuku.c""") + sources_common 38 sources_ntkresolv = sources_common + Split("""andns_lib.c ntkresolv.c andns_net.c 39 crypto.c snsd_cache.c inet.c 40 ll_map.c libnetlink.c 41 err_errno.c""") 42 43 libs = ['gmp', 'pthread', 'crypto', 'z', 'm'] 44 45 # 46 # Command line options and help 47 # 48 49 opts = Options('build.conf') 50 opts.AddOptions(('CONF_DIR', """Directory where the Netsukuku configuration files will be installed""", 51 '/etc/netsukuku'), 52 ('DATA_DIR', 'Directory to install data files', 53 '/usr/share/netsukuku'), 54 ('MAN_DIR', 'Where the manuals will be installed', 55 '/usr/man'), 56 ('BIN_DIR' , 'Directory to install the binaries', 57 '/usr/bin'), 58 ('MOD_DIR' , 'Directory to install the modules', 59 '/usr/lib/netsukuku'), 60 ('PID_DIR', 'Specify location of ntkd.pid file', 61 '/var/run'), 62 ('destdir', 'SCons will copy all the files under destdir during installation', 63 '/'), 64 EnumOption('debug', 'build the debug code', 'no', 65 allowed_values=('yes', 'no', '1', '0'), map={}, 66 ignorecase=0), 67 EnumOption('static', 'build statically the binaries', 'no', 68 allowed_values=('yes', 'no', '1', '0'), map={}, 69 ignorecase=0)) 70 opts.Add('CC', 'The C compiler.') 71 opts.Add('CXX', 'The C++ compiler.') 72 73 env = Environment(options = opts, ENV = os.environ, CCFLAGS = ' -Wall', 74 LINKFLAGS = ' -rdynamic') 75 76 if ("yes" in env['debug']) or ("1" in env['debug']): 77 debug = 1 78 env.Append(CPPDEFINES={'DEBUG' : '${debug}'}, CCFLAGS = ' -ggdb', CXXFLAGS = '-g') 79 #CCFLAGS = ' -ggdb -Wall -DDMALLOC_FUNC_CHECK' 80 # libs+=['dmalloc', 'dmallocth'] 81 os.system("echo Cscoping and ctagging...; ./gentags.sh") 82 else: 83 debug = 0 84 if ("yes" in env['static']) or ("1" in env['static']): 85 static = 1 86 env.Append(CCFLAGS = ' -static', CXXFLAGS = '-static') 87 else: 88 static = 0 89 if (env['destdir'] == "/"): 90 env['destdir']="" 91 92 opts.Save('build.conf', env) 93 94 if os.path.exists("conf/netsukuku.conf") and env.GetOption('clean'): 95 Execute(Delete('conf/netsukuku.conf')) 96 if os.path.exists("config.h") and env.GetOption('clean'): 97 Execute(Delete('config.h')) 98 if os.path.exists("config.log") and env.GetOption('clean'): 99 Execute(Delete('config.log')) 100 101 Help(""" 102 *** Usage 103 'scons' to build the ntkd binary, 104 'scons debug=yes' to build the debug version. 105 'scons install' to install it in the system. 106 107 *** General options 108 """ + opts.GenerateHelpText(env)) 109 110 if ARGUMENTS.get('install'): 111 print "you aren't root" 112 113 # 114 # Configure 115 # 116 117 if not os.path.exists("config.log") and not env.GetOption('clean'): 118 print 'Configuring... ' 119 conf = Configure(env) 120 if not conf.CheckLib('gmp'): 121 print 'Did not find libgmp.a or gmp.lib, exiting!' 122 Execute(Delete('config.log')) 123 Exit(1) 124 if not conf.CheckCHeader([ "gmp.h" ]): 125 print 'Did not find the gmp headers, exiting!' 126 Execute(Delete('config.log')) 127 Exit(1) 128 if not conf.CheckCHeader([ "zlib.h" ]): 129 print 'Did not find the zlib headers, exiting!' 130 Execute(Delete('config.log')) 131 Exit(1) 132 if not conf.CheckLib('pthread'): 133 print 'Did not find pthread.a or pthread.lib, exiting!' 134 Execute(Delete('config.log')) 135 Exit(1) 136 if not conf.CheckLib('crypto'): 137 print 'Did not find the openssl libcrypto.a or libcrypto.lib, exiting!' 138 Execute(Delete('config.log')) 139 Exit(1) 140 if not conf.CheckCHeader([ "openssl/bio.h", "openssl/evp.h", 141 "openssl/crypto.h", "openssl/x509.h", 142 "openssl/engine.h", "openssl/err.h", "openssl/rand.h", 143 "openssl/rsa.h", "openssl/pem.h" ]): 144 print 'Did not find the openssl headers, exiting!' 145 Execute(Delete('config.log')) 146 Exit(1) 147 148 env = conf.Finish() 149 150 def conf_build(target, source, env): 151 conf_defines = { 152 "CONF_DIR": env["CONF_DIR"], 153 "DATA_DIR": env["DATA_DIR"], 154 "MOD_DIR": env["MOD_DIR"], 155 "PID_DIR": env["PID_DIR"], 156 "VERSION": NTK_VERSION, 157 "debug": debug # this is an int. 1 for true, 0 for false 158 } 159 160 conf = file(str(target), "w") 161 conf_in = file(str(source), "r") 162 conf.write(conf_in.read() % conf_defines) 163 conf_in.close() 164 conf.close() 165 166 def build_config_files(target = None, source = None, env = None): 167 if not os.path.exists("config.h") and not env.GetOption('clean'): 168 print 'Generating config.h from config_scons.h.in' 169 conf_build('config.h', 'config_scons.h.in', env) 170 conf = file("config.h", "a") 171 if sys.platform == 'linux2' or sys.platform == 'linux-i386': 172 conf.write("#define GNU_LINUX\n") 173 elif sys.platform == 'darwin': 174 conf.write("#define DARWIN\n") 175 elif string.find (sys.platform, 'sunos') != -1: 176 conf.write("#define SUNOS\n") 177 elif sys.platform=='openbsd3': 178 conf.write("#define OPEN_BSD\n") 179 elif string.find (sys.platform, 'irix') != -1: 180 conf.write("#define IRIX\n") 181 conf.close() 182 183 if not os.path.exists("conf/netsukuku.conf") and not env.GetOption('clean'): 184 print 'Generating conf/netsukuku.conf from conf/ntk_scons.conf.in' 185 conf_build('conf/netsukuku.conf', 'conf/ntk_scons.conf.in', env) 186 187 return 0 188 189 build_config_files(env = env) 190 191 # 192 # Build 193 # 194 195 ntkd = env.Program('ntkd', sources_netsukuku, LIBS = libs) 196 qspn = env.Program('qspn-empiric', sources_qspn, LIBS = libs) 197 ntkresolv = env.Program('ntk-resolv', sources_ntkresolv, LIBS = libs) 198 199 Default(ntkd, ntkresolv) 200 201 202 # 203 # Install 204 # 205 206 Export("env", "debug", "static") 207 subdirs = Split("""man/SConscript scripts/SConscript conf/SConscript 208 modules/SConscript""") 209 SConscript(subdirs, 'env') 210 211 # Here are our installation paths: 212 idir_bin = '$destdir' + '$BIN_DIR' 213 idir_data = '$destdir' + '$DATA_DIR' 214 idir_mod = '$destdir' + '$MOD_DIR' 215 idir_conf = '$destdir' + '$CONF_DIR' 216 idir_pid = '$destdir' + '$PID_DIR' 217 218 SConsignFile() 219 env.Install(idir_bin, [ntkd]) 220 env.Install(idir_bin, [ntkresolv]) 221 env.Alias('install', [idir_bin, idir_conf]) 222 223 #Dirty hack ;( Why GetOption("install") doesn't work? 224 #if not os.path.exists(env["DATA_DIR"]) and os.path.exists(env["CONF_DIR"]): 225 # Execute(Mkdir(env["DATA_DIR"]))
| alpt (at) freaknet (dot) org | ViewVC Help |
| Powered by ViewVC 1.1-dev |