Make pkidir, rundir, logdir modifiable from "configure" command line.
authorBen Pfaff <blp@nicira.com>
Wed, 22 Oct 2008 21:53:25 +0000 (14:53 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 23 Oct 2008 21:07:25 +0000 (14:07 -0700)
Make "make" behave properly when these are changed by re-running
"configure", by putting their definitions into a generated file that
depends on Makefile.

16 files changed:
Makefile.am
controller/controller.8.in
include/automake.mk
include/dirs.h [new file with mode: 0644]
lib/automake.mk
lib/daemon.c
m4/libopenflow.m4
secchan/secchan.8.in
switch/switch.8.in
utilities/automake.mk
utilities/ofp-discover.8.in
utilities/ofp-discover.c
utilities/ofp-kill.8.in
utilities/ofp-pki-cgi.in
utilities/ofp-pki.8.in
utilities/ofp-pki.in

index 398dcb0..bb69db7 100644 (file)
@@ -20,12 +20,6 @@ endif
 
 AM_CFLAGS = -Wstrict-prototypes
 
 
 AM_CFLAGS = -Wstrict-prototypes
 
-rundir = $(localstatedir)/run
-AM_CPPFLAGS += -DRUNDIR=\"$(rundir)\"
-
-logdir = $(localstatedir)/log/$(PACKAGE)
-AM_CPPFLAGS += -DLOGDIR=\"$(logdir)\"
-
 if NDEBUG
 AM_CPPFLAGS += -DNDEBUG
 AM_CFLAGS += -fomit-frame-pointer
 if NDEBUG
 AM_CPPFLAGS += -DNDEBUG
 AM_CFLAGS += -fomit-frame-pointer
@@ -46,11 +40,12 @@ noinst_LIBRARIES =
 noinst_PROGRAMS =
 noinst_SCRIPTS =
 
 noinst_PROGRAMS =
 noinst_SCRIPTS =
 
-do_subst = sed -e 's,[@]pkidir[@],$(pkidir),g' \
-               -e 's,[@]rundir[@],$(rundir),g' \
+do_subst = sed -e 's,[@]PKIDIR[@],$(PKIDIR),g' \
+               -e 's,[@]RUNDIR[@],$(RUNDIR),g' \
                -e 's,[@]PERL[@],$(PERL),g'
 ro_script = sed "`printf '1a\\' && printf '\\n\# -*- buffer-read-only: t -*-'`"
 ro_man = printf '.\\" Local\040variables:\n.\\" buffer-read-only: t\n.\\" End:\n'
                -e 's,[@]PERL[@],$(PERL),g'
 ro_script = sed "`printf '1a\\' && printf '\\n\# -*- buffer-read-only: t -*-'`"
 ro_man = printf '.\\" Local\040variables:\n.\\" buffer-read-only: t\n.\\" End:\n'
+ro_c = echo '/* -*- mode: c; buffer-read-only: t -*- */'
 
 EXTRA_DIST += README.hwtables
 
 
 EXTRA_DIST += README.hwtables
 
index 044125b..f7f265c 100644 (file)
@@ -129,7 +129,7 @@ performance, so it should not be used in production.
 Causes a file (by default, \fBcontroller.pid\fR) to be created indicating
 the PID of the running process.  If \fIpidfile\fR is not specified, or
 if it does not begin with \fB/\fR, then it is created in
 Causes a file (by default, \fBcontroller.pid\fR) to be created indicating
 the PID of the running process.  If \fIpidfile\fR is not specified, or
 if it does not begin with \fB/\fR, then it is created in
-\fB@rundir@\fR.
+\fB@RUNDIR@\fR.
 
 .TP
 \fB-f\fR, \fB--force\fR
 
 .TP
 \fB-f\fR, \fB--force\fR
index a86dcc0..83f3b59 100644 (file)
@@ -5,6 +5,7 @@ noinst_HEADERS += \
        include/daemon.h \
        include/dhcp-client.h \
        include/dhcp.h \
        include/daemon.h \
        include/dhcp-client.h \
        include/dhcp.h \
+       include/dirs.h \
        include/dynamic-string.h \
        include/dpif.h \
        include/fatal-signal.h \
        include/dynamic-string.h \
        include/dpif.h \
        include/fatal-signal.h \
diff --git a/include/dirs.h b/include/dirs.h
new file mode 100644 (file)
index 0000000..36048ce
--- /dev/null
@@ -0,0 +1,40 @@
+/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford
+ * Junior University
+ * 
+ * We are making the OpenFlow specification and associated documentation
+ * (Software) available for public use and benefit with the expectation
+ * that others will use, modify and enhance the Software and contribute
+ * those enhancements back to the community. However, since we would
+ * like to make the Software available for broadest use, with as few
+ * restrictions as possible permission is hereby granted, free of
+ * charge, to any person obtaining a copy of this Software to deal in
+ * the Software under the copyrights without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * The name and trademarks of copyright holder(s) may NOT be used in
+ * advertising or publicity pertaining to the Software or any
+ * derivatives without specific, written prior permission.
+ */
+
+#ifndef DIRS_H
+#define DIRS_H 1
+
+extern const char ofp_rundir[];  /* /usr/local/var/run */
+extern const char ofp_logdir[];  /* /usr/local/var/log */
+
+#endif /* dirs.h */
index ee8eb34..be0f5f6 100644 (file)
@@ -31,6 +31,7 @@ lib_libopenflow_a_SOURCES = \
        lib/vconn-stream.c \
        lib/vconn.c \
        lib/vlog-socket.c \
        lib/vconn-stream.c \
        lib/vconn.c \
        lib/vlog-socket.c \
+       lib/dirs.c \
        lib/vlog.c
 
 if HAVE_NETLINK
        lib/vlog.c
 
 if HAVE_NETLINK
@@ -58,3 +59,9 @@ EXTRA_DIST += \
        lib/dh2048.pem \
        lib/dh4096.pem \
        lib/dhparams.h
        lib/dh2048.pem \
        lib/dh4096.pem \
        lib/dhparams.h
+
+lib/dirs.c: Makefile
+       ($(ro_c) && \
+        echo 'const char ofp_rundir[] = "@RUNDIR@";' && \
+        echo 'const char ofp_logdir[] = "@LOGDIR@";') > lib/dirs.c.tmp
+       mv lib/dirs.c.tmp lib/dirs.c
index f9bf5ce..8800d0d 100644 (file)
@@ -39,6 +39,7 @@
 #include <string.h>
 #include <unistd.h>
 #include "fatal-signal.h"
 #include <string.h>
 #include <unistd.h>
 #include "fatal-signal.h"
+#include "dirs.h"
 #include "util.h"
 
 #define THIS_MODULE VLM_daemon
 #include "util.h"
 
 #define THIS_MODULE VLM_daemon
@@ -58,9 +59,9 @@ static bool force;
 char *
 make_pidfile_name(const char *name) 
 {
 char *
 make_pidfile_name(const char *name) 
 {
-    return (!name ? xasprintf("%s/%s.pid", RUNDIR, program_name)
+    return (!name ? xasprintf("%s/%s.pid", ofp_rundir, program_name)
             : *name == '/' ? xstrdup(name)
             : *name == '/' ? xstrdup(name)
-            : xasprintf("%s/%s", RUNDIR, name));
+            : xasprintf("%s/%s", ofp_rundir, name));
 }
 
 /* Sets up a following call to daemonize() to create a pidfile named 'name'.
 }
 
 /* Sets up a following call to daemonize() to create a pidfile named 'name'.
@@ -243,5 +244,5 @@ daemon_usage(void)
         "  -D, --detach            run in background as daemon\n"
         "  -P, --pidfile[=FILE]    create pidfile (default: %s/%s.pid)\n"
         "  -f, --force             with -P, start even if already running\n",
         "  -D, --detach            run in background as daemon\n"
         "  -P, --pidfile[=FILE]    create pidfile (default: %s/%s.pid)\n"
         "  -f, --force             with -P, start even if already running\n",
-        RUNDIR, program_name);
+        ofp_rundir, program_name);
 }
 }
index 4fa5b54..c1787f4 100644 (file)
@@ -1,3 +1,5 @@
+# -*- autoconf -*-
+
 # Copyright (c) 2008 The Board of Trustees of The Leland Stanford
 # Junior University
 #
 # Copyright (c) 2008 The Board of Trustees of The Leland Stanford
 # Junior University
 #
@@ -118,6 +120,35 @@ AC_DEFUN([OFP_CHECK_SOCKET_LIBS],
   [AC_CHECK_LIB([socket], [connect])
    AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv])])
 
   [AC_CHECK_LIB([socket], [connect])
    AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv])])
 
+dnl Checks for the directory in which to store the PKI.
+AC_DEFUN([OFP_CHECK_PKIDIR],
+  [AC_ARG_WITH(
+     [pkidir], 
+     AC_HELP_STRING([--with-pkidir=DIR], 
+                    [PKI hierarchy directory [[DATADIR/openflow/pki]]]),
+     [PKIDIR=$withval],
+     [PKIDIR='${pkgdatadir}/pki'])
+   AC_SUBST([PKIDIR])])
+
+dnl Checks for the directory in which to store pidfiles.
+AC_DEFUN([OFP_CHECK_RUNDIR],
+  [AC_ARG_WITH(
+     [rundir], 
+     AC_HELP_STRING([--with-rundir=DIR], 
+                    [directory used for pidfiles [[LOCALSTATEDIR/run]]]),
+     [RUNDIR=$withval],
+     [RUNDIR='${localstatedir}/run'])
+   AC_SUBST([RUNDIR])])
+
+dnl Checks for the directory in which to store logs.
+AC_DEFUN([OFP_CHECK_LOGDIR],
+  [AC_ARG_WITH(
+     [logdir], 
+     AC_HELP_STRING([--with-logdir=DIR], 
+                    [directory used for logs [[LOCALSTATEDIR/log/PACKAGE]]]),
+     [LOGDIR=$withval],
+     [LOGDIR='${localstatedir}/log/${PACKAGE}'])
+   AC_SUBST([LOGDIR])])
 
 dnl Runs the checks required to include the headers in include/ and
 dnl link against lib/libopenflow.a.
 
 dnl Runs the checks required to include the headers in include/ and
 dnl link against lib/libopenflow.a.
@@ -129,5 +160,8 @@ AC_DEFUN([OFP_CHECK_LIBOPENFLOW],
    AC_REQUIRE([OFP_CHECK_SNAT])
    AC_REQUIRE([OFP_CHECK_FAULT_LIBS])
    AC_REQUIRE([OFP_CHECK_SOCKET_LIBS])
    AC_REQUIRE([OFP_CHECK_SNAT])
    AC_REQUIRE([OFP_CHECK_FAULT_LIBS])
    AC_REQUIRE([OFP_CHECK_SOCKET_LIBS])
+   AC_REQUIRE([OFP_CHECK_PKIDIR])
+   AC_REQUIRE([OFP_CHECK_RUNDIR])
+   AC_REQUIRE([OFP_CHECK_LOGDIR])
    AC_CHECK_FUNCS([strlcpy])])
 
    AC_CHECK_FUNCS([strlcpy])])
 
index 5e88791..d7dd9b8 100644 (file)
@@ -401,7 +401,7 @@ require the controller to send the CA certificate, but
 Causes a file (by default, \fBsecchan.pid\fR) to be created indicating
 the PID of the running process.  If \fIpidfile\fR is not specified, or
 if it does not begin with \fB/\fR, then it is created in
 Causes a file (by default, \fBsecchan.pid\fR) to be created indicating
 the PID of the running process.  If \fIpidfile\fR is not specified, or
 if it does not begin with \fB/\fR, then it is created in
-\fB@rundir@\fR.
+\fB@RUNDIR@\fR.
 
 .TP
 \fB-f\fR, \fB--force\fR
 
 .TP
 \fB-f\fR, \fB--force\fR
index 6d1a33b..4b3584e 100644 (file)
@@ -89,7 +89,7 @@ the switch is connected to a trustworthy controller.
 Causes a file (by default, \fBswitch.pid\fR) to be created indicating
 the PID of the running process.  If \fIpidfile\fR is not specified, or
 if it does not begin with \fB/\fR, then it is created in
 Causes a file (by default, \fBswitch.pid\fR) to be created indicating
 the PID of the running process.  If \fIpidfile\fR is not specified, or
 if it does not begin with \fB/\fR, then it is created in
-\fB@rundir@\fR.
+\fB@RUNDIR@\fR.
 
 .TP
 \fB-f\fR, \fB--force\fR
 
 .TP
 \fB-f\fR, \fB--force\fR
index 08bf61b..e359d5f 100644 (file)
@@ -39,8 +39,6 @@ utilities_ofp_discover_LDADD = lib/libopenflow.a
 utilities_ofp_kill_SOURCES = utilities/ofp-kill.c
 utilities_ofp_kill_LDADD = lib/libopenflow.a
 
 utilities_ofp_kill_SOURCES = utilities/ofp-kill.c
 utilities_ofp_kill_LDADD = lib/libopenflow.a
 
-pkidir = $(pkgdatadir)/pki
-
 utilities/ofp-pki: utilities/ofp-pki.in Makefile
        $(do_subst) < $(srcdir)/utilities/ofp-pki.in \
                | $(ro_script) > utilities/ofp-pki
 utilities/ofp-pki: utilities/ofp-pki.in Makefile
        $(do_subst) < $(srcdir)/utilities/ofp-pki.in \
                | $(ro_script) > utilities/ofp-pki
index 772bccb..e2ba8b2 100644 (file)
@@ -77,7 +77,7 @@ This option is mutually exclusive with \fB--exit-without-bind\fR and
 Causes a file (by default, \fBofp\-discover.pid\fR) to be created indicating
 the PID of the running process.  If \fIpidfile\fR is not specified, or
 if it does not begin with \fB/\fR, then it is created in
 Causes a file (by default, \fBofp\-discover.pid\fR) to be created indicating
 the PID of the running process.  If \fIpidfile\fR is not specified, or
 if it does not begin with \fB/\fR, then it is created in
-\fB@rundir@\fR.
+\fB@RUNDIR@\fR.
 
 The \fIpidfile\fR is created when \fBofp\-discover\fR detaches, so
 this this option has no effect when one of \fB--exit-without-bind\fR,
 
 The \fIpidfile\fR is created when \fBofp\-discover\fR detaches, so
 this this option has no effect when one of \fB--exit-without-bind\fR,
index 4efaac7..d48f61a 100644 (file)
@@ -42,6 +42,7 @@
 #include "daemon.h"
 #include "dhcp-client.h"
 #include "dhcp.h"
 #include "daemon.h"
 #include "dhcp-client.h"
 #include "dhcp.h"
+#include "dirs.h"
 #include "dynamic-string.h"
 #include "fatal-signal.h"
 #include "netdev.h"
 #include "dynamic-string.h"
 #include "fatal-signal.h"
 #include "netdev.h"
@@ -413,6 +414,6 @@ usage(void)
            "  -v, --verbose           set maximum verbosity level\n"
            "  -h, --help              display this help message\n"
            "  -V, --version           display version information\n",
            "  -v, --verbose           set maximum verbosity level\n"
            "  -h, --help              display this help message\n"
            "  -V, --version           display version information\n",
-           program_name, program_name, RUNDIR, program_name);
+           program_name, program_name, ofp_rundir, program_name);
     exit(EXIT_SUCCESS);
 }
     exit(EXIT_SUCCESS);
 }
index 122ff54..7b45bf0 100644 (file)
@@ -16,7 +16,7 @@ the PID of the process to kill as a text string.  It then uses
 owns a lock on \fIpidfile\fR before it sends the signal.
 
 A \fIpidfile\fR whose name begins with \fB/\fR is used literally.
 owns a lock on \fIpidfile\fR before it sends the signal.
 
 A \fIpidfile\fR whose name begins with \fB/\fR is used literally.
-Otherwise, \fB@rundir@/\fR is prefixed.
+Otherwise, \fB@RUNDIR@/\fR is prefixed.
 
 This program exists for use by \fBofp\-switch\-setup\fR, which cannot
 easily implement its functionality since Perl has no portable
 
 This program exists for use by \fBofp\-switch\-setup\fR, which cannot
 easily implement its functionality since Perl has no portable
index 291352e..837b3f9 100755 (executable)
@@ -9,7 +9,7 @@ $CGI::POST_MAX = 65536;    # Limit POSTs to 64 kB.
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
-my $pkidir = '@pkidir@';
+my $pkidir = '@PKIDIR@';
 my $q = new CGI;
 
 die unless $q->request_method() eq 'POST';
 my $q = new CGI;
 
 die unless $q->request_method() eq 'POST';
index 3680347..7242df5 100644 (file)
@@ -67,7 +67,7 @@ administration:
 
 .TP
 \fBinit\fR
 
 .TP
 \fBinit\fR
-Initializes a new PKI (by default in directory \fB@pkidir@\fR) and populates
+Initializes a new PKI (by default in directory \fB@PKIDIR@\fR) and populates
 it with a pair of certificate authorities for controllers and
 switches.
 
 it with a pair of certificate authorities for controllers and
 switches.
 
@@ -115,7 +115,7 @@ bits in the generated RSA key.
 When DSA keys are used (as specified with \fB\-\^\-key=dsa\fR), \fBreq\fR
 needs access to the \fBdsaparam.pem\fR file created as part of the PKI
 hierarchy (but not to other files in that tree).  By default,
 When DSA keys are used (as specified with \fB\-\^\-key=dsa\fR), \fBreq\fR
 needs access to the \fBdsaparam.pem\fR file created as part of the PKI
 hierarchy (but not to other files in that tree).  By default,
-\fBofp\-pki\fR looks for this file in \fB@pkidir@/dsaparam.pem\fR, but
+\fBofp\-pki\fR looks for this file in \fB@PKIDIR@/dsaparam.pem\fR, but
 the \fB\-D\fR or \fB\-\^\-dsaparam\fR option (see below) may be used to
 specify an alternate location.
 
 the \fB\-D\fR or \fB\-\^\-dsaparam\fR option (see below) may be used to
 specify an alternate location.
 
@@ -288,7 +288,7 @@ Suppresses the interactive verification of fingerprints that the
 .TP
 \fB\-d\fR \fIdir\fR | \fB\-\^\-dir=\fR\fIdir\fR
 Specifies the location of the PKI hierarchy to be used or created by
 .TP
 \fB\-d\fR \fIdir\fR | \fB\-\^\-dir=\fR\fIdir\fR
 Specifies the location of the PKI hierarchy to be used or created by
-the command (default: \fB@pkidir@\fR).  All commands, except \fBreq\fR,
+the command (default: \fB@PKIDIR@\fR).  All commands, except \fBreq\fR,
 need access to a PKI hierarchy.
 
 .TP
 need access to a PKI hierarchy.
 
 .TP
index 6f227d6..4a5466a 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh -e
 
 #! /bin/sh -e
 
-pkidir='@pkidir@'
+pkidir='@PKIDIR@'
 command=
 prev=
 force=no
 command=
 prev=
 force=no