summaryrefslogtreecommitdiffhomepage
path: root/auto/make
diff options
context:
space:
mode:
Diffstat (limited to 'auto/make')
-rw-r--r--auto/make127
1 files changed, 103 insertions, 24 deletions
diff --git a/auto/make b/auto/make
index abfd41ad..f21a2dfc 100644
--- a/auto/make
+++ b/auto/make
@@ -10,10 +10,18 @@ $echo "creating $NXT_MAKEFILE"
cat << END > $NXT_MAKEFILE
+# Pretty print compiler etc actions...
+PP_CC := @echo ' CC '
+PP_AR := @echo ' AR '
+PP_LD := @echo ' LD '
+PP_VER := @echo ' VER '
+PP_SED := @echo ' SED '
+
CC = $CC
AR = $AR
-CFLAGS = $NXT_CFLAGS $NXT_CC_OPT $CFLAGS
+EXTRA_CFLAGS =
+CFLAGS = $NXT_CFLAGS $NXT_CC_OPT $CFLAGS \$(EXTRA_CFLAGS)
NXT_EXEC_LINK = $NXT_EXEC_LINK $NXT_LD_OPT
NXT_SHARED_LOCAL_LINK = $NXT_SHARED_LOCAL_LINK $NXT_LD_OPT
@@ -28,6 +36,47 @@ manpage: $NXT_BUILD_DIR/share/man/man8/unitd.8
END
+NXT_OS=$(uname -s)
+NXT_GNU_MAKE=$(make --version | grep GNU || true)
+
+# Requires GNU make. On OpenIndiana at least we have to use gmake
+if [ -n "$NXT_GNU_MAKE" ] || [ $NXT_OS = "SunOS" ]; then
+
+ cat << END >> $NXT_MAKEFILE
+# By default compiler etc output is hidden, use
+# make V=1 ...
+# to show it.
+V := 0
+
+v := @
+ifeq (\$V,1)
+ v :=
+endif
+
+# Optionally enable debugging builds with
+# make D=1 ...
+# -g is always used, this just changes the optimisation level.
+# On GCC this would be -Og, however according to the clang(1)
+# man page, -O0 'generates the most debuggable code'.
+D := 0
+
+ifeq (\$D,1)
+ CFLAGS += -O0
+endif
+
+# Optionally disable -Werror with
+# make E=0 ...
+E := 1
+
+ifeq (\$E,0)
+ CFLAGS += -Wno-error
+endif
+
+END
+
+fi
+
+
# The include paths list.
$echo -n "NXT_LIB_INCS =" >> $NXT_MAKEFILE
@@ -75,8 +124,10 @@ cat << END >> $NXT_MAKEFILE
include version
$NXT_VERSION_H: version
- $echo '#define NXT_VERSION "\$(NXT_VERSION)"' > $NXT_VERSION_H
- $echo '#define NXT_VERNUM \$(NXT_VERNUM)' >> $NXT_VERSION_H
+ \$(PP_VER) \$@ \(NXT_VERSION\)
+ \$(v)$echo '#define NXT_VERSION "\$(NXT_VERSION)"' > $NXT_VERSION_H
+ \$(PP_VER) \$@ \(NXT_VERNUM\)
+ \$(v)$echo '#define NXT_VERNUM \$(NXT_VERNUM)' >> $NXT_VERSION_H
END
@@ -88,23 +139,26 @@ cat << END >> $NXT_MAKEFILE
libnxt: $NXT_BUILD_DIR/lib/$NXT_LIB_SHARED $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC
$NXT_BUILD_DIR/lib/$NXT_LIB_SHARED: \$(NXT_LIB_OBJS)
- \$(NXT_SHARED_LOCAL_LINK) -o \$@ \$(NXT_LIB_OBJS) \\
+ \$(PP_LD) \$@
+ \$(v)\$(NXT_SHARED_LOCAL_LINK) -o \$@ \$(NXT_LIB_OBJS) \\
$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC: \$(NXT_LIB_OBJS)
- $NXT_STATIC_LINK \$@ \$(NXT_LIB_OBJS)
+ \$(PP_AR) \$@
+ \$(v)$NXT_STATIC_LINK \$@ \$(NXT_LIB_OBJS)
$NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC: \$(NXT_LIB_UNIT_OBJS) \\
$NXT_BUILD_DIR/share/pkgconfig/unit.pc \\
$NXT_BUILD_DIR/share/pkgconfig/unit-uninstalled.pc
- $NXT_STATIC_LINK \$@ \$(NXT_LIB_UNIT_OBJS)
+ \$(PP_AR) \$@
+ \$(v)$NXT_STATIC_LINK \$@ \$(NXT_LIB_UNIT_OBJS)
END
# Object files.
-for nxt_src in $NXT_LIB_SRCS $NXT_TEST_SRCS $NXT_LIB_UNIT_SRCS \
+for nxt_src in $NXT_LIB_SRCS $NXT_TEST_SRCS $NXT_FUZZ_SRCS $NXT_LIB_UNIT_SRCS \
src/test/nxt_unit_app_test.c \
src/test/nxt_unit_websocket_chat.c \
src/test/nxt_unit_websocket_echo.c
@@ -116,7 +170,8 @@ do
cat << END >> $NXT_MAKEFILE
$NXT_BUILD_DIR/$nxt_obj: $nxt_src $NXT_VERSION_H
- \$(CC) -c \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
+ \$(PP_CC) \$@
+ \$(v)\$(CC) -c \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
-o $NXT_BUILD_DIR/$nxt_obj \\
$nxt_dep_flags \\
$nxt_src
@@ -136,7 +191,8 @@ nxt_dep_post=`nxt_gen_dep_post`
cat << END >> $NXT_MAKEFILE
$NXT_BUILD_DIR/$nxt_obj: $nxt_src $NXT_VERSION_H
- \$(CC) -c \$(CFLAGS) -DNXT_NCQ_TEST=1 \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
+ \$(PP_CC) \$@
+ \$(v)\$(CC) -c \$(CFLAGS) -DNXT_NCQ_TEST=1 \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
-o $NXT_BUILD_DIR/$nxt_obj \\
$nxt_dep_flags \\
$nxt_src
@@ -154,7 +210,8 @@ nxt_dep_post=`nxt_gen_dep_post`
cat << END >> $NXT_MAKEFILE
$NXT_BUILD_DIR/$nxt_obj: $nxt_src $NXT_VERSION_H
- \$(CC) -c \$(CFLAGS) -DNXT_NCQ_TEST=0 \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
+ \$(PP_CC) \$@
+ \$(v)\$(CC) -c \$(CFLAGS) -DNXT_NCQ_TEST=0 \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
-o $NXT_BUILD_DIR/$nxt_obj \\
$nxt_dep_flags \\
$nxt_src
@@ -192,14 +249,16 @@ tests: $NXT_BUILD_DIR/tests $NXT_BUILD_DIR/utf8_file_name_test \\
$NXT_BUILD_DIR/tests: \$(NXT_TEST_OBJS) \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC
- \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/tests \\
+ \$(PP_LD) \$@
+ \$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/tests \\
\$(CFLAGS) \$(NXT_TEST_OBJS) \\
$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/lib/$NXT_LIB_STATIC
- \$(CC) \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
+ \$(PP_LD) \$@
+ \$(v)\$(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/lib/$NXT_LIB_STATIC \\
@@ -207,21 +266,24 @@ $NXT_BUILD_DIR/utf8_file_name_test: $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\
$NXT_BUILD_DIR/ncq_test: $NXT_BUILD_DIR/src/test/nxt_ncq_test.o \\
$NXT_BUILD_DIR/lib/$NXT_LIB_STATIC
- \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/ncq_test \\
+ \$(PP_LD) \$@
+ \$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/ncq_test \\
\$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_ncq_test.o \\
$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/lib/$NXT_LIB_STATIC
- \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/vbcq_test \\
+ \$(PP_LD) \$@
+ \$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/vbcq_test \\
\$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_vbcq_test.o \\
$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/lib/$NXT_LIB_UNIT_STATIC
- \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_app_test \\
+ \$(PP_LD) \$@
+ \$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_app_test \\
\$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_unit_app_test.o \\
$NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \\
$NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS
@@ -229,7 +291,8 @@ $NXT_BUILD_DIR/unit_app_test: $NXT_BUILD_DIR/src/test/nxt_unit_app_test.o \\
$NXT_BUILD_DIR/unit_websocket_chat: \\
$NXT_BUILD_DIR/src/test/nxt_unit_websocket_chat.o \\
$NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC
- \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_websocket_chat \\
+ \$(PP_LD) \$@
+ \$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_websocket_chat \\
\$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_unit_websocket_chat.o \\
$NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \\
$NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS
@@ -237,7 +300,8 @@ $NXT_BUILD_DIR/unit_websocket_chat: \\
$NXT_BUILD_DIR/unit_websocket_echo: \\
$NXT_BUILD_DIR/src/test/nxt_unit_websocket_echo.o \\
$NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC
- \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_websocket_echo \\
+ \$(PP_LD) \$@
+ \$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_websocket_echo \\
\$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_unit_websocket_echo.o \\
$NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \\
$NXT_LD_OPT $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS
@@ -296,7 +360,8 @@ cat << END >> $NXT_MAKEFILE
$NXT_BUILD_DIR/sbin/$NXT_DAEMON: $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
\$(NXT_OBJS)
- \$(NXT_EXEC_LINK) -o \$@ \$(CFLAGS) \\
+ \$(PP_LD) \$@
+ \$(v)\$(NXT_EXEC_LINK) -o \$@ \$(CFLAGS) \\
\$(NXT_OBJS) $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS
@@ -309,7 +374,8 @@ cat << END >> $NXT_MAKEFILE
$NXT_BUILD_DIR/share/man/man8/unitd.8: docs/man/man8/unitd.8.in \\
$NXT_BUILD_DIR/include/nxt_auto_config.h
- sed -e "s|%%ERROR_LOG_PATH%%|$NXT_LOG|" \\
+ \$(PP_SED) \$@
+ \$(v)sed -e "s|%%ERROR_LOG_PATH%%|$NXT_LOG|" \\
-e "s|%%PID_PATH%%|$NXT_PID|" \\
-e "s|%%SOCKET_PATH%%|$NXT_CONTROL|" \\
< docs/man/man8/unitd.8.in > \$@
@@ -328,7 +394,8 @@ do
cat << END >> $NXT_MAKEFILE
$NXT_BUILD_DIR/$nxt_obj: $nxt_src $NXT_VERSION_H
- \$(CC) -c \$(CFLAGS) \$(NXT_INCS) \\
+ \$(PP_CC) \$@
+ \$(v)\$(CC) -c \$(CFLAGS) \$(NXT_INCS) \\
$NXT_LIB_AUX_CFLAGS \\
-o $NXT_BUILD_DIR/$nxt_obj \\
$nxt_dep_flags \\
@@ -367,8 +434,6 @@ ${NXT_DAEMON}-install: $NXT_DAEMON install-check
|| install -d \$(DESTDIR)$NXT_STATEDIR
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 \
@@ -441,7 +506,8 @@ END
cat << END >> $NXT_MAKEFILE
$NXT_BUILD_DIR/share/pkgconfig/unit.pc: src/unit.pc.in
- sed -e "s|@PREFIX@|$NXT_PREFIX|" \\
+ \$(PP_SED) \$@
+ \$(v)sed -e "s|@PREFIX@|$NXT_PREFIX|" \\
-e "s|@LIBDIR@|$NXT_LIBDIR|" \\
-e "s|@CFLAGS@|-I$NXT_INCLUDEDIR|" \\
-e "s|@VERSION@|\$(NXT_VERSION)|" \\
@@ -451,7 +517,8 @@ $NXT_BUILD_DIR/share/pkgconfig/unit.pc: src/unit.pc.in
< src/unit.pc.in > \$@
$NXT_BUILD_DIR/share/pkgconfig/unit-uninstalled.pc: src/unit.pc.in
- sed -e "s|@PREFIX@|$(pwd)/$NXT_BUILD_DIR|" \\
+ \$(PP_SED) \$@
+ \$(v)sed -e "s|@PREFIX@|$(pwd)/$NXT_BUILD_DIR|" \\
-e "s|@LIBDIR@|$(pwd)/$NXT_BUILD_DIR/lib|" \\
-e "s|@CFLAGS@|-I$(pwd)/src -I$(pwd)$NXT_BUILD_DIR/include|" \\
-e "s|@VERSION@|\$(NXT_VERSION)|" \\
@@ -472,4 +539,16 @@ include $NXT_MAKEFILE
clean:
rm -rf $NXT_BUILD_DIR *.dSYM Makefile
+.PHONY: help
+help:
+ @echo "Variables to control make/build behaviour:"
+ @echo
+ @echo " make V=1 ... - Enables verbose output"
+ @echo " make D=1 ... - Enables debug builds (-O0)"
+ @echo " make E=0 ... - Disables -Werror"
+ @echo
+ @echo " make EXTRA_CFLAGS= ... - Add extra compiler options"
+ @echo
+ @echo " Variables can be combined."
+
END