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
104 ARCH ?= $(shell uname -m)
108 # make -C $SRCDIR # will create ./build-$(MODE)
110 # make -C $SRCDIR OUT=$PWD
111 # This variable is extended on subdir calls and doesn't need to be re-called.
115 $(shell mkdir -p "$(OUT)")
118 # Ensure a command-line supplied OUT has a slash
126 # common-mk/BASE_VER file.
128 BASE_VER := $(shell cat $(SRC)/../common-mk/BASE_VER)
132 # Re-start in the $(OUT) directory if we're not there.
133 # We may be invoked using -C or bare and we need to ensure behavior
156 QUIET = @
158 QUIET=
173 $(MAKE) -r -I "$(SRC)" -f "$(CURDIR)/Makefile" \
176 pass-to-subcall := 1
179 ifeq ($(pass-to-subcall),)
182 MODULES_LIST := $(filter-out Makefile %.d,$(MAKEFILE_LIST))
183 ifeq ($(words $(filter-out Makefile common.mk %.d $(SRC)/Makefile \
186 # All the top-level defines outside of module.mk.
194 $(if $(wildcard $(dir $1)),$2,$(QUIET)mkdir -p "$(dir $1)")
201 $(QUIET)# Create the archive in one step to avoid parallel use accessing it
202 $(QUIET)# before all the symbols are present.
205 -> $(subst $(SRC)/,,$(TARGET_OR_MEMBER))"
206 $(QUIET)$(AR) rcs $(TARGET_OR_MEMBER) \
210 # Default compile from objects using pre-requisites but filters out
220 # Default compile from objects using pre-requisites but filters out
233 $(QUIET)($(ECHO) -n '$(COLOR_RED)CLEANFILE$(COLOR_RESET) ' && \
240 $(QUIET)# $(1) not empty [$(wildcard $(1)/*)]. Not deleting.,
241 $(QUIET)($(ECHO) -n '$(COLOR_RED)CLEANDIR$(COLOR_RESET) ' && \
261 $(eval $(call override_var,PKG_CONFIG,pkg-config))
266 ECHO = /bin/echo -e
285 $($(2)) $($(4)) -x $(3) $(LDFLAGS) $(5) - $(6) -o /dev/null > /dev/null 2>&1 \
309 SSP_CFLAGS := $(call check_cc,-fstack-protector-strong)
311 SSP_CFLAGS := $(call check_cc,-fstack-protector-all)
315 # CXXFLAGS += -mahflag # Append to the list
316 # CXXFLAGS := -mahflag $(CXXFLAGS) # Prepend to the list
317 # CXXFLAGS := $(filter-out badflag,$(CXXFLAGS)) # Filter out a value
319 COMMON_CFLAGS-gcc := -fvisibility=internal -ggdb3 -Wa,--noexecstack
320 COMMON_CFLAGS-clang := -fvisibility=hidden -ggdb
321 COMMON_CFLAGS := -Wall -Werror -fno-strict-aliasing $(SSP_CFLAGS) -O1 -Wformat=2
322 CXXFLAGS += $(COMMON_CFLAGS) $(COMMON_CFLAGS-$(CXXDRIVER))
323 CFLAGS += $(COMMON_CFLAGS) $(COMMON_CFLAGS-$(CDRIVER))
324 CPPFLAGS += -D_FORTIFY_SOURCE=2
327 CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
331 CXXFLAGS := $(CXXFLAGS) -fno-exceptions -fno-unwind-tables \
332 -fno-asynchronous-unwind-tables
337 CFLAGS := $(filter-out -O1,$(CFLAGS)) -O2
338 CXXFLAGS := $(filter-out -O1,$(CXXFLAGS)) -O2
339 # Only drop -g* if symbols aren't desired.
341 # TODO: do we want -fomit-frame-pointer on x86?
342 CFLAGS := $(filter-out -ggdb3,$(CFLAGS))
343 CXXFLAGS := $(filter-out -ggdb3,$(CXXFLAGS))
348 CFLAGS := $(CFLAGS) -O0 -g --coverage
349 CXXFLAGS := $(CXXFLAGS) -O0 -g --coverage
350 LDFLAGS := $(LDFLAGS) --coverage
353 LDFLAGS := $(LDFLAGS) -Wl,-z,relro -Wl,-z,noexecstack -Wl,-z,now
364 QUIET = @
366 QUIET=
373 # Useful for dealing with pie-broken toolchains.
375 OBJ_PIE_FLAG = -fPIE
376 COMPILE_PIE_FLAG = -pie
388 # Default compile from objects using pre-requisites but filters out
389 # all non-.o files.
393 $(QUIET)$($(1)) $(COMPILE_PIE_FLAGS) -o $(TARGET_OR_MEMBER) \
396 $(foreach so,$(filter %.so,$^),-L$(dir $(so)) \
397 -l$(patsubst lib%,%,$(basename $(notdir $(so))))) \
400 @$(ECHO) -n "BIN "
402 @$(ECHO) " $(COLOR_YELLOW)-----$(COLOR_RESET)"
409 # Then add -Wl,-soname,$@.$(PV) ?
411 # Default compile from objects using pre-requisites but filters out
412 # all non-.o values. (Remember to add -L$(OUT) -llib)
417 $(QUIET)$($(1)) -shared -Wl,-E -o $(TARGET_OR_MEMBER) \
419 $(if $(filter %.a,$^),-Wl$(COMMA)--whole-archive,) \
421 $(foreach a,$(filter %.a,$^),-L$(dir $(a)) \
422 -l$(patsubst lib%,%,$(basename $(notdir $(a))))) \
423 $(foreach so,$(filter %.so,$^),-L$(dir $(so)) \
424 -l$(patsubst lib%,%,$(basename $(notdir $(so))))) \
427 @$(ECHO) -n "LIB $(COLOR_GREEN)"
429 @$(ECHO) " $(COLOR_YELLOW)-----$(COLOR_RESET)"
438 $(if $(filter 1,$(SPLITDEBUG)), @$(ECHO) -n "DEBUG "; \
442 $(QUIET)$(OBJCOPY) --only-keep-debug "$(TARGET_OR_MEMBER)" \
444 $(if $(filter-out dbg,$(MODE)),$(QUIET)$(STRIP) --strip-unneeded \
461 $(if $(shell find $^ -cnewer "$%" 2>/dev/null),$(1))
482 $(call old_or_no_timestamp,$(call cxx_binary,-static))
487 $(call old_or_no_timestamp,$(call cc_binary,-static))
535 $(QUIET)# CLEAN($%) meta-target called
536 $(if $(filter-out $(PWD)/,$(dir $(abspath $(TARGET_OR_MEMBER)))), \
538 $(QUIET)# Not deleting $(dir $(abspath $(TARGET_OR_MEMBER))) yet.)
542 # Top-level objects and pattern rules
552 # Note, the catch-all pattern rules don't work in subdirectories because
553 # we're building from the $(OUT) directory. At the top-level (here) they will
561 # not match without further magic on a per-subdirectory basis.
578 $$(basename $$@),$$($(4)) $$(CPPFLAGS) -fPIC)
583 $$(QUIET)touch "$$@"
587 $$(QUIET)touch "$$@"
591 @$(ECHO) "$(1) $(subst $(SRC)/,,$<) -> $(2).o"
593 $(QUIET)$($(1)) -c -MD -MF $(2).d $(3) -o $(2).o $<
594 $(QUIET)# Wrap all the deps in $$(wildcard) so a missing header
595 $(QUIET)# won't cause weirdness. First we remove newlines and \,
596 $(QUIET)# then wrap it.
597 $(QUIET)sed -i -e :j -e '$$!N;s|\\\s*\n| |;tj' \
598 -e 's|^\(.*\s*:\s*\)\(.*\)$$|\1 $$\(wildcard \2\)|' $(2).d
606 # These may already be handled by '-r', but let's keep it to be safe.
622 HOST_ARCH ?= $(shell uname -m)
626 # if uname -m runs and you get x86_64, then this subst
629 QEMU_ARCH := $(subst x86,i386,$(ARCH)) # x86 -> i386
631 QEMU_ARCH := $(subst amd64,x86_64,$(ARCH)) # amd64 -> x86_64
637 # If we're cross-compiling, try to use qemu for running the tests.
640 $(info SYSROOT not defined. qemu-based testing disabled)
645 # Allow 64-bit hosts to run 32-bit without qemu.
665 # Default to / when all the empty-sysroot logic is done.
669 QEMU_NAME = qemu-$(QEMU_ARCH)
676 …f\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/build/bin/qemu-arm:"
686 $(info - OUT=$(OUT))
687 $(info - SRC=$(SRC))
688 $(info - MODE=$(MODE))
689 $(info - SPLITDEBUG=$(SPLITDEBUG))
690 $(info - NOSTRIP=$(NOSTRIP))
691 $(info - VALGRIND=$(VALGRIND))
692 $(info - COLOR=$(COLOR))
693 $(info - CXXEXCEPTIONS=$(CXXEXCEPTIONS))
694 $(info - ARCH=$(ARCH))
695 $(info - QEMU_ARCH=$(QEMU_ARCH))
696 $(info - USE_QEMU=$(USE_QEMU))
697 $(info - NEEDS_ROOT=$(NEEDS_ROOT))
698 $(info - NEEDS_MOUNTS=$(NEEDS_MOUNTS))
699 $(info - SYSROOT=$(SYSROOT))
709 $(QUIET)(test -z "$^" && \
711 $(QUIET)test -n "$^"
719 $(QUIET)FILES=""; \
720 for GCNO in `find . -name "*.gcno"`; do \
722 if [ -e $${GCDA} ]; then \
726 if [ -n "$${FILES}" ]; then \
727 gcov -l $${FILES}; \
728 lcov --capture --directory . \
729 --output-file=lcov-coverage.info; \
730 genhtml lcov-coverage.info \
731 --output-directory lcov-html; \
739 $(QUIET)$(ECHO) "QEMU Preparing $(QEMU_NAME)"
745 $(QUIET)if [[ ! -e $(QEMU_SYSROOT_PATH) || \
746 `stat -c %i $(QEMU_SRC_PATH)` != `stat -c %i $(QEMU_SYSROOT_PATH)` \
748 $(ROOT_CMD) ln -Tf $(QEMU_SRC_PATH) $(QEMU_SYSROOT_PATH).$$$$; \
749 $(ROOT_CMD) mv -Tf $(QEMU_SYSROOT_PATH).$$$$ $(QEMU_SYSROOT_PATH); \
754 @# There may still be some race conditions here where one script de-registers
755 @# and another script starts executing before it gets re-registered, however
757 -$(QUIET)[[ -e $(QEMU_REGISTER_PATH) ]] || \
758 $(ROOT_CMD) mount binfmt_misc -t binfmt_misc \
761 -$(QUIET)if [[ -e $(QEMU_BINFMT_PATH) && \
764 echo -1 | $(ROOT_CMD) tee $(QEMU_BINFMT_PATH) >/dev/null; \
767 -$(if $(QEMU_MAGIC_$(ARCH)),$(QUIET)[[ -e $(QEMU_BINFMT_PATH) ]] || \
773 # TODO(wad) Move to -L $(SYSROOT) and fakechroot when qemu-user
788 -drop-ld-preload \
789 -E LD_LIBRARY_PATH="$(QEMU_LDPATH):$(patsubst $(OUT),,$(LD_DIRS))" \
790 -E HOME="$(HOME)" -E SRC="$(SRC)" --
805 VALGRIND_CMD = /usr/bin/valgrind --tool=memcheck $(VALGRIND_ARGS) --
809 $(QUIET)$(call TEST_setup)
810 $(QUIET)$(call TEST_run)
811 $(QUIET)$(call TEST_teardown)
812 $(QUIET)exit $$(cat $(OUT)$(TARGET_OR_MEMBER).status.test)
816 @$(ECHO) -n "TEST $(TARGET_OR_MEMBER) "
818 $(QUIET)# Setup a target-specific results file
819 $(QUIET)(echo > $(OUT)$(TARGET_OR_MEMBER).setup.test)
820 $(QUIET)(echo 1 > $(OUT)$(TARGET_OR_MEMBER).status.test)
821 $(QUIET)(echo > $(OUT)$(TARGET_OR_MEMBER).cleanup.test)
822 $(QUIET)# No setup if we are not using QEMU
823 $(QUIET)# TODO(wad) this is racy until we use a vfs namespace
825 $(QUIET)(echo "mkdir -p '$(SYSROOT)/proc' '$(SYSROOT)/dev' \
829 $(QUIET)(echo "$(MOUNT_CMD) --bind /mnt/host/source \
833 $(QUIET)(echo "$(MOUNT_CMD) --bind /proc '$(SYSROOT)/proc'" \
836 $(QUIET)(echo "$(MOUNT_CMD) --bind /dev '$(SYSROOT)/dev'" \
841 @$(ECHO) -n "TEST $(TARGET_OR_MEMBER) "
843 $(call if_qemu, $(QUIET)$(SHELL) "$(OUT)$(TARGET_OR_MEMBER).cleanup.test")
851 @$(ECHO) -n "TEST $(TARGET_OR_MEMBER) "
853 $(QUIET)(echo 1 > "$(OUT)$(TARGET_OR_MEMBER).status.test")
854 $(QUIET)(echo $(ROOT_CMD) SRC="$(SRC)" $(QEMU_CMD) $(VALGRIND_CMD) \
856 $(if $(filter-out 0,$(words $(GTEST_ARGS.real))),$(GTEST_ARGS.real),\
858 -$(QUIET)$(call if_qemu,$(SUDO_CMD) $(UNSHARE_CMD) -m) $(SHELL) \
872 clean: CLEAN($(OUT)lcov-coverage.info) CLEAN($(OUT)lcov-html)
875 $(QUIET)# Always delete the containing directory last.
901 $(dir $(lastword $(filter-out %common.mk,$(MAKEFILE_LIST)))))
917 clean: CLEAN($(OUT)$(MODULE)/*.gcov) CLEAN($(OUT)lcov-coverage.info)
918 clean: CLEAN($(OUT)lcov-html)
941 endif ## pass-to-subcall wrapper for relocating the call directory