Also, this allows writing config vars to a file so an external program
(maybe a packager or installer), can use them automatically.

Thanks,
Ben

--
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com

diff --git a/SConstruct b/SConstruct
index 97210e3..0f3be79 100644
--- a/SConstruct
+++ b/SConstruct
@@ -44,6 +44,7 @@ Help("""
         Default is "obj/<arch>-<os>-<rel>".
     prefix=<some path> to specify a different install directory.
         Default is "/usr/local/xorp".
+    enable_gprof=true if you want things compiled with '-pg' flag.
     enable_xrldb_validation=true if you want XRLdb runtime validation enabled..
         This is not normally required unless you are developing and making 
changes
         to the XRL template files.  XRLdb validation increases startup time.
@@ -78,14 +79,26 @@ vars.AddVariables(
     BoolVariable('debug_msg',  'Build with debug messages', False),
     BoolVariable('debug_fn',  'Build with function names in debug_msg output', 
False),
     BoolVariable('debug_cb',  'Build with callback debugging', False),
+    BoolVariable('enable_gprof',  'Enable gprof (compile with -pg)', False),
     BoolVariable('enable_xrldb_validation',  'Enable Runtime XRLdb 
Validation', False),
     BoolVariable('enable_olsr',  'Build OLSR', False),
     BoolVariable('enable_tests', 'Build Test Programs', False),
+    BoolVariable('save_args', 'Save scons arguments to .scons_build_args 
file', False),
     )
 
 build_arch = os.uname()[4].lower()
 build_os = os.uname()[0].lower()
 
+if ARGUMENTS.get("save_args"):
+    del ARGUMENTS["save_args"]
+    f = open(".scons_build_args", 'w')
+    arg_keys = ARGUMENTS.keys()
+    for a in arg_keys:
+        f.write(a)
+        f.write("=")
+        f.write(ARGUMENTS.get(a))
+        f.write(" ")
+
 host_arch = ARGUMENTS.get('arch')
 if not host_arch:
        host_arch = build_arch
@@ -154,6 +167,9 @@ print 'Debug messages:   ', env['debug_msg']
 print 'Debug function names: ', env['debug_fn']
 print 'Debug callbacks:  ', env['debug_cb']
 
+env['WITH_GPROF'] = ARGUMENTS.get('enable_gprof', False)
+print 'Enable gprof:     ', env['enable_gprof']
+
 env['VALIDATE_XRLDB'] = ARGUMENTS.get('enable_xrldb_validation', False)
 print 'Enable XRLdb Validation:      ', env['enable_xrldb_validation']
 
@@ -409,6 +425,21 @@ if env['VALIDATE_XRLDB']:
         '-DVALIDATE_XRLDB',
     ])
 
+if env['WITH_GPROF']:
+    env.AppendUnique(CFLAGS = [
+        '-pg',
+        '-fno-omit-frame-pointer',
+        '-fno-optimize-sibling-calls',
+    ])
+    env.AppendUnique(CXXFLAGS = [
+        '-pg',
+        '-fno-omit-frame-pointer',
+        '-fno-optimize-sibling-calls',
+    ])
+    env.AppendUnique(LINKFLAGS = [
+        '-pg',
+    ])
+    
 env.AppendUnique(RPATH = [
     '$libdir',
     ])
diff --git a/lf_pkg.bash b/lf_pkg.bash
index 3d425fe..9bee351 100755
--- a/lf_pkg.bash
+++ b/lf_pkg.bash
@@ -3,7 +3,15 @@
 
 rm -fr /usr/local/xorp
 
-scons enable_olsr=true strip=no install
+SCONS_ARGS="enable_olsr=true strip=no"
+if [ -f .scons_build_args ]
+then
+   SCONS_ARGS=`cat .scons_build_args`
+   SCONS_ARGS=$SCONS_ARGS strip=no
+fi
+#scons enable_olsr=true strip=no install
+echo "Scons args: $SCONS_ARGS"
+scons $SCONS_ARGS install
 cp xorp_install.bash /usr/local/xorp/
 chmod a+x /usr/local/xorp/xorp_install.bash
 
_______________________________________________
Xorp-hackers mailing list
[email protected]
http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers

Reply via email to