Make pkidir, rundir, logdir modifiable from "configure" command line.

Make "make" behave properly when these are changed by re-running
"configure", by putting their definitions into a generated file that
depends on Makefile.
This commit is contained in:
Ben Pfaff committed 2008-10-23 14:07:25 -07:00
1 parent f793b541e2
commit ddbf6040e3
16 files changed
+101 -24

No files matched your search

+3 -8
View File
@@ -20,12 +20,6 @@ endif
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
@@ -46,11 +40,12 @@ noinst_LIBRARIES =
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'
ro_c = echo '/* -*- mode: c; buffer-read-only: t -*- */'
EXTRA_DIST += README.hwtables
+1 -1
View 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
\fB@rundir@\fR.
\fB@RUNDIR@\fR.
.TP
\fB-f\fR, \fB--force\fR
+1
View File
@@ -5,6 +5,7 @@ noinst_HEADERS += \
include/daemon.h \
include/dhcp-client.h \
include/dhcp.h \
include/dirs.h \
include/dynamic-string.h \
include/dpif.h \
include/fatal-signal.h \
+40
View File
@@ -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 */
+7
View File
@@ -31,6 +31,7 @@ lib_libopenflow_a_SOURCES = \
lib/vconn-stream.c \
lib/vconn.c \
lib/vlog-socket.c \
lib/dirs.c \
lib/vlog.c
if HAVE_NETLINK
@@ -58,3 +59,9 @@ EXTRA_DIST += \
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
+4 -3
View File
@@ -39,6 +39,7 @@
#include <string.h>
#include <unistd.h>
#include "fatal-signal.h"
#include "dirs.h"
#include "util.h"
#define THIS_MODULE VLM_daemon
@@ -58,9 +59,9 @@ static bool force;
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)
: xasprintf("%s/%s", RUNDIR, name));
: xasprintf("%s/%s", ofp_rundir, 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",
RUNDIR, program_name);
ofp_rundir, program_name);
}
+34
View File
@@ -1,3 +1,5 @@
# -*- autoconf -*-
# 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])])
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.
@@ -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_PKIDIR])
AC_REQUIRE([OFP_CHECK_RUNDIR])
AC_REQUIRE([OFP_CHECK_LOGDIR])
AC_CHECK_FUNCS([strlcpy])])
+1 -1
View 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
\fB@rundir@\fR.
\fB@RUNDIR@\fR.
.TP
\fB-f\fR, \fB--force\fR
+1 -1
View 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
\fB@rundir@\fR.
\fB@RUNDIR@\fR.
.TP
\fB-f\fR, \fB--force\fR
-2
View 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
pkidir = $(pkgdatadir)/pki
utilities/ofp-pki: utilities/ofp-pki.in Makefile
$(do_subst) < $(srcdir)/utilities/ofp-pki.in \
| $(ro_script) > utilities/ofp-pki
+1 -1
View 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
\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,
+2 -1
View File
@@ -42,6 +42,7 @@
#include "daemon.h"
#include "dhcp-client.h"
#include "dhcp.h"
#include "dirs.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",
program_name, program_name, RUNDIR, program_name);
program_name, program_name, ofp_rundir, program_name);
exit(EXIT_SUCCESS);
}
+1 -1
View 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.
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
+1 -1
View File
@@ -9,7 +9,7 @@ $CGI::POST_MAX = 65536; # Limit POSTs to 64 kB.
use strict;
use warnings;
my $pkidir = '@pkidir@';
my $pkidir = '@PKIDIR@';
my $q = new CGI;
die unless $q->request_method() eq 'POST';
+3 -3
View File
@@ -67,7 +67,7 @@ administration:
.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.
@@ -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,
\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.
@@ -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
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
+1 -1
View File
@@ -1,6 +1,6 @@
#! /bin/sh -e
pkidir='@pkidir@'
pkidir='@PKIDIR@'
command=
prev=
force=no