[netfilter-cvslog] r3362 - in trunk/nfsim: . core tools
rusty at netfilter.org
rusty at netfilter.org
Tue Dec 14 02:57:53 CET 2004
Author: rusty at netfilter.org
Date: 2004-12-14 02:57:52 +0100 (Tue, 14 Dec 2004)
New Revision: 3362
Added:
trunk/nfsim/core/config.h.in
Modified:
trunk/nfsim/Makefile.in
trunk/nfsim/configure
trunk/nfsim/core/core.c
trunk/nfsim/tools/version.c
Log:
More configuration: install directory.
Automagically set up LD_LIBRARY_PATH to try to help users.
Modified: trunk/nfsim/Makefile.in
===================================================================
--- trunk/nfsim/Makefile.in 2004-12-14 01:54:22 UTC (rev 3361)
+++ trunk/nfsim/Makefile.in 2004-12-14 01:57:52 UTC (rev 3362)
@@ -2,8 +2,11 @@
CC=%CC%
GCOV=%GCOV%
GCOVFLAGS=%GCOVFLAGS%
+BINDIR=%BINDIR%
+LIBDIR=%LIBDIR%
+BASEDIR=%BASEDIR%
-CFLAGS = -DVERSION=\"%VERSION%\" -Wstrict-prototypes -Wunused -Wall -g -Wa,-W
+CFLAGS = -Wstrict-prototypes -Wunused -Wall -g -Wa,-W
CPPFLAGS = -I. -I$(shell pwd)/core -I$(shell pwd)/kernelenv/include \
-I$(shell pwd)/netfilter/include
@@ -113,8 +116,8 @@
-czvf nfsim/nfsim-$(shell date +%Y%m%d).tar.gz nfsim)
install: simulator
- cp simulator /usr/local/bin/nfsim$(VERSION)
- cp fakesockopt.so.1.0 /usr/local/lib
+ cp simulator %BASEDIR%%BINDIR%nfsim
+ cp fakesockopt.so.1.0 %BASEDIR%%LIBDIR%
# 2.4 Makefiles want this
TOPDIR=$(shell pwd)
Modified: trunk/nfsim/configure
===================================================================
--- trunk/nfsim/configure 2004-12-14 01:54:22 UTC (rev 3361)
+++ trunk/nfsim/configure 2004-12-14 01:57:52 UTC (rev 3362)
@@ -7,6 +7,7 @@
VERSION=0.2
GCOV=${GCOV:-gcov}
CC=${CC:-gcc}
+PREFIX=/usr/local
barf()
{
@@ -18,19 +19,29 @@
case "$arg" in
--kerneldir=*) KERNELDIR=$(echo "$arg" | cut -d= -f2-);;
--gcov) GCOVFLAGS='-fprofile-arcs -ftest-coverage';;
+ --prefix) PREFIX=$(echo "$arg" | cut -d= -f2-);;
+ --bindir) BINDIR=$(echo "$arg" | cut -d= -f2-)/;;
+ --libdir) LIBDIR=$(echo "$arg" | cut -d= -f2-)/;;
+ --basedir) BASEDIR=$(echo "$arg" | cut -d= -f2-)/;;
*)
- barf "Usage: ./configure [--gcov] --kerneldir=<DIR>"
+ barf "Usage: ./configure [--gcov] [--prefix=<dir>] --kerneldir=<DIR>"
;;
esac
done
-SUB='s/%GCOVFLAGS%/'$GCOVFLAGS'/;s/%TYPE%/'$TYPE'/;s/%VERSION%/'$VERSION'/;s/%GCOV%/'$GCOV'/;s/%CC%/'$CC'/'
+[ -n "$BINDIR" ] || BINDIR="$PREFIX"/bin/
+[ -n "$LIBDIR" ] || LIBDIR="$PREFIX"/lib/
+SUB='s@%GCOVFLAGS%@'$GCOVFLAGS'@;s@%TYPE%@'$TYPE'@;s@%VERSION%@'$VERSION'@;s@%GCOV%@'$GCOV'@;s@%CC%@'$CC'@;s@%LIBDIR%@'$LIBDIR'@;s@%BINDIR%@'$BINDIR'@;s@%BASEDIR%@'$BASEDIR'@'
+
[ -d $KERNELDIR/net/$TYPE/netfilter ] ||
barf No netfilter directory found in $KERNELDIR
-echo Setting up Makefile
-sed "$SUB" < Makefile.in > Makefile
+echo -n Configuring files:
+for f in `find . -name '*.in'`; do
+ echo -n " $f"
+ sed "$SUB" < $f > `echo $f | sed 's/.in$//'`
+done
echo Importing netfilter $TYPE code from $KERNELDIR
Added: trunk/nfsim/core/config.h.in
===================================================================
--- trunk/nfsim/core/config.h.in 2004-12-14 01:54:22 UTC (rev 3361)
+++ trunk/nfsim/core/config.h.in 2004-12-14 01:57:52 UTC (rev 3362)
@@ -0,0 +1,7 @@
+#ifndef __NFSIM_CONFIG_H
+#define __NFSIM_CONFIG_H
+
+#define LIBDIR "%LIBDIR%"
+#define VERSION "%VERSION%"
+
+#endif /* __NFSIM_CONFIG_H */
Modified: trunk/nfsim/core/core.c
===================================================================
--- trunk/nfsim/core/core.c 2004-12-14 01:54:22 UTC (rev 3361)
+++ trunk/nfsim/core/core.c 2004-12-14 01:57:52 UTC (rev 3362)
@@ -19,6 +19,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
#include "core.h"
#include "message.h"
#include "tui.h"
@@ -163,6 +164,7 @@
{
int termfd, load_all = 0;
char c;
+ char *p;
while ((c = getopt_long(argc, argv, "xqeaV", options, NULL)) != EOF) {
switch (c) {
@@ -190,6 +192,30 @@
}
}
+ /* Hack to make users' lives easier: set LD_LIBRARY_PATH for
+ * fakesockopt.so, based on where we are. */
+ p = strrchr(argv[0], '/');
+ if (!p || strncmp(argv[0], LIBDIR, strlen(LIBDIR)) == 0) {
+ char *oldpath, *path;
+
+ oldpath = getenv("LD_LIBRARY_PATH");
+ path = talloc_asprintf(NULL, "%s%s%s",
+ oldpath ?:"", oldpath ? ":" : "",
+ LIBDIR);
+ setenv("LD_LIBRARY_PATH", path, 1);
+ talloc_free(path);
+ } else {
+ char *oldpath, *path;
+
+ /* Assume it's still in working directory. */
+ oldpath = getenv("LD_LIBRARY_PATH");
+ path = talloc_asprintf(NULL, "%s%s%.*s",
+ oldpath ?:"", oldpath ? ":" : "",
+ p - argv[0], argv[0]);
+ setenv("LD_LIBRARY_PATH", path, 1);
+ talloc_free(path);
+ }
+
kernelenv_init();
run_inits();
Modified: trunk/nfsim/tools/version.c
===================================================================
--- trunk/nfsim/tools/version.c 2004-12-14 01:54:22 UTC (rev 3361)
+++ trunk/nfsim/tools/version.c 2004-12-14 01:57:52 UTC (rev 3362)
@@ -20,6 +20,7 @@
*/
#include <linux/version.h>
+#include <config.h>
#include <log.h>
#include <tui.h>
#include <kernelenv.h>
More information about the netfilter-cvslog
mailing list