From 8efdcd165a577313f4f84d545213ca839f8ade5c Mon Sep 17 00:00:00 2001
From: Robert Ricci <ricci@cs.utah.edu>
Date: Wed, 26 Nov 2003 20:14:12 +0000
Subject: [PATCH] Give nsgen a Makefile, and get it installed with the rest of
 the world

Also added webnsgen as a frontend for web pages that need to call
nsgen.
---
 configure                  | 40 +++++++++++++++++++++++++-------------
 configure.in               |  1 +
 utils/GNUmakefile.in       | 13 +++++++++++--
 utils/nsgen/GNUmakefile.in | 33 +++++++++++++++++++++++++++++++
 utils/nsgen/webnsgen.in    | 27 +++++++++++++++++++++++++
 5 files changed, 98 insertions(+), 16 deletions(-)
 create mode 100644 utils/nsgen/GNUmakefile.in
 create mode 100644 utils/nsgen/webnsgen.in

diff --git a/configure b/configure
index 4e55801a72..7ba87d13e1 100755
--- a/configure
+++ b/configure
@@ -51,6 +51,7 @@ program_suffix=NONE
 program_transform_name=s,x,x,
 silent=
 site=
+sitefile=
 srcdir=
 target=NONE
 verbose=
@@ -165,6 +166,7 @@ Configuration:
   --help                  print this message
   --no-create             do not create output files
   --quiet, --silent       do not print \`checking...' messages
+  --site-file=FILE        use FILE as the site file
   --version               print the version of autoconf that created configure
 Directory and file names:
   --prefix=PREFIX         install architecture-independent files in PREFIX
@@ -335,6 +337,11 @@ EOF
   -site=* | --site=* | --sit=*)
     site="$ac_optarg" ;;
 
+  -site-file | --site-file | --site-fil | --site-fi | --site-f)
+    ac_prev=sitefile ;;
+  -site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*)
+    sitefile="$ac_optarg" ;;
+
   -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
     ac_prev=srcdir ;;
   -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
@@ -500,12 +507,16 @@ fi
 srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
 
 # Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
-  if test "x$prefix" != xNONE; then
-    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
-  else
-    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+if test -z "$sitefile"; then
+  if test -z "$CONFIG_SITE"; then
+    if test "x$prefix" != xNONE; then
+      CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+    else
+      CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+    fi
   fi
+else
+  CONFIG_SITE="$sitefile"
 fi
 for ac_site_file in $CONFIG_SITE; do
   if test -r "$ac_site_file"; then
@@ -573,7 +584,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:577: checking host system type" >&5
+echo "configure:588: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -594,7 +605,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$host" 1>&6
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:598: checking build system type" >&5
+echo "configure:609: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
@@ -620,7 +631,7 @@ fi
 # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:624: checking for $ac_word" >&5
+echo "configure:635: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -652,7 +663,7 @@ fi
 # Extract the first word of "${ac_tool_prefix}g++", so it can be a program name with args.
 set dummy ${ac_tool_prefix}g++; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:656: checking for $ac_word" >&5
+echo "configure:667: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -684,7 +695,7 @@ fi
 # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:688: checking for $ac_word" >&5
+echo "configure:699: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -716,7 +727,7 @@ fi
 # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:720: checking for $ac_word" >&5
+echo "configure:731: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -748,7 +759,7 @@ fi
 # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
 set dummy ${ac_tool_prefix}strip; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:752: checking for $ac_word" >&5
+echo "configure:763: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -780,7 +791,7 @@ fi
 # Extract the first word of "${ac_tool_prefix}ssh", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ssh; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:784: checking for $ac_word" >&5
+echo "configure:795: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_SSH'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1281,7 +1292,7 @@ fi
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1285: checking for a BSD compatible install" >&5
+echo "configure:1296: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1415,6 +1426,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
 	utils/sshtb utils/create_image utils/node_admin utils/webcreateimage \
 	utils/firstuser utils/export_tables utils/eventping \
 	utils/cvsupd.pl utils/newnode \
+	utils/nsgen/GNUmakefile utils/nsgen/webnsgen \
 	www/GNUmakefile www/defs.php3 www/dbdefs.php3 \
 	vis/GNUmakefile vis/webvistopology \
 	vis/dbvistopology \
diff --git a/configure.in b/configure.in
index a112ffe65d..c6d5e0e67c 100755
--- a/configure.in
+++ b/configure.in
@@ -469,6 +469,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
 	utils/sshtb utils/create_image utils/node_admin utils/webcreateimage \
 	utils/firstuser utils/export_tables utils/eventping \
 	utils/cvsupd.pl utils/newnode \
+	utils/nsgen/GNUmakefile utils/nsgen/webnsgen \
 	www/GNUmakefile www/defs.php3 www/dbdefs.php3 \
 	vis/GNUmakefile vis/webvistopology \
 	vis/dbvistopology \
diff --git a/utils/GNUmakefile.in b/utils/GNUmakefile.in
index eebd4e48a6..db95f592d8 100644
--- a/utils/GNUmakefile.in
+++ b/utils/GNUmakefile.in
@@ -12,6 +12,8 @@ UNIFIED         = @UNIFIED_BOSS_AND_OPS@
 
 include $(OBJDIR)/Makeconf
 
+SUBDIRS		= nsgen
+
 BIN_SCRIPTS	= delay_config sshtb create_image node_admin
 SBIN_SCRIPTS	= vlandiff vlansync withadminprivs export_tables cvsupd.pl \
                   eventping
@@ -26,13 +28,14 @@ USERBINS        = create_image delay_config node_admin
 # Force dependencies on the scripts so that they will be rerun through
 # configure if the .in file is changed.
 # 
-all:	$(BIN_SCRIPTS) $(SBIN_SCRIPTS) $(LIBEXEC_SCRIPTS)
+all:	$(BIN_SCRIPTS) $(SBIN_SCRIPTS) $(LIBEXEC_SCRIPTS) $(SUBDIRS)
 
 include $(TESTBED_SRCDIR)/GNUmakerules
 
 install: $(addprefix $(INSTALL_BINDIR)/, $(BIN_SCRIPTS)) \
 	$(addprefix $(INSTALL_SBINDIR)/, $(SBIN_SCRIPTS)) \
-	$(addprefix $(INSTALL_LIBEXECDIR)/, $(LIBEXEC_SCRIPTS))
+	$(addprefix $(INSTALL_LIBEXECDIR)/, $(LIBEXEC_SCRIPTS)) \
+	subdir-install
 
 #
 # Control node installation (okay, plastic)
@@ -49,4 +52,10 @@ endif
 control-install:
 	$(LINKS)
 
+#
+# Automate this part at some point.
+# 
+subdir-install:
+	@$(MAKE) -C nsgen install	
+
 clean:
diff --git a/utils/nsgen/GNUmakefile.in b/utils/nsgen/GNUmakefile.in
new file mode 100644
index 0000000000..67203014e6
--- /dev/null
+++ b/utils/nsgen/GNUmakefile.in
@@ -0,0 +1,33 @@
+#
+# EMULAB-COPYRIGHT
+# Copyright (c) 2000-2003 University of Utah and the Flux Group.
+# All rights reserved.
+#
+
+SRCDIR		= @srcdir@
+TESTBED_SRCDIR	= @top_srcdir@
+OBJDIR		= ../..
+SUBDIR		= utils/nsgen
+
+include $(OBJDIR)/Makeconf
+
+BIN_STUFF	= nsgen
+LIBEXEC_STUFF	= webnsgen
+
+XML_STUFF	= $(notdir $(wildcard $(SRCDIR)/*.xml))
+
+all:
+
+include $(TESTBED_SRCDIR)/GNUmakerules
+
+install:	install-bin install-data
+
+install-bin:	$(addprefix $(INSTALL_BINDIR)/, $(BIN_STUFF)) \
+		$(addprefix $(INSTALL_LIBEXECDIR)/, $(LIBEXEC_STUFF))
+
+install-data:	$(addprefix $(INSTALL_ETCDIR)/nsgen/, $(XML_STUFF))
+
+$(INSTALL_ETCDIR)/nsgen/%: %
+	@echo "Installing $<"
+	-mkdir -p $(INSTALL_ETCDIR)/nsgen
+	$(INSTALL_DATA) $< $@
diff --git a/utils/nsgen/webnsgen.in b/utils/nsgen/webnsgen.in
new file mode 100644
index 0000000000..909322a208
--- /dev/null
+++ b/utils/nsgen/webnsgen.in
@@ -0,0 +1,27 @@
+#!/usr/bin/perl -w
+
+#
+# EMULAB-COPYRIGHT
+# Copyright (c) 2003 University of Utah and the Flux Group.
+# All rights reserved.
+#
+
+use English;
+
+#
+# This gets invoked from the Web interface. Simply a wrapper for nsgen
+#
+# usage: webnsgen arguments ...
+#
+
+#
+# Configure variables
+#
+my $TB       = "@prefix@";
+
+#
+# Run the real thing, and never return.
+# 
+exec "$TB/bin/nsgen", @ARGV;
+
+die("webnsgen: Could not exec nsgen: $!");
-- 
GitLab