From 5a37171f733fa8c7326161cc49af3df0be5dfae4 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Thu, 14 Jul 2022 13:25:57 +0200 Subject: [PATCH] Added default values for pathnames. This allows one to simply run `./configure` and expect it to produce sane defaults for an install. Previously, without specifying `--prefix=...`, `make install` would simply fail, recommending to set `--prefix` or `DESTDIR`, but that recommendation was incomplete at best, since it didn't set many of the subdirs needed for a good organization. Setting `DESTDIR` was even worse, since that shouldn't even affect an installation (it is required to be transparent to the installation). /usr/local is the historic Unix standard path to use for installations from source made manually by the admin of the system. Some package managers (Homebrew, I'm looking specifically at you) have abused that path to install their things, but 1) it's not our fault that someone else incorrectly abuses that path (and they seem to be fixing it for newer archs; e.g., they started using /opt/homebrew for Apple Silicon), 2) there's no better path than /usr/local, 3) we still allow changing it for systems where this might not be the desired path (MacOS Intel with hombrew), and 4) it's _the standard_. See a related conversation with Ingo (OpenBSD maintainer): On 7/27/22 16:16, Ingo Schwarze wrote: > Hi Alejandro, [...] > > Alejandro Colomar wrote on Sun, Jul 24, 2022 at 07:07:18PM +0200: >> On 7/24/22 16:57, Ingo Schwarze wrote: >>> Alejandro Colomar wrote on Sun, Jul 24, 2022 at 01:20:46PM +0200: > >>>> /usr/local is for sysadmins to build from source; > >>> Doing that is *very* strongly discouraged on OpenBSD. > >> I guess that's why the directory was reused in the BSDs to install ports >> (probably ports were installed by the sysadmin there, and by extension, >> ports are now always installed there, but that's just a guess). > > Maybe. In any case, the practice of using /usr/local for packages > created from ports is significantly older than the recommendation > to refrain from using upstream "make install" outside the ports > framework. > > * The FreeBSD ports framework was started by Jordan Hubbard in 1993. > * The ports framework was ported from FreeBSD to OpenBSD > by Niklas Hallqvist in 1996. > * NetBSD pkgsrc was forked from FreeBSD ports by Alistair G. Crooks > and Hubert Feyrer in 1997. > > I failed to quickly find Jordan's original version, but rev. 1.1 > of /usr/ports/infrastructure/mk/bsd.port.mk in OpenBSD (dated Jun 3 > 22:47:10 1996 UTC) already said > > LOCALBASE ?= /usr/local > PREFIX ?= ${LOCALBASE} > [...] >> I had a discussion in NGINX Unit about it, and >> the decission for now has been: "support prefix=/usr/local for default >> manual installation through the Makefile, and let BSD users adjust to >> their preferred path". > > That's an *excellent* solution for the task, thanks for doing it > the right way. By setting PREFIX=/usr/local by default in the > upstream Makefile, you are minimizing the work for *BSD porters. > > The BSD ports frameworks will typically run the upstreak "make install" > with the variable DESTDIR set to a custom value, for example > > DESTDIR=/usr/ports/pobj/groff-1.23.0/fake-amd64 > > so if the upstream Makefile sets PREFIX=/usr/local , > that's perfect, everything gets installed to the right place > without an intervention by the person doing the porting. > > Of course, if the upstream Makefile would use some other PREFIX, > that would not be a huge obstacle. All we have to do in that case > is pass the option --prefix=/usr/local to the ./configure script, > or something equivalent if the software isn't using GNU configure. > >> We were concerned that we might get collisions >> with the BSD port also installing in /usr/local, but that's the least >> evil (and considering BSD users don't typically run `make install`, it's >> not so bad). > > It's not bad at all. It's perfect. > > Of course, if a user wants to install *without* the ports framework, > they have to provide their own --prefix. But that's not an issue > because it is easy to do, and installing without a port is discouraged > anyway. === Directory variables should never contain a trailing slash (I've learned that the hard way, where some things would break unexpectedly). Especially, make(1) is likely to have problems when things have double slashes or a trailing slash, since it treats filenames as text strings. I've removed the trailing slash from the prefix, and added it to the derivate variables just after the prefix. pkg-config(1) also expects directory variables to have no trailing slash. === I also removed the code that would set variables as depending on the prefix if they didn't start with a slash, because that is a rather non-obvious behavior, and things should not always depend on prefix, but other dirs such as $(runstatedir), so if we keep a similar behavior it would be very unreliable. Better keep variables intact if set, or use the default if unset. === Print the real defaults for ./configure --help, rather than the actual values. === I used a subdirectory under the standard /var/lib for NXT_STATE, instead of a homemade "state" dir that does the same thing. === Modified the Makefile to create some dirs that weren't being created, and also remove those that weren't being removed in uninstall, probably because someone forgot to add them. === Add new options for setting the new variables, and rename some to be consistent with the standard names. Keep the old ones at configuration time for compatibility, but mark them as deprecated. Don't keep the old ones at exec time. === A summary of the default config is: Unit configuration summary: bin directory: ............. "/usr/local/bin" sbin directory: ............ "/usr/local/sbin" lib directory: ............. "/usr/local/lib" include directory: ......... "/usr/local/include" man pages directory: ....... "/usr/local/share/man" modules directory: ......... "/usr/local/lib/unit/modules" state directory: ........... "/usr/local/var/lib/unit" tmp directory: ............. "/tmp" pid file: .................. "/usr/local/var/run/unit/unit.pid" log file: .................. "/usr/local/var/log/unit/unit.log" control API socket: ........ "unix:/usr/local/var/run/unit/control.unit.sock" Link: Link: Reviewed-by: Artem Konev Reviewed-by: Andrew Clayton Tested-by: Andrew Clayton Reviewed-by: Konstantin Pavlov Signed-off-by: Alejandro Colomar --- auto/help | 38 +++++++++------ auto/make | 36 ++++++++------ auto/modules/java | 10 ++-- auto/modules/perl | 8 +-- auto/modules/php | 8 +-- auto/modules/python | 8 +-- auto/modules/ruby | 8 +-- auto/options | 116 +++++++++++++++++++------------------------- auto/save | 4 +- auto/summary | 8 +-- configure | 17 ++----- docs/changes.xml | 7 +++ src/nxt_runtime.c | 31 ++++++------ test/conftest.py | 6 +-- tools/setup-unit | 6 +-- 15 files changed, 152 insertions(+), 159 deletions(-) diff --git a/auto/help b/auto/help index a3884679d..5de528ba4 100644 --- a/auto/help +++ b/auto/help @@ -11,23 +11,31 @@ cat << END --cc-opt=OPTIONS set additional C compiler options --ld-opt=OPTIONS set additional linker options - --prefix=DIRECTORY set prefix for relative pathnames, default: none - --bindir=DIRECTORY set user executables directory name - default: "$NXT_BINDIR" - --sbindir=DIRECTORY set system admin executables directory name - default: "$NXT_SBINDIR" - --libdir=DIRECTORY set library directory name, default: "$NXT_LIBDIR" - --incdir=DIRECTORY set includes directory name, default: "$NXT_INCDIR" - --mandir=DIRECTORY set man pages directory name, default: "$NXT_MANDIR" - --modules=DIRECTORY set modules directory name, default: "$NXT_MODULES" - --state=DIRECTORY set state directory name, default: "$NXT_STATE" - --tmp=DIRECTORY set tmp directory name, default: "$NXT_TMP" - - --pid=FILE set pid filename, default: "$NXT_PID" - --log=FILE set log filename, default: "$NXT_LOG" + --prefix=DIR default: "/usr/local" + --exec-prefix=DIR default: "\$prefix" + --bindir=DIR default: "\$exec_prefix/bin" + --sbindir=DIR default: "\$exec_prefix/sbin" + --includedir=DIR default: "\$prefix/include" + --libdir=DIR default: "\$exec_prefix/lib" + --modulesdir=DIR default: "\$libdir/unit/modules" + --datarootdir=DIR default: "\$prefix/share" + --mandir=DIR default: "\$datarootdir/man" + --localstatedir=DIR default: "\$prefix/var" + --libstatedir=DIR default: "\$localstatedir/lib/unit" + --runstatedir=DIR default: "\$localstatedir/run/unit" + --logdir=DIR default: "\$localstatedir/log/unit" + --tmpdir=DIR default: "/tmp" + + --incdir=DIR [deprecated] synonym for --includedir + --modules=DIR [deprecated] synonym for --modulesdir + --state=DIR [deprecated] synonym for --libstatedir + --tmp=DIR [deprecated] synonym for --tmpdir + + --pid=FILE set pid filename, default: "\$runstatedir/unit.pid" + --log=FILE set log filename, default: "\$logdir/unit.log" --control=ADDRESS set address of control API socket - default: "$NXT_CONTROL" + default: "unix:\$runstatedir/control.unit.sock" --user=USER set non-privileged processes to run as specified user default: "$NXT_USER" diff --git a/auto/make b/auto/make index 5324f49c7..66f2b1ec7 100644 --- a/auto/make +++ b/auto/make @@ -366,8 +366,12 @@ ${NXT_DAEMON}-install: $NXT_DAEMON install-check test -d \$(DESTDIR)$NXT_SBINDIR \ || install -d \$(DESTDIR)$NXT_SBINDIR install -p $NXT_BUILD_DIR/$NXT_DAEMON \$(DESTDIR)$NXT_SBINDIR/ - test -d \$(DESTDIR)$NXT_STATE \ - || install -d \$(DESTDIR)$NXT_STATE + test -d \$(DESTDIR)$NXT_LIBSTATEDIR \ + || install -d \$(DESTDIR)$NXT_LIBSTATEDIR + test -d \$(DESTDIR)$NXT_LOGDIR \ + || install -d \$(DESTDIR)$NXT_LOGDIR + test -d \$(DESTDIR)$NXT_RUNSTATEDIR \ + || install -d \$(DESTDIR)$NXT_RUNSTATEDIR manpage-install: manpage install-check test -d \$(DESTDIR)$NXT_MANDIR/man8 \ @@ -397,8 +401,8 @@ libunit-install: $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC || install -d \$(DESTDIR)$NXT_LIBDIR install -p -m u=rw,go=r $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC \ \$(DESTDIR)$NXT_LIBDIR/ - test -d \$(DESTDIR)$NXT_INCDIR \ - || install -d \$(DESTDIR)$NXT_INCDIR + test -d \$(DESTDIR)$NXT_INCLUDEDIR \ + || install -d \$(DESTDIR)$NXT_INCLUDEDIR install -p -m u=rw,go=r src/nxt_unit.h \ src/nxt_unit_field.h \ src/nxt_unit_request.h \ @@ -409,22 +413,22 @@ libunit-install: $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC $NXT_BUILD_DIR/nxt_auto_config.h \ $NXT_BUILD_DIR/nxt_version.h \ src/nxt_websocket_header.h \ - \$(DESTDIR)$NXT_INCDIR/ + \$(DESTDIR)$NXT_INCLUDEDIR/ libunit-uninstall: rm -f \$(DESTDIR)$NXT_LIBDIR/$NXT_LIB_UNIT_STATIC @rmdir -p \$(DESTDIR)$NXT_LIBDIR 2>/dev/null || true - rm -f \$(DESTDIR)$NXT_INCDIR/nxt_unit.h \ - \$(DESTDIR)$NXT_INCDIR/nxt_unit_field.h \ - \$(DESTDIR)$NXT_INCDIR/nxt_unit_request.h \ - \$(DESTDIR)$NXT_INCDIR/nxt_unit_response.h \ - \$(DESTDIR)$NXT_INCDIR/nxt_unit_sptr.h \ - \$(DESTDIR)$NXT_INCDIR/nxt_unit_typedefs.h \ - \$(DESTDIR)$NXT_INCDIR/nxt_unit_websocket.h \ - \$(DESTDIR)$NXT_INCDIR/nxt_auto_config.h \ - \$(DESTDIR)$NXT_INCDIR/nxt_version.h \ - \$(DESTDIR)$NXT_INCDIR/nxt_websocket_header.h - @rmdir -p \$(DESTDIR)$NXT_INCDIR 2>/dev/null || true + rm -f \$(DESTDIR)$NXT_INCLUDEDIR/nxt_unit.h \ + \$(DESTDIR)$NXT_INCLUDEDIR/nxt_unit_field.h \ + \$(DESTDIR)$NXT_INCLUDEDIR/nxt_unit_request.h \ + \$(DESTDIR)$NXT_INCLUDEDIR/nxt_unit_response.h \ + \$(DESTDIR)$NXT_INCLUDEDIR/nxt_unit_sptr.h \ + \$(DESTDIR)$NXT_INCLUDEDIR/nxt_unit_typedefs.h \ + \$(DESTDIR)$NXT_INCLUDEDIR/nxt_unit_websocket.h \ + \$(DESTDIR)$NXT_INCLUDEDIR/nxt_auto_config.h \ + \$(DESTDIR)$NXT_INCLUDEDIR/nxt_version.h \ + \$(DESTDIR)$NXT_INCLUDEDIR/nxt_websocket_header.h + @rmdir -p \$(DESTDIR)$NXT_INCLUDEDIR 2>/dev/null || true END diff --git a/auto/modules/java b/auto/modules/java index bdf17022e..a6ce5e81a 100644 --- a/auto/modules/java +++ b/auto/modules/java @@ -63,7 +63,7 @@ fi . $NXT_AUTOCONF_DATA -NXT_JARS=${NXT_JARS=$NXT_MODULES} +NXT_JARS=${NXT_JARS=$NXT_MODULESDIR} NXT_JAVA_MODULE=${NXT_JAVA_MODULE=java} NXT_JAVA_LIB_PATH=${NXT_JAVA_LIB_PATH=} @@ -535,9 +535,9 @@ ${NXT_JAVA_MODULE}-install: $NXT_BUILD_DIR/${NXT_JAVA_MODULE}.unit.so \\ $NXT_BUILD_DIR/$NXT_UNIT_JAR \\ $NXT_BUILD_DIR/$NXT_WS_API_JAR \\ java-shared-install - install -d \$(DESTDIR)$NXT_MODULES + install -d \$(DESTDIR)$NXT_MODULESDIR install -p $NXT_BUILD_DIR/${NXT_JAVA_MODULE}.unit.so \\ - \$(DESTDIR)$NXT_MODULES/ + \$(DESTDIR)$NXT_MODULESDIR/ install -d \$(DESTDIR)$NXT_JARS install -p -m 0644 $NXT_BUILD_DIR/$NXT_UNIT_JAR \$(DESTDIR)$NXT_JARS/ install -p -m 0644 $NXT_BUILD_DIR/$NXT_WS_API_JAR \$(DESTDIR)$NXT_JARS/ @@ -546,8 +546,8 @@ ${NXT_JAVA_MODULE}-install: $NXT_BUILD_DIR/${NXT_JAVA_MODULE}.unit.so \\ uninstall: ${NXT_JAVA_MODULE}-uninstall ${NXT_JAVA_MODULE}-uninstall: java-shared-uninstall - rm -f \$(DESTDIR)$NXT_MODULES/${NXT_JAVA_MODULE}.unit.so - @rmdir -p \$(DESTDIR)$NXT_MODULES 2>/dev/null || true + rm -f \$(DESTDIR)$NXT_MODULESDIR/${NXT_JAVA_MODULE}.unit.so + @rmdir -p \$(DESTDIR)$NXT_MODULESDIR 2>/dev/null || true rm -f \$(DESTDIR)$NXT_JARS/$NXT_UNIT_JAR rm -f \$(DESTDIR)$NXT_JARS/$NXT_WS_API_JAR @rmdir -p \$(DESTDIR)$NXT_JARS 2>/dev/null || true diff --git a/auto/modules/perl b/auto/modules/perl index 2daebd0dc..94f068793 100644 --- a/auto/modules/perl +++ b/auto/modules/perl @@ -195,15 +195,15 @@ $NXT_BUILD_DIR/${NXT_PERL_MODULE}.unit.so: $nxt_objs install: ${NXT_PERL_MODULE}-install ${NXT_PERL_MODULE}-install: ${NXT_PERL_MODULE} install-check - install -d \$(DESTDIR)$NXT_MODULES + install -d \$(DESTDIR)$NXT_MODULESDIR install -p $NXT_BUILD_DIR/${NXT_PERL_MODULE}.unit.so \\ - \$(DESTDIR)$NXT_MODULES/ + \$(DESTDIR)$NXT_MODULESDIR/ uninstall: ${NXT_PERL_MODULE}-uninstall ${NXT_PERL_MODULE}-uninstall: - rm -f \$(DESTDIR)$NXT_MODULES/${NXT_PERL_MODULE}.unit.so - @rmdir -p \$(DESTDIR)$NXT_MODULES 2>/dev/null || true + rm -f \$(DESTDIR)$NXT_MODULESDIR/${NXT_PERL_MODULE}.unit.so + @rmdir -p \$(DESTDIR)$NXT_MODULESDIR 2>/dev/null || true END diff --git a/auto/modules/php b/auto/modules/php index f0ecb7095..21dec2159 100644 --- a/auto/modules/php +++ b/auto/modules/php @@ -275,15 +275,15 @@ $NXT_BUILD_DIR/${NXT_PHP_MODULE}.unit.so: $nxt_objs install: ${NXT_PHP_MODULE}-install ${NXT_PHP_MODULE}-install: ${NXT_PHP_MODULE} install-check - install -d \$(DESTDIR)$NXT_MODULES + install -d \$(DESTDIR)$NXT_MODULESDIR install -p $NXT_BUILD_DIR/${NXT_PHP_MODULE}.unit.so \\ - \$(DESTDIR)$NXT_MODULES/ + \$(DESTDIR)$NXT_MODULESDIR/ uninstall: ${NXT_PHP_MODULE}-uninstall ${NXT_PHP_MODULE}-uninstall: - rm -f \$(DESTDIR)$NXT_MODULES/${NXT_PHP_MODULE}.unit.so - @rmdir -p \$(DESTDIR)$NXT_MODULES 2>/dev/null || true + rm -f \$(DESTDIR)$NXT_MODULESDIR/${NXT_PHP_MODULE}.unit.so + @rmdir -p \$(DESTDIR)$NXT_MODULESDIR 2>/dev/null || true END diff --git a/auto/modules/python b/auto/modules/python index 480ae1dab..d7504fc8e 100644 --- a/auto/modules/python +++ b/auto/modules/python @@ -223,15 +223,15 @@ $NXT_BUILD_DIR/${NXT_PYTHON_MODULE}.unit.so: $nxt_objs install: ${NXT_PYTHON_MODULE}-install ${NXT_PYTHON_MODULE}-install: ${NXT_PYTHON_MODULE} install-check - install -d \$(DESTDIR)$NXT_MODULES + install -d \$(DESTDIR)$NXT_MODULESDIR install -p $NXT_BUILD_DIR/${NXT_PYTHON_MODULE}.unit.so \\ - \$(DESTDIR)$NXT_MODULES/ + \$(DESTDIR)$NXT_MODULESDIR/ uninstall: ${NXT_PYTHON_MODULE}-uninstall ${NXT_PYTHON_MODULE}-uninstall: - rm -f \$(DESTDIR)$NXT_MODULES/${NXT_PYTHON_MODULE}.unit.so - @rmdir -p \$(DESTDIR)$NXT_MODULES 2>/dev/null || true + rm -f \$(DESTDIR)$NXT_MODULESDIR/${NXT_PYTHON_MODULE}.unit.so + @rmdir -p \$(DESTDIR)$NXT_MODULESDIR 2>/dev/null || true END diff --git a/auto/modules/ruby b/auto/modules/ruby index 608193a6b..99f6b2864 100644 --- a/auto/modules/ruby +++ b/auto/modules/ruby @@ -261,15 +261,15 @@ $NXT_BUILD_DIR/${NXT_RUBY_MODULE}.unit.so: $nxt_objs install: ${NXT_RUBY_MODULE}-install ${NXT_RUBY_MODULE}-install: ${NXT_RUBY_MODULE} install-check - install -d \$(DESTDIR)$NXT_MODULES + install -d \$(DESTDIR)$NXT_MODULESDIR install -p $NXT_BUILD_DIR/${NXT_RUBY_MODULE}.unit.so \\ - \$(DESTDIR)$NXT_MODULES/ + \$(DESTDIR)$NXT_MODULESDIR/ uninstall: ${NXT_RUBY_MODULE}-uninstall ${NXT_RUBY_MODULE}-uninstall: - rm -f \$(DESTDIR)$NXT_MODULES/${NXT_RUBY_MODULE}.unit.so - @rmdir -p \$(DESTDIR)$NXT_MODULES 2>/dev/null || true + rm -f \$(DESTDIR)$NXT_MODULESDIR/${NXT_RUBY_MODULE}.unit.so + @rmdir -p \$(DESTDIR)$NXT_MODULESDIR 2>/dev/null || true END diff --git a/auto/options b/auto/options index abcf531d1..802ab7016 100644 --- a/auto/options +++ b/auto/options @@ -9,8 +9,6 @@ NXT_CFLAGS= NXT_CC_OPT= NXT_LD_OPT= -NXT_PREFIX= - NXT_DEBUG=NO NXT_INET6=YES @@ -44,6 +42,8 @@ NXT_TEST_BUILD_HPUX_SENDFILE=NO NXT_TESTS=NO +NXT_HELP=NO + for nxt_option do case "$nxt_option" in @@ -57,14 +57,35 @@ do --ld-opt=*) NXT_LD_OPT="$value" ;; --prefix=*) NXT_PREFIX="$value" ;; + --exec-prefix=*) NXT_EXEC_PREFIX="$value" ;; --bindir=*) NXT_BINDIR="$value" ;; --sbindir=*) NXT_SBINDIR="$value" ;; + --includedir=*) NXT_INCLUDEDIR="$value" ;; + --incdir=*) + >&2 echo "[warn] option --incdir is deprecated; use --includedir" + NXT_INCLUDEDIR="$value" + ;; --libdir=*) NXT_LIBDIR="$value" ;; - --incdir=*) NXT_INCDIR="$value" ;; + --modulesdir=*) NXT_MODULESDIR="$value" ;; + --modules=*) + >&2 echo "[warn] option --modules is deprecated; use --modulesdir" + NXT_MODULESDIR="$value" + ;; + --datarootdir=*) NXT_DATAROOTDIR="$value" ;; --mandir=*) NXT_MANDIR="$value" ;; - --modules=*) NXT_MODULES="$value" ;; - --state=*) NXT_STATE="$value" ;; - --tmp=*) NXT_TMP="$value" ;; + --localstatedir=*) NXT_LOCALSTATEDIR="$value" ;; + --libstatedir=*) NXT_LIBSTATEDIR="$value" ;; + --state=*) + >&2 echo "[warn] option --state is deprecated; use --libstatedir" + NXT_LIBSTATEDIR="$value" + ;; + --logdir=*) NXT_LOGDIR="$value" ;; + --runstatedir=*) NXT_RUNSTATEDIR="$value" ;; + --tmpdir=*) NXT_TMPDIR="$value" ;; + --tmp=*) + >&2 echo "[warn] option --tmp is deprecated; use --tmpdir" + NXT_TMPDIR="$value" + ;; --pid=*) NXT_PID="$value" ;; --log=*) NXT_LOG="$value" ;; @@ -124,63 +145,26 @@ do done -case "$NXT_PREFIX" in - ""|*/) ;; - *) NXT_PREFIX="$NXT_PREFIX/" ;; -esac - -case "$NXT_BINDIR" in - /*) ;; - *) NXT_BINDIR="$NXT_PREFIX$NXT_BINDIR" ;; -esac - -case "$NXT_SBINDIR" in - /*) ;; - *) NXT_SBINDIR="$NXT_PREFIX$NXT_SBINDIR" ;; -esac - -case "$NXT_LIBDIR" in - /*) ;; - *) NXT_LIBDIR="$NXT_PREFIX$NXT_LIBDIR" ;; -esac - -case "$NXT_INCDIR" in - /*) ;; - *) NXT_INCDIR="$NXT_PREFIX$NXT_INCDIR" ;; -esac - -case "$NXT_MANDIR" in - /*) ;; - *) NXT_MANDIR="$NXT_PREFIX$NXT_MANDIR" ;; -esac - -case "$NXT_MODULES" in - /*) ;; - *) NXT_MODULES="$NXT_PREFIX$NXT_MODULES" ;; -esac - -case "$NXT_STATE" in - /*) ;; - *) NXT_STATE="$NXT_PREFIX$NXT_STATE" ;; -esac - -case "$NXT_TMP" in - /*) ;; - *) NXT_TMP="$NXT_PREFIX$NXT_TMP" ;; -esac - -case "$NXT_PID" in - /*) ;; - *) NXT_PID="$NXT_PREFIX$NXT_PID" ;; -esac - -case "$NXT_LOG" in - /*) ;; - *) NXT_LOG="$NXT_PREFIX$NXT_LOG" ;; -esac - -case "$NXT_CONTROL" in - unix:/*) ;; - unix:*) NXT_CONTROL="unix:$NXT_PREFIX${NXT_CONTROL##unix:}" ;; - *) ;; -esac +NXT_PREFIX="${NXT_PREFIX-"/usr/local"}" + +NXT_EXEC_PREFIX="${NXT_EXEC_PREFIX-"$NXT_PREFIX"}" +NXT_BINDIR="${NXT_BINDIR-"$NXT_EXEC_PREFIX/bin"}" +NXT_SBINDIR="${NXT_SBINDIR-"$NXT_EXEC_PREFIX/sbin"}" + +NXT_INCLUDEDIR="${NXT_INCLUDEDIR-"$NXT_PREFIX/include"}" + +NXT_LIBDIR="${NXT_LIBDIR-"$NXT_PREFIX/lib"}" +NXT_MODULESDIR="${NXT_MODULESDIR-"$NXT_LIBDIR/unit/modules"}" + +NXT_DATAROOTDIR="${NXT_DATAROOTDIR-"$NXT_PREFIX/share"}" +NXT_MANDIR="${NXT_MANDIR-"$NXT_DATAROOTDIR/man"}" + +NXT_LOCALSTATEDIR="${NXT_LOCALSTATEDIR-"$NXT_PREFIX/var"}" +NXT_LIBSTATEDIR="${NXT_LIBSTATEDIR-"$NXT_LOCALSTATEDIR/lib/unit"}" +NXT_LOGDIR="${NXT_LOGDIR-"$NXT_LOCALSTATEDIR/log/unit"}" +NXT_LOG="${NXT_LOG-"$NXT_LOGDIR/unit.log"}" +NXT_RUNSTATEDIR="${NXT_RUNSTATEDIR-"$NXT_LOCALSTATEDIR/run/unit"}" +NXT_CONTROL="${NXT_CONTROL-"unix:$NXT_RUNSTATEDIR/control.unit.sock"}" +NXT_PID="${NXT_PID-"$NXT_RUNSTATEDIR/unit.pid"}" + +NXT_TMPDIR="${NXT_TMPDIR-"/tmp"}" diff --git a/auto/save b/auto/save index 19ef09ecf..794b582a3 100644 --- a/auto/save +++ b/auto/save @@ -28,7 +28,7 @@ NXT_LIB_AUX_LIBS= NXT_LIB_UNIT_STATIC='$NXT_LIB_UNIT_STATIC' -NXT_MODULES='$NXT_MODULES' -NXT_TMP='$NXT_TMP' +NXT_MODULESDIR='$NXT_MODULESDIR' +NXT_TMPDIR='$NXT_TMPDIR' END diff --git a/auto/summary b/auto/summary index 51db0eae1..eff4881d5 100644 --- a/auto/summary +++ b/auto/summary @@ -10,11 +10,11 @@ Unit configuration summary: bin directory: ............. "$NXT_BINDIR" sbin directory: ............ "$NXT_SBINDIR" lib directory: ............. "$NXT_LIBDIR" - include directory: ......... "$NXT_INCDIR" + include directory: ......... "$NXT_INCLUDEDIR" man pages directory: ....... "$NXT_MANDIR" - modules directory: ......... "$NXT_MODULES" - state directory: ........... "$NXT_STATE" - tmp directory: ............. "$NXT_TMP" + modules directory: ......... "$NXT_MODULESDIR" + state directory: ........... "$NXT_LIBSTATEDIR" + tmp directory: ............. "$NXT_TMPDIR" pid file: .................. "$NXT_PID" log file: .................. "$NXT_LOG" diff --git a/configure b/configure index 8482b514e..1b831e6b7 100755 --- a/configure +++ b/configure @@ -31,17 +31,6 @@ NXT_MAKEFILE=$NXT_BUILD_DIR/Makefile CC=${CC:-cc} NXT_DAEMON=unitd -NXT_BINDIR="bin" -NXT_SBINDIR="sbin" -NXT_LIBDIR="lib" -NXT_INCDIR="include" -NXT_MANDIR="share/man" -NXT_MODULES="modules" -NXT_STATE="state" -NXT_TMP="tmp" -NXT_PID="unit.pid" -NXT_LOG="unit.log" -NXT_CONTROL="unix:control.unit.sock" NXT_USER="nobody" NXT_GROUP= @@ -82,9 +71,9 @@ cat << END >> $NXT_AUTO_CONFIG_H #define NXT_PID "$NXT_PID" #define NXT_LOG "$NXT_LOG" -#define NXT_MODULES "$NXT_MODULES" -#define NXT_STATE "$NXT_STATE" -#define NXT_TMP "$NXT_TMP" +#define NXT_MODULESDIR "$NXT_MODULESDIR" +#define NXT_LIBSTATEDIR "$NXT_LIBSTATEDIR" +#define NXT_TMPDIR "$NXT_TMPDIR" #define NXT_CONTROL_SOCK "$NXT_CONTROL" diff --git a/docs/changes.xml b/docs/changes.xml index 414f86728..569e49e5f 100644 --- a/docs/changes.xml +++ b/docs/changes.xml @@ -38,6 +38,13 @@ support the keys API on the request objects in NJS. + + +added default values for 'make install' pathnames such as prefix; +this allows to do './configure && make && sudo make install'. + + + /dev/null; then + | if grep '\--libstatedir' >/dev/null; then echo "$cmd" \ | sed 's/ --/\n--/g' \ - | grep '\--state' \ + | grep '\--libstatedir' \ | cut -d' ' -f2; else $cmd --help \ - | sed -n '/\--state/,+1p' \ + | sed -n '/\--libstatedir/,+1p' \ | grep 'default:' \ | sed 's/ *default: "\(.*\)"/\1/'; fi \