summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-12-01 16:28:06 +0300
committerMax Romanov <max.romanov@nginx.com>2017-12-01 16:28:06 +0300
commit630ec3f1eca0543b2d10c409822ea4acb657c87c (patch)
treea5256391de48996133269e860486c28e4745824f
parent1add36a7ee543b993aeba10c04a4abfc0244c3f8 (diff)
downloadunit-630ec3f1eca0543b2d10c409822ea4acb657c87c.tar.gz
unit-630ec3f1eca0543b2d10c409822ea4acb657c87c.tar.bz2
Using compiler capability to generate dependencies.
This closes #58 issue on GitHub.
-rw-r--r--auto/cc/deps25
-rw-r--r--auto/feature8
-rw-r--r--auto/make62
-rw-r--r--auto/modules/php10
-rw-r--r--auto/modules/python15
-rw-r--r--auto/save1
-rw-r--r--auto/sources76
7 files changed, 78 insertions, 119 deletions
diff --git a/auto/cc/deps b/auto/cc/deps
new file mode 100644
index 00000000..6e7df20f
--- /dev/null
+++ b/auto/cc/deps
@@ -0,0 +1,25 @@
+
+case "$NXT_CC_NAME" in
+
+ SunC):
+ nxt_gen_dep_flags() {
+ $echo "-xMMD -xMF $NXT_BUILD_DIR/$nxt_dep.tmp"
+ }
+
+ nxt_gen_dep_post() {
+ $echo -n "@sed -e 's#^.*:#$NXT_BUILD_DIR/$nxt_obj:#' "
+ $echo -n "$NXT_BUILD_DIR/$nxt_dep.tmp > $NXT_BUILD_DIR/$nxt_dep"
+ $echo " && rm -f $NXT_BUILD_DIR/$nxt_dep.tmp"
+ }
+ ;;
+
+ *)
+ nxt_gen_dep_flags() {
+ $echo "-MMD -MF $NXT_BUILD_DIR/$nxt_dep -MT $NXT_BUILD_DIR/$nxt_obj"
+ }
+
+ nxt_gen_dep_post() {
+ $echo ""
+ }
+ ;;
+esac
diff --git a/auto/feature b/auto/feature
index f7e7f25d..55df46bc 100644
--- a/auto/feature
+++ b/auto/feature
@@ -74,13 +74,15 @@ END
if /bin/sh -c "($NXT_AUTOTEST)" >> $NXT_AUTOCONF_ERR 2>&1; then
$echo " found"
nxt_found=yes
- cat << END >> $NXT_AUTO_CONFIG_H
+ if [ -n "$nxt_feature_name" ]; then
+ cat << END >> $NXT_AUTO_CONFIG_H
#ifndef $nxt_feature_name
#define $nxt_feature_name 1
#endif
END
+ fi
else
$echo " found but is not working"
fi
@@ -89,13 +91,15 @@ END
*)
$echo " found"
nxt_found=yes
- cat << END >> $NXT_AUTO_CONFIG_H
+ if [ -n "$nxt_feature_name" ]; then
+ cat << END >> $NXT_AUTO_CONFIG_H
#ifndef $nxt_feature_name
#define $nxt_feature_name 1
#endif
END
+ fi
;;
esac
diff --git a/auto/make b/auto/make
index 27b937fb..12abd41c 100644
--- a/auto/make
+++ b/auto/make
@@ -3,6 +3,7 @@
# Copyright (C) Valentin V. Bartenev
# Copyright (C) NGINX, Inc.
+. auto/cc/deps
$echo "creating $NXT_MAKEFILE"
@@ -41,26 +42,13 @@ $echo >> $NXT_MAKEFILE
$echo >> $NXT_MAKEFILE
-# The include files dependences list.
-
-$echo "NXT_LIB_DEPS = \\" >> $NXT_MAKEFILE
-
-for nxt_dep in $NXT_LIB_DEPS $NXT_TEST_DEPS $NXT_AUTO_CONFIG_H
-do
- $echo " $nxt_dep \\" >> $NXT_MAKEFILE
-done
-
-$echo >> $NXT_MAKEFILE
-$echo >> $NXT_MAKEFILE
-
-
# Library object files list.
$echo "NXT_LIB_OBJS = \\" >> $NXT_MAKEFILE
for nxt_src in $NXT_LIB_SRCS
do
- nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
+ nxt_obj=${nxt_src%.c}.o
$echo " $NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
done
@@ -89,13 +77,21 @@ END
for nxt_src in $NXT_LIB_SRCS $NXT_TEST_SRCS
do
- nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
+ nxt_obj=${nxt_src%.c}.o
+ nxt_dep=${nxt_src%.c}.dep
+ nxt_dep_flags=`nxt_gen_dep_flags`
+ nxt_dep_post=`nxt_gen_dep_post`
cat << END >> $NXT_MAKEFILE
-$NXT_BUILD_DIR/$nxt_obj: $nxt_src \$(NXT_LIB_DEPS)
+$NXT_BUILD_DIR/$nxt_obj: $nxt_src
\$(CC) -c \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
-o $NXT_BUILD_DIR/$nxt_obj \\
+ $nxt_dep_flags \\
$nxt_src
+ $nxt_dep_post
+
+-include $NXT_BUILD_DIR/$nxt_dep
+
END
done
@@ -109,7 +105,7 @@ $echo "NXT_TEST_OBJS = \\" >> $NXT_MAKEFILE
for nxt_src in $NXT_TEST_SRCS
do
- nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
+ nxt_obj=${nxt_src%.c}.o
$echo " $NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
done
@@ -119,14 +115,14 @@ done
cat << END >> $NXT_MAKEFILE
$NXT_BUILD_DIR/tests: \$(NXT_TEST_OBJS) \\
- $NXT_BUILD_DIR/$NXT_LIB_STATIC \$(NXT_LIB_DEPS)
+ $NXT_BUILD_DIR/$NXT_LIB_STATIC
\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/tests \\
\$(CFLAGS) \$(NXT_TEST_OBJS) \\
$NXT_BUILD_DIR/$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_LIB_DEPS)
+ $NXT_BUILD_DIR/$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 \\
@@ -137,7 +133,6 @@ END
NXT_MAKE_INCS="src $NXT_BUILD_DIR"
-NXT_MAKE_DEPS="\$(NXT_LIB_DEPS) $NXT_DEPS"
NXT_MAKE_SRCS="$NXT_SRCS"
@@ -154,26 +149,13 @@ $echo >> $NXT_MAKEFILE
$echo >> $NXT_MAKEFILE
-# The include files dependences list.
-
-$echo "NXT_DEPS = \\" >> $NXT_MAKEFILE
-
-for nxt_dep in $NXT_MAKE_DEPS
-do
- $echo " $nxt_dep \\" >> $NXT_MAKEFILE
-done
-
-$echo >> $NXT_MAKEFILE
-$echo >> $NXT_MAKEFILE
-
-
# Object files list.
$echo "NXT_OBJS = \\" >> $NXT_MAKEFILE
for nxt_src in $NXT_MAKE_SRCS
do
- nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
+ nxt_obj=${nxt_src%.c}.o
$echo " $NXT_BUILD_DIR/$nxt_obj \\" >> $NXT_MAKEFILE
done
@@ -197,14 +179,22 @@ END
for nxt_src in $NXT_MAKE_SRCS
do
- nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/\.o/"`
+ nxt_obj=${nxt_src%.c}.o
+ nxt_dep=${nxt_src%.c}.dep
+ nxt_dep_flags=`nxt_gen_dep_flags`
+ nxt_dep_post=`nxt_gen_dep_post`
cat << END >> $NXT_MAKEFILE
-$NXT_BUILD_DIR/$nxt_obj: $nxt_src \$(NXT_DEPS)
+$NXT_BUILD_DIR/$nxt_obj: $nxt_src
\$(CC) -c \$(CFLAGS) \$(NXT_INCS) \\
$NXT_LIB_AUX_CFLAGS \\
-o $NXT_BUILD_DIR/$nxt_obj \\
+ $nxt_dep_flags \\
$nxt_src
+ $nxt_dep_post
+
+-include $NXT_BUILD_DIR/$nxt_dep
+
END
done
diff --git a/auto/modules/php b/auto/modules/php
index daeb0b68..e5eb60f0 100644
--- a/auto/modules/php
+++ b/auto/modules/php
@@ -82,7 +82,7 @@ if /bin/sh -c "${NXT_PHP_CONFIG} --version" >> $NXT_AUTOCONF_ERR 2>&1; then
fi
nxt_feature="PHP embed SAPI"
- nxt_feature_name=NXT_HAVE_PHP
+ nxt_feature_name=""
nxt_feature_run=no
nxt_feature_incs="${NXT_PHP_INCLUDE}"
nxt_feature_libs="${NXT_PHP_LIB} ${NXT_PHP_LDFLAGS}"
@@ -120,6 +120,7 @@ fi
$echo " + PHP module: ${NXT_PHP_MODULE}.unit.so"
+. auto/cc/deps
$echo >> $NXT_MAKEFILE
@@ -133,14 +134,19 @@ nxt_objs=
for nxt_src in $NXT_PHP_MODULE_SRCS; do
- nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/-$NXT_PHP_MODULE.o/"`
+ nxt_obj=${nxt_src%.c}-$NXT_PHP_MODULE.o
+ nxt_dep=${nxt_src%.c}-$NXT_PHP_MODULE.dep
+ nxt_dep_flags=`nxt_gen_dep_flags`
+ nxt_dep_post=`nxt_gen_dep_post`
nxt_objs="$nxt_objs $NXT_BUILD_DIR/$nxt_obj"
cat << END >> $NXT_MAKEFILE
$NXT_BUILD_DIR/$nxt_obj: $nxt_src
\$(CC) -c \$(CFLAGS) \$(NXT_INCS) $NXT_PHP_INCLUDE \\
+ $nxt_dep_flags \\
-o $NXT_BUILD_DIR/$nxt_obj $nxt_src
+ $nxt_dep_post
END
done
diff --git a/auto/modules/python b/auto/modules/python
index f006d87b..bd6377f4 100644
--- a/auto/modules/python
+++ b/auto/modules/python
@@ -65,7 +65,7 @@ if /bin/sh -c "$NXT_PYTHON_CONFIG --prefix" >> $NXT_AUTOCONF_ERR 2>&1; then
NXT_PYTHON_LIBS=`${NXT_PYTHON_CONFIG} --ldflags`
nxt_feature="Python"
- nxt_feature_name=NXT_HAVE_PYTHON
+ nxt_feature_name=""
nxt_feature_run=no
nxt_feature_incs="${NXT_PYTHON_INCLUDE}"
nxt_feature_libs="${NXT_PYTHON_LIBS}"
@@ -92,7 +92,7 @@ fi
nxt_feature="Python version"
-nxt_feature_name=NXT_PYTHON_VERSION
+nxt_feature_name=""
nxt_feature_run=value
nxt_feature_incs="${NXT_PYTHON_INCLUDE}"
nxt_feature_libs="${NXT_PYTHON_LIBS}"
@@ -117,6 +117,7 @@ fi
$echo " + Python module: ${NXT_PYTHON_MODULE}.unit.so"
+. auto/cc/deps
$echo >> $NXT_MAKEFILE
@@ -130,14 +131,22 @@ nxt_objs=
for nxt_src in $NXT_PYTHON_MODULE_SRCS; do
- nxt_obj=`$echo $nxt_src | sed -e "s/\.c$/-$NXT_PYTHON_MODULE.o/"`
+ nxt_obj=${nxt_src%.c}-$NXT_PYTHON_MODULE.o
+ nxt_dep=${nxt_src%.c}-$NXT_PYTHON_MODULE.dep
+ nxt_dep_flags=`nxt_gen_dep_flags`
+ nxt_dep_post=`nxt_gen_dep_post`
nxt_objs="$nxt_objs $NXT_BUILD_DIR/$nxt_obj"
cat << END >> $NXT_MAKEFILE
$NXT_BUILD_DIR/$nxt_obj: $nxt_src
\$(CC) -c \$(CFLAGS) \$(NXT_INCS) $NXT_PYTHON_INCLUDE \\
+ $nxt_dep_flags \\
-o $NXT_BUILD_DIR/$nxt_obj $nxt_src
+ $nxt_dep_post
+
+-include $NXT_BUILD_DIR/$nxt_dep
+
END
done
diff --git a/auto/save b/auto/save
index 3fad03e1..27304272 100644
--- a/auto/save
+++ b/auto/save
@@ -8,6 +8,7 @@ cat << END > $NXT_AUTOCONF_DATA
CC='$CC'
CFLAGS='$CFLAGS'
+NXT_CC_NAME='$NXT_CC_NAME'
NXT_CFLAGS='$NXT_CFLAGS'
NXT_CC_OPT='$NXT_CC_OPT'
NXT_LD_OPT='$NXT_LD_OPT'
diff --git a/auto/sources b/auto/sources
index 08083b96..48052d9a 100644
--- a/auto/sources
+++ b/auto/sources
@@ -3,80 +3,6 @@
# Copyright (C) NGINX, Inc.
-NXT_LIB_DEPS=" \
- src/nxt_main.h \
- src/nxt_clang.h \
- src/nxt_types.h \
- src/nxt_atomic.h \
- src/nxt_errno.h \
- src/nxt_time.h \
- src/nxt_unix.h \
- src/nxt_malloc.h \
- src/nxt_file.h \
- src/nxt_mem_map.h \
- src/nxt_socket.h \
- src/nxt_process_type.h \
- src/nxt_process.h \
- src/nxt_signal.h \
- src/nxt_port.h \
- src/nxt_port_hash.h \
- src/nxt_port_memory.h \
- src/nxt_port_memory_int.h \
- src/nxt_dyld.h \
- src/nxt_thread.h \
- src/nxt_thread_id.h \
- src/nxt_spinlock.h \
- src/nxt_random.h \
- src/nxt_queue.h \
- src/nxt_rbtree.h \
- src/nxt_string.h \
- src/nxt_utf8.h \
- src/nxt_unicode_lowcase.h \
- src/nxt_parse.h \
- src/nxt_mp.h \
- src/nxt_mem_zone.h \
- src/nxt_sprintf.h \
- src/nxt_file_name.h \
- src/nxt_log.h \
- src/nxt_djb_hash.h \
- src/nxt_murmur_hash.h \
- src/nxt_lvlhsh.h \
- src/nxt_hash.h \
- src/nxt_sort.h \
- src/nxt_array.h \
- src/nxt_vector.h \
- src/nxt_list.h \
- src/nxt_buf.h \
- src/nxt_buf_pool.h \
- src/nxt_buf_filter.h \
- src/nxt_recvbuf.h \
- src/nxt_sendbuf.h \
- src/nxt_semaphore.h \
- src/nxt_thread_log.h \
- src/nxt_thread_time.h \
- src/nxt_thread_pool.h \
- src/nxt_work_queue.h \
- src/nxt_service.h \
- src/nxt_log_moderation.h \
- src/nxt_event_engine.h \
- src/nxt_timer.h \
- src/nxt_fd_event.h \
- src/nxt_file_event.h \
- src/nxt_conn.h \
- src/nxt_job.h \
- src/nxt_job_file.h \
- src/nxt_sockaddr.h \
- src/nxt_job_resolve.h \
- src/nxt_listen_socket.h \
- src/nxt_http_parse.h \
- src/nxt_runtime.h \
- src/nxt_conf.h \
- src/nxt_application.h \
- src/nxt_main_process.h \
- src/nxt_router.h \
- src/nxt_port_hash.h \
-"
-
NXT_LIB_SRCS=" \
src/nxt_lib.c \
src/nxt_gmtime.c \
@@ -228,7 +154,6 @@ NXT_LIB_UTF8_FILE_NAME_TEST_SRCS=" \
if [ $NXT_SSLTLS = YES ]; then
nxt_have=NXT_SSLTLS . auto/have
- NXT_LIB_DEPS="$NXT_LIB_DEPS $NXT_LIB_SSLTLS_DEPS"
NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_LIB_SSLTLS_SRCS"
fi
@@ -322,7 +247,6 @@ fi
if [ "$NXT_TEST_BUILD" = "YES" ]; then
- NXT_LIB_DEPS="$NXT_LIB_DEPS $NXT_TEST_BUILD_DEPS"
NXT_LIB_SRCS="$NXT_LIB_SRCS $NXT_TEST_BUILD_SRCS"
fi