Lines Matching +full:- +full:- +full:quiet
2 # Use of this source code is governed by a BSD-style license that can be
10 # https://chromium.googlesource.com/chromiumos/platform2/+/master/common-mk
22 # 2. In your top-level Makefile, place "include common.mk" at the top
32 # - cc_binary, cxx_binary provide standard compilation steps for binaries
33 # - cxx_library, cc_library provide standard compilation steps for
36 # - update_archive creates/updates a given .a target
39 # - CXX_BINARY, CC_BINARY, CC_STATIC_BINARY, CXX_STATIC_BINARY
40 # - CXX_LIBRARY, CC_LIBRARY, CC_STATIC_LIBRARY, CXX_STATIC_LIBRARY
41 # - E.g., CXX_BINARY(mahbinary): foo.o
42 # - object.depends targets may be used when a prerequisite is required for an
46 # - TEST(binary) or TEST(CXX_BINARY(binary)) may be used as a prerequisite
48 # - CLEAN(file_or_dir) dependency can be added to 'clean'.
53 # - For C source files
55 # - For C++ source files
59 # - all - Your desired targets should be given
60 # - tests - Any TEST(test_binary) targets should be given
61 # - FORCE - force the given target to run regardless of changes
65 # - COLOR=[0|1] to set ANSI color output (default: 1)
66 # - VERBOSE=[0|1] to hide/show commands (default: 0)
67 # - MODE=[opt|dbg|profiling] (default: opt)
68 # opt - Enable optimizations for release builds
69 # dbg - Turn down optimization for debugging
70 # profiling - Turn off optimization and turn on profiling/coverage
72 # - ARCH=[x86|arm|supported qemu name] (default: from portage or uname -m)
73 # - SPLITDEBUG=[0|1] splits debug info in target.debug (default: 0)
75 # - NOSTRIP=[0|1] determines if binaries are stripped. (default: 1)
76 # NOSTRIP=0 and MODE=opt will also drop -g from the CFLAGS.
77 # - VALGRIND=[0|1] runs tests under valgrind (default: 0)
78 # - OUT=/path/to/builddir puts all output in given path (default: $PWD)
79 # - VALGRIND_ARGS="" supplies extra memcheck arguments
81 # Per-target(-ish) variable:
82 # - NEEDS_ROOT=[0|1] allows a TEST() target to run with root.
84 # - NEEDS_MOUNTS=[0|1] allows a TEST() target running on QEmu to get
88 # - Directories or files with spaces in them DO NOT get along with GNU Make.
91 # - External CXXFLAGS and CFLAGS should be passed via the environment since
93 # - Our version of GNU Make doesn't seem to support the 'private' variable
105 ARCH ?= $(shell uname -m)
109 # make -C $SRCDIR # will create ./build-$(MODE)
111 # make -C $SRCDIR OUT=$PWD
112 # This variable is extended on subdir calls and doesn't need to be re-called.
116 $(shell mkdir -p "$(OUT)")
119 # Ensure a command-line supplied OUT has a slash
127 # common-mk/BASE_VER file.
129 BASE_VER := $(shell cat $(SRC)/../common-mk/BASE_VER)
133 # Re-start in the $(OUT) directory if we're not there.
134 # We may be invoked using -C or bare and we need to ensure behavior
157 QUIET = @
159 QUIET=
174 $(MAKE) -r -I "$(SRC)" -f "$(CURDIR)/Makefile" \
177 pass-to-subcall := 1
180 ifeq ($(pass-to-subcall),)
183 MODULES_LIST := $(filter-out Makefile %.d,$(MAKEFILE_LIST))
184 ifeq ($(words $(filter-out Makefile common.mk %.d $(SRC)/Makefile \
187 # All the top-level defines outside of module.mk.
195 $(if $(wildcard $(dir $1)),$2,$(QUIET)mkdir -p "$(dir $1)")
202 $(QUIET)# Create the archive in one step to avoid parallel use accessing it
203 $(QUIET)# before all the symbols are present.
206 -> $(subst $(SRC)/,,$(TARGET_OR_MEMBER))"
207 $(QUIET)$(AR) rcs $(TARGET_OR_MEMBER) \
211 # Default compile from objects using pre-requisites but filters out
221 # Default compile from objects using pre-requisites but filters out
234 $(QUIET)($(ECHO) -n '$(COLOR_RED)CLEANFILE$(COLOR_RESET) ' && \
241 $(QUIET)# $(1) not empty [$(wildcard $(1)/*)]. Not deleting.,
242 $(QUIET)($(ECHO) -n '$(COLOR_RED)CLEANDIR$(COLOR_RESET) ' && \
262 $(eval $(call override_var,PKG_CONFIG,pkg-config))
267 ECHO = /bin/echo -e
286 $($(2)) $($(4)) -x $(3) $(LDFLAGS) $(5) - $(6) -o /dev/null > /dev/null 2>&1 \
310 SSP_CFLAGS := $(call check_cc,-fstack-protector-strong)
312 SSP_CFLAGS := $(call check_cc,-fstack-protector-all)
316 # CXXFLAGS += -mahflag # Append to the list
317 # CXXFLAGS := -mahflag $(CXXFLAGS) # Prepend to the list
318 # CXXFLAGS := $(filter-out badflag,$(CXXFLAGS)) # Filter out a value
320 COMMON_CFLAGS-gcc := -fvisibility=internal -ggdb3 -Wa,--noexecstack
321 COMMON_CFLAGS-clang := -fvisibility=hidden -ggdb
322 COMMON_CFLAGS := -Wall -Wunused -Wno-unused-parameter -Werror -Wformat=2 \
323 -fno-strict-aliasing $(SSP_CFLAGS) -O1
324 CXXFLAGS += $(COMMON_CFLAGS) $(COMMON_CFLAGS-$(CXXDRIVER)) -std=gnu++14
325 CFLAGS += $(COMMON_CFLAGS) $(COMMON_CFLAGS-$(CDRIVER)) -std=gnu11
326 CPPFLAGS += -D_FORTIFY_SOURCE=2
329 CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
333 CXXFLAGS := $(CXXFLAGS) -fno-exceptions -fno-unwind-tables \
334 -fno-asynchronous-unwind-tables
339 CFLAGS := $(filter-out -O1,$(CFLAGS)) -O2
340 CXXFLAGS := $(filter-out -O1,$(CXXFLAGS)) -O2
341 # Only drop -g* if symbols aren't desired.
343 # TODO: do we want -fomit-frame-pointer on x86?
344 CFLAGS := $(filter-out -ggdb3,$(CFLAGS))
345 CXXFLAGS := $(filter-out -ggdb3,$(CXXFLAGS))
350 CFLAGS := $(CFLAGS) -O0 -g --coverage
351 CXXFLAGS := $(CXXFLAGS) -O0 -g --coverage
352 LDFLAGS := $(LDFLAGS) --coverage
355 LDFLAGS := $(LDFLAGS) -Wl,-z,relro -Wl,-z,noexecstack -Wl,-z,now
366 QUIET = @
368 QUIET=
375 # Useful for dealing with pie-broken toolchains.
377 OBJ_PIE_FLAG = -fPIE
378 COMPILE_PIE_FLAG = -pie
390 # Default compile from objects using pre-requisites but filters out
391 # all non-.o files.
395 $(QUIET)$($(1)) $(COMPILE_PIE_FLAGS) -o $(TARGET_OR_MEMBER) \
398 $(foreach so,$(filter %.so,$^),-L$(dir $(so)) \
399 -l$(patsubst lib%,%,$(basename $(notdir $(so))))) \
402 @$(ECHO) -n "BIN "
404 @$(ECHO) " $(COLOR_YELLOW)-----$(COLOR_RESET)"
411 # Then add -Wl,-soname,$@.$(PV) ?
413 # Default compile from objects using pre-requisites but filters out
414 # all non-.o values. (Remember to add -L$(OUT) -llib)
419 $(QUIET)$($(1)) -shared -Wl,-E -o $(TARGET_OR_MEMBER) \
421 $(if $(filter %.a,$^),-Wl$(COMMA)--whole-archive,) \
423 $(foreach a,$(filter %.a,$^),-L$(dir $(a)) \
424 -l$(patsubst lib%,%,$(basename $(notdir $(a))))) \
425 $(foreach so,$(filter %.so,$^),-L$(dir $(so)) \
426 -l$(patsubst lib%,%,$(basename $(notdir $(so))))) \
429 @$(ECHO) -n "LIB $(COLOR_GREEN)"
431 @$(ECHO) " $(COLOR_YELLOW)-----$(COLOR_RESET)"
440 $(if $(filter 1,$(SPLITDEBUG)), @$(ECHO) -n "DEBUG "; \
444 $(QUIET)$(OBJCOPY) --only-keep-debug "$(TARGET_OR_MEMBER)" \
446 $(if $(filter-out dbg,$(MODE)),$(QUIET)$(STRIP) --strip-unneeded \
463 $(if $(shell find $^ -cnewer "$%" 2>/dev/null),$(1))
484 $(call old_or_no_timestamp,$(call cxx_binary,-static))
489 $(call old_or_no_timestamp,$(call cc_binary,-static))
540 $(QUIET)# CLEAN($%) meta-target called
541 $(if $(filter-out $(PWD)/,$(dir $(abspath $(TARGET_OR_MEMBER)))), \
543 $(QUIET)# Not deleting $(dir $(abspath $(TARGET_OR_MEMBER))) yet.)
547 # Top-level objects and pattern rules
557 # Note, the catch-all pattern rules don't work in subdirectories because
558 # we're building from the $(OUT) directory. At the top-level (here) they will
566 # not match without further magic on a per-subdirectory basis.
583 $$(basename $$@),$$($(4)) $$(CPPFLAGS) -fPIC)
588 $$(QUIET)touch "$$@"
592 $$(QUIET)touch "$$@"
598 @$(ECHO) "$(1) $(subst $(SRC)/,,$<) -> $(2).o"
600 $(QUIET)$($(1)) -c -MD -MF $(2).d $(3) -o $(2).o $<
601 $(QUIET)sed -i -e :j -e '$$!N;s|\\\s*\n| |;tj' \
602 -e 's|^\(.*\s*:\s*\)\(.*\)$$|\1 $$\(wildcard \2\)|' $(2).d
610 # These may already be handled by '-r', but let's keep it to be safe.
626 HOST_ARCH ?= $(shell uname -m)
630 # if uname -m runs and you get x86_64, then this subst
633 QEMU_ARCH := $(subst x86,i386,$(ARCH)) # x86 -> i386
635 QEMU_ARCH := $(subst amd64,x86_64,$(ARCH)) # amd64 -> x86_64
641 # If we're cross-compiling, try to use qemu for running the tests.
644 $(info SYSROOT not defined. qemu-based testing disabled)
649 # Allow 64-bit hosts to run 32-bit without qemu.
669 # Default to / when all the empty-sysroot logic is done.
673 QEMU_NAME = qemu-$(QEMU_ARCH)
680 …f\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/build/bin/qemu-arm:"
690 $(info - OUT=$(OUT))
691 $(info - SRC=$(SRC))
692 $(info - MODE=$(MODE))
693 $(info - SPLITDEBUG=$(SPLITDEBUG))
694 $(info - NOSTRIP=$(NOSTRIP))
695 $(info - VALGRIND=$(VALGRIND))
696 $(info - COLOR=$(COLOR))
697 $(info - CXXEXCEPTIONS=$(CXXEXCEPTIONS))
698 $(info - ARCH=$(ARCH))
699 $(info - QEMU_ARCH=$(QEMU_ARCH))
700 $(info - USE_QEMU=$(USE_QEMU))
701 $(info - NEEDS_ROOT=$(NEEDS_ROOT))
702 $(info - NEEDS_MOUNTS=$(NEEDS_MOUNTS))
703 $(info - SYSROOT=$(SYSROOT))
713 $(QUIET)(test -z "$^" && \
715 $(QUIET)test -n "$^"
723 $(QUIET)FILES=""; \
724 for GCNO in `find . -name "*.gcno"`; do \
726 if [ -e $${GCDA} ]; then \
730 if [ -n "$${FILES}" ]; then \
731 gcov -l $${FILES}; \
732 lcov --capture --directory . \
733 --output-file=lcov-coverage.info; \
734 genhtml lcov-coverage.info \
735 --output-directory lcov-html; \
745 $(QUIET)$(ECHO) "QEMU Preparing $(QEMU_NAME)"
751 $(QUIET)if [[ ! -e $(QEMU_SYSROOT_PATH) || \
752 `stat -c %i $(QEMU_SRC_PATH)` != `stat -c %i $(QEMU_SYSROOT_PATH)` \
754 $(ROOT_CMD) ln -Tf $(QEMU_SRC_PATH) $(QEMU_SYSROOT_PATH).$$$$; \
755 $(ROOT_CMD) mv -Tf $(QEMU_SYSROOT_PATH).$$$$ $(QEMU_SYSROOT_PATH); \
760 @# There may still be some race conditions here where one script de-registers
761 @# and another script starts executing before it gets re-registered, however
763 -$(QUIET)[[ -e $(QEMU_REGISTER_PATH) ]] || \
764 $(ROOT_CMD) mount binfmt_misc -t binfmt_misc \
767 -$(QUIET)if [[ -e $(QEMU_BINFMT_PATH) && \
770 echo -1 | $(ROOT_CMD) tee $(QEMU_BINFMT_PATH) >/dev/null; \
773 -$(if $(QEMU_MAGIC_$(ARCH)),$(QUIET)[[ -e $(QEMU_BINFMT_PATH) ]] || \
779 # TODO(wad) Move to -L $(SYSROOT) and fakechroot when qemu-user
794 -drop-ld-preload \
795 -E LD_LIBRARY_PATH="$(QEMU_LDPATH):$(patsubst $(OUT),,$(LD_DIRS))" \
796 -E HOME="$(HOME)" -E SRC="$(SRC)" --
811 VALGRIND_CMD = /usr/bin/valgrind --tool=memcheck $(VALGRIND_ARGS) --
816 $(QUIET)$(call TEST_setup)
817 $(QUIET)$(call TEST_run)
818 $(QUIET)$(call TEST_teardown)
819 $(QUIET)exit $$(cat $(OUT)$(TARGET_OR_MEMBER).status.test)
827 @$(ECHO) -n "TEST $(TARGET_OR_MEMBER) "
829 $(QUIET)# Setup a target-specific results file
830 $(QUIET)(echo > $(OUT)$(TARGET_OR_MEMBER).setup.test)
831 $(QUIET)(echo 1 > $(OUT)$(TARGET_OR_MEMBER).status.test)
832 $(QUIET)(echo > $(OUT)$(TARGET_OR_MEMBER).cleanup.test)
833 $(QUIET)# No setup if we are not using QEMU
834 $(QUIET)# TODO(wad) this is racy until we use a vfs namespace
836 $(QUIET)(echo "mkdir -p '$(SYSROOT)/proc' '$(SYSROOT)/dev' \
840 $(QUIET)(echo "$(MOUNT_CMD) --bind /mnt/host/source \
844 $(QUIET)(echo "$(MOUNT_CMD) --bind /proc '$(SYSROOT)/proc'" \
847 $(QUIET)(echo "$(MOUNT_CMD) --bind /dev '$(SYSROOT)/dev'" \
852 @$(ECHO) -n "TEST $(TARGET_OR_MEMBER) "
854 $(call if_qemu, $(QUIET)$(SHELL) "$(OUT)$(TARGET_OR_MEMBER).cleanup.test")
862 @$(ECHO) -n "TEST $(TARGET_OR_MEMBER) "
864 $(QUIET)(echo 1 > "$(OUT)$(TARGET_OR_MEMBER).status.test")
865 $(QUIET)(echo $(ROOT_CMD) SRC="$(SRC)" $(QEMU_CMD) $(VALGRIND_CMD) \
867 $(if $(filter-out 0,$(words $(GTEST_ARGS.real))),$(GTEST_ARGS.real),\
869 -$(QUIET)$(call if_qemu,$(SUDO_CMD) $(UNSHARE_CMD) -m) $(SHELL) \
883 clean: CLEAN($(OUT)lcov-coverage.info) CLEAN($(OUT)lcov-html)
886 $(QUIET)# Always delete the containing directory last.
912 $(dir $(lastword $(filter-out %common.mk,$(MAKEFILE_LIST)))))
928 clean: CLEAN($(OUT)$(MODULE)/*.gcov) CLEAN($(OUT)lcov-coverage.info)
929 clean: CLEAN($(OUT)lcov-html)
952 endif ## pass-to-subcall wrapper for relocating the call directory