diff options
author | Alejandro Colomar <alx@nginx.com> | 2023-03-22 16:55:02 +0100 |
---|---|---|
committer | Alejandro Colomar <alx@nginx.com> | 2023-03-29 00:41:08 +0200 |
commit | 6e16d7ac5bb86140a55ea30a35c69ee0df3eff8d (patch) | |
tree | c0b346f2bd14433df1c1b412b5d798a0f7f1a178 /auto/make | |
parent | 5ba79b9b524ef746bc3269520c3f6b893f39275c (diff) | |
download | unit-6e16d7ac5bb86140a55ea30a35c69ee0df3eff8d.tar.gz unit-6e16d7ac5bb86140a55ea30a35c69ee0df3eff8d.tar.bz2 |
Auto: mirroring installation structure in build tree.
This makes the build tree more organized, which is good for adding new
stuff. Now, it's useful for example for adding manual pages in man3/,
but it may be useful in the future for example for extending the build
system to run linters (e.g., clang-tidy(1), Clang analyzer, ...) on the
C source code.
Previously, the build tree was quite flat, and looked like this (after
`./configure && make`):
$ tree -I src build
build
├── Makefile
├── autoconf.data
├── autoconf.err
├── echo
├── libnxt.a
├── nxt_auto_config.h
├── nxt_version.h
├── unitd
└── unitd.8
1 directory, 9 files
And after this patch, it looks like this:
$ tree -I src build
build
├── Makefile
├── autoconf.data
├── autoconf.err
├── bin
│ └── echo
├── include
│ ├── nxt_auto_config.h
│ └── nxt_version.h
├── lib
│ ├── libnxt.a
│ └── unit
│ └── modules
├── sbin
│ └── unitd
├── share
│ └── man
│ └── man8
│ └── unitd.8
└── var
├── lib
│ └── unit
├── log
│ └── unit
└── run
└── unit
17 directories, 9 files
It also solves one issue introduced in
5a37171f733f ("Added default values for pathnames."). Before that
commit, it was possible to run unitd from the build system
(`./build/unitd`). Now, since it expects files in a very specific
location, that has been broken. By having a directory structure that
mirrors the installation, it's possible to trick it to believe it's
installed, and run it from there:
$ ./configure --prefix=./build
$ make
$ ./build/sbin/unitd
Fixes: 5a37171f733f ("Added default values for pathnames.")
Reported-by: Liam Crilly <liam@nginx.com>
Reviewed-by: Konstantin Pavlov <thresh@nginx.com>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Cc: Andrei Zeliankou <zelenkov@nginx.com>
Cc: Zhidao Hong <z.hong@f5.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
Diffstat (limited to 'auto/make')
-rw-r--r-- | auto/make | 78 |
1 files changed, 37 insertions, 41 deletions
@@ -7,9 +7,6 @@ $echo "creating $NXT_MAKEFILE" -mkdir -p $NXT_BUILD_DIR/src \ - $NXT_BUILD_DIR/src/test - cat << END > $NXT_MAKEFILE @@ -25,8 +22,8 @@ NXT_MODULE_LINK = $NXT_MODULE_LINK all: $NXT_DAEMON manpage .PHONY: $NXT_DAEMON manpage -$NXT_DAEMON: $NXT_BUILD_DIR/$NXT_DAEMON -manpage: $NXT_BUILD_DIR/unitd.8 +$NXT_DAEMON: $NXT_BUILD_DIR/sbin/$NXT_DAEMON +manpage: $NXT_BUILD_DIR/share/man/man8/unitd.8 END @@ -35,7 +32,7 @@ END $echo -n "NXT_LIB_INCS =" >> $NXT_MAKEFILE -for nxt_inc in src $NXT_BUILD_DIR +for nxt_inc in src $NXT_BUILD_DIR/include do $echo -n " -I $nxt_inc" >> $NXT_MAKEFILE done @@ -88,20 +85,17 @@ END cat << END >> $NXT_MAKEFILE -libnxt: $NXT_BUILD_DIR/$NXT_LIB_SHARED $NXT_BUILD_DIR/$NXT_LIB_STATIC +libnxt: $NXT_BUILD_DIR/lib/$NXT_LIB_SHARED $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC -$NXT_BUILD_DIR/$NXT_LIB_SHARED: \$(NXT_LIB_OBJS) - \$(NXT_SHARED_LOCAL_LINK) -o $NXT_BUILD_DIR/$NXT_LIB_SHARED \\ - \$(NXT_LIB_OBJS) \\ +$NXT_BUILD_DIR/lib/$NXT_LIB_SHARED: \$(NXT_LIB_OBJS) + \$(NXT_SHARED_LOCAL_LINK) -o \$@ \$(NXT_LIB_OBJS) \\ $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS -$NXT_BUILD_DIR/$NXT_LIB_STATIC: \$(NXT_LIB_OBJS) - $NXT_STATIC_LINK $NXT_BUILD_DIR/$NXT_LIB_STATIC \\ - \$(NXT_LIB_OBJS) +$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC: \$(NXT_LIB_OBJS) + $NXT_STATIC_LINK \$@ \$(NXT_LIB_OBJS) -$NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC: \$(NXT_LIB_UNIT_OBJS) - $NXT_STATIC_LINK $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC \\ - \$(NXT_LIB_UNIT_OBJS) +$NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC: \$(NXT_LIB_UNIT_OBJS) + $NXT_STATIC_LINK \$@ \$(NXT_LIB_UNIT_OBJS) END @@ -195,55 +189,55 @@ tests: $NXT_BUILD_DIR/tests $NXT_BUILD_DIR/utf8_file_name_test \\ $NXT_BUILD_DIR/unit_websocket_echo $NXT_BUILD_DIR/tests: \$(NXT_TEST_OBJS) \\ - $NXT_BUILD_DIR/$NXT_LIB_STATIC + $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/tests \\ \$(CFLAGS) \$(NXT_TEST_OBJS) \\ - $NXT_BUILD_DIR/$NXT_LIB_STATIC \\ + $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\ $NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS $NXT_BUILD_DIR/utf8_file_name_test: $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\ - $NXT_BUILD_DIR/$NXT_LIB_STATIC + $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \$(CC) \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\ -o $NXT_BUILD_DIR/utf8_file_name_test \\ $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\ - $NXT_BUILD_DIR/$NXT_LIB_STATIC \\ + $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\ $NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS $NXT_BUILD_DIR/ncq_test: $NXT_BUILD_DIR/src/test/nxt_ncq_test.o \\ - $NXT_BUILD_DIR/$NXT_LIB_STATIC + $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/ncq_test \\ \$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_ncq_test.o \\ - $NXT_BUILD_DIR/$NXT_LIB_STATIC \\ + $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\ $NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS $NXT_BUILD_DIR/vbcq_test: $NXT_BUILD_DIR/src/test/nxt_vbcq_test.o \\ - $NXT_BUILD_DIR/$NXT_LIB_STATIC + $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/vbcq_test \\ \$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_vbcq_test.o \\ - $NXT_BUILD_DIR/$NXT_LIB_STATIC \\ + $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\ $NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS $NXT_BUILD_DIR/unit_app_test: $NXT_BUILD_DIR/src/test/nxt_unit_app_test.o \\ - $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC + $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_app_test \\ \$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_unit_app_test.o \\ - $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC \\ + $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \\ $NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS $NXT_BUILD_DIR/unit_websocket_chat: \\ $NXT_BUILD_DIR/src/test/nxt_unit_websocket_chat.o \\ - $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC + $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_websocket_chat \\ \$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_unit_websocket_chat.o \\ - $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC \\ + $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \\ $NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS $NXT_BUILD_DIR/unit_websocket_echo: \\ $NXT_BUILD_DIR/src/test/nxt_unit_websocket_echo.o \\ - $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC + $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_websocket_echo \\ \$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_unit_websocket_echo.o \\ - $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC \\ + $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \\ $NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS END @@ -264,7 +258,7 @@ END fi -NXT_MAKE_INCS="src $NXT_BUILD_DIR" +NXT_MAKE_INCS="src $NXT_BUILD_DIR/include" NXT_MAKE_SRCS="$NXT_SRCS" @@ -298,10 +292,10 @@ $echo >> $NXT_MAKEFILE cat << END >> $NXT_MAKEFILE -$NXT_BUILD_DIR/$NXT_DAEMON: $NXT_BUILD_DIR/$NXT_LIB_STATIC \\ +$NXT_BUILD_DIR/sbin/$NXT_DAEMON: $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\ \$(NXT_OBJS) - \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/$NXT_DAEMON \$(CFLAGS) \\ - \$(NXT_OBJS) $NXT_BUILD_DIR/$NXT_LIB_STATIC \\ + \$(NXT_EXEC_LINK) -o \$@ \$(CFLAGS) \\ + \$(NXT_OBJS) $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\ $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS END @@ -311,7 +305,8 @@ END cat << END >> $NXT_MAKEFILE -$NXT_BUILD_DIR/unitd.8: docs/man/unitd.8.in $NXT_BUILD_DIR/nxt_auto_config.h +$NXT_BUILD_DIR/share/man/man8/unitd.8: docs/man/unitd.8.in \\ + $NXT_BUILD_DIR/include/nxt_auto_config.h sed -e "s|%%ERROR_LOG_PATH%%|$NXT_LOG|" \\ -e "s|%%PID_PATH%%|$NXT_PID|" \\ -e "s|%%SOCKET_PATH%%|$NXT_CONTROL|" \\ @@ -365,7 +360,7 @@ install-check: ${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/ + install -p $NXT_BUILD_DIR/sbin/$NXT_DAEMON \$(DESTDIR)$NXT_SBINDIR/ test -d \$(DESTDIR)$NXT_STATEDIR \ || install -d \$(DESTDIR)$NXT_STATEDIR test -d \$(DESTDIR)$NXT_LOGDIR \ @@ -376,7 +371,8 @@ ${NXT_DAEMON}-install: $NXT_DAEMON install-check manpage-install: manpage install-check test -d \$(DESTDIR)$NXT_MANDIR/man8 \ || install -d \$(DESTDIR)$NXT_MANDIR/man8 - install -p -m644 $NXT_BUILD_DIR/unitd.8 \$(DESTDIR)$NXT_MANDIR/man8/ + install -p -m644 $NXT_BUILD_DIR/share/man/man8/unitd.8 \ + \$(DESTDIR)$NXT_MANDIR/man8/ .PHONY: uninstall ${NXT_DAEMON}-uninstall manpage-uninstall @@ -396,10 +392,10 @@ cat << END >> $NXT_MAKEFILE .PHONY: libunit-install libunit-uninstall -libunit-install: $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC +libunit-install: $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC test -d \$(DESTDIR)$NXT_LIBDIR \ || install -d \$(DESTDIR)$NXT_LIBDIR - install -p -m u=rw,go=r $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC \ + install -p -m u=rw,go=r $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \ \$(DESTDIR)$NXT_LIBDIR/ test -d \$(DESTDIR)$NXT_INCLUDEDIR \ || install -d \$(DESTDIR)$NXT_INCLUDEDIR @@ -410,8 +406,8 @@ libunit-install: $NXT_BUILD_DIR/$NXT_LIB_UNIT_STATIC src/nxt_unit_sptr.h \ src/nxt_unit_typedefs.h \ src/nxt_unit_websocket.h \ - $NXT_BUILD_DIR/nxt_auto_config.h \ - $NXT_BUILD_DIR/nxt_version.h \ + $NXT_BUILD_DIR/include/nxt_auto_config.h \ + $NXT_BUILD_DIR/include/nxt_version.h \ src/nxt_websocket_header.h \ \$(DESTDIR)$NXT_INCLUDEDIR/ |