Linux Audio

Check our new training course

Loading...
v4.10.11
  1###
  2# build: Generic definitions
  3#
  4#  Lots of this code have been borrowed or heavily inspired from parts
  5#  of kbuild code, which is not credited, but mostly developed by:
  6#
  7#  Copyright (C) Sam Ravnborg <sam@mars.ravnborg.org>, 2015
  8#  Copyright (C) Linus Torvalds <torvalds@linux-foundation.org>, 2015
  9#
 10
 11###
 12# Convenient variables
 13comma   := ,
 14squote  := '
 
 15
 16###
 17# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
 18dot-target = $(dir $@).$(notdir $@)
 19
 20###
 21# filename of target with directory and extension stripped
 22basetarget = $(basename $(notdir $@))
 23
 24###
 25# The temporary file to save gcc -MD generated dependencies must not
 26# contain a comma
 27depfile = $(subst $(comma),_,$(dot-target).d)
 28
 29###
 30# Check if both arguments has same arguments. Result is empty string if equal.
 31arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
 32                    $(filter-out $(cmd_$@),   $(cmd_$(1))) )
 33
 34###
 35# Escape single quote for use in echo statements
 36escsq = $(subst $(squote),'\$(squote)',$1)
 37
 38# Echo command
 39# Short version is used, if $(quiet) equals `quiet_', otherwise full one.
 40echo-cmd = $(if $($(quiet)cmd_$(1)),\
 41           echo '  $(call escsq,$($(quiet)cmd_$(1)))';)
 42
 43###
 44# Replace >$< with >$$< to preserve $ when reloading the .cmd file
 45# (needed for make)
 46# Replace >#< with >\#< to avoid starting a comment in the .cmd file
 47# (needed for make)
 48# Replace >'< with >'\''< to be able to enclose the whole string in '...'
 49# (needed for the shell)
 50make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1)))))
 51
 52###
 53# Find any prerequisites that is newer than target or that does not exist.
 54# PHONY targets skipped in both cases.
 55any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
 56
 57###
 58# Copy dependency data into .cmd file
 59#  - gcc -M dependency info
 60#  - command line to create object 'cmd_object :='
 61dep-cmd = $(if $(wildcard $(fixdep)),                                           \
 62           $(fixdep) $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;           \
 63           rm -f $(depfile);                                                    \
 64           mv -f $(dot-target).tmp $(dot-target).cmd,                           \
 65           printf '\# cannot find fixdep (%s)\n' $(fixdep) > $(dot-target).cmd; \
 66           printf '\# using basic dep data\n\n' >> $(dot-target).cmd;           \
 67           cat $(depfile) >> $(dot-target).cmd;                                 \
 68           printf '\n%s\n' 'cmd_$@ := $(make-cmd)' >> $(dot-target).cmd)
 69
 70###
 71# if_changed_dep  - execute command if any prerequisite is newer than
 72#                   target, or command line has changed and update
 73#                   dependencies in the cmd file
 74if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)),         \
 75                  @set -e;                                         \
 76                  $(echo-cmd) $(cmd_$(1)) && $(dep-cmd))
 77
 78# if_changed      - execute command if any prerequisite is newer than
 79#                   target, or command line has changed
 80if_changed = $(if $(strip $(any-prereq) $(arg-check)),                   \
 81              @set -e;                                                   \
 82              $(echo-cmd) $(cmd_$(1));                                   \
 83              printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
 84
 85###
 86# C flags to be used in rule definitions, includes:
 87# - depfile generation
 88# - global $(CFLAGS)
 89# - per target C flags
 90# - per object C flags
 91# - BUILD_STR macro to allow '-D"$(variable)"' constructs
 92c_flags_1 = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
 93c_flags_2 = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(c_flags_1))
 94c_flags   = $(filter-out $(CFLAGS_REMOVE_$(obj)), $(c_flags_2))
 95cxx_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj))
 96
 97###
 98## HOSTCC C flags
 99
100host_c_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CHOSTFLAGS) -D"BUILD_STR(s)=\#s" $(CHOSTFLAGS_$(basetarget).o) $(CHOSTFLAGS_$(obj))
v4.17
  1###
  2# build: Generic definitions
  3#
  4#  Lots of this code have been borrowed or heavily inspired from parts
  5#  of kbuild code, which is not credited, but mostly developed by:
  6#
  7#  Copyright (C) Sam Ravnborg <sam@mars.ravnborg.org>, 2015
  8#  Copyright (C) Linus Torvalds <torvalds@linux-foundation.org>, 2015
  9#
 10
 11###
 12# Convenient variables
 13comma   := ,
 14squote  := '
 15pound   := \#
 16
 17###
 18# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
 19dot-target = $(dir $@).$(notdir $@)
 20
 21###
 22# filename of target with directory and extension stripped
 23basetarget = $(basename $(notdir $@))
 24
 25###
 26# The temporary file to save gcc -MD generated dependencies must not
 27# contain a comma
 28depfile = $(subst $(comma),_,$(dot-target).d)
 29
 30###
 31# Check if both arguments has same arguments. Result is empty string if equal.
 32arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
 33                    $(filter-out $(cmd_$@),   $(cmd_$(1))) )
 34
 35###
 36# Escape single quote for use in echo statements
 37escsq = $(subst $(squote),'\$(squote)',$1)
 38
 39# Echo command
 40# Short version is used, if $(quiet) equals `quiet_', otherwise full one.
 41echo-cmd = $(if $($(quiet)cmd_$(1)),\
 42           echo '  $(call escsq,$($(quiet)cmd_$(1)))';)
 43
 44###
 45# Replace >$< with >$$< to preserve $ when reloading the .cmd file
 46# (needed for make)
 47# Replace >#< with >$(pound)< to avoid starting a comment in the .cmd file
 48# (needed for make)
 49# Replace >'< with >'\''< to be able to enclose the whole string in '...'
 50# (needed for the shell)
 51make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))))
 52
 53###
 54# Find any prerequisites that is newer than target or that does not exist.
 55# PHONY targets skipped in both cases.
 56any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
 57
 58###
 59# Copy dependency data into .cmd file
 60#  - gcc -M dependency info
 61#  - command line to create object 'cmd_object :='
 62dep-cmd = $(if $(wildcard $(fixdep)),                                           \
 63           $(fixdep) $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;           \
 64           rm -f $(depfile);                                                    \
 65           mv -f $(dot-target).tmp $(dot-target).cmd,                           \
 66           printf '\# cannot find fixdep (%s)\n' $(fixdep) > $(dot-target).cmd; \
 67           printf '\# using basic dep data\n\n' >> $(dot-target).cmd;           \
 68           cat $(depfile) >> $(dot-target).cmd;                                 \
 69           printf '\n%s\n' 'cmd_$@ := $(make-cmd)' >> $(dot-target).cmd)
 70
 71###
 72# if_changed_dep  - execute command if any prerequisite is newer than
 73#                   target, or command line has changed and update
 74#                   dependencies in the cmd file
 75if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)),         \
 76                  @set -e;                                         \
 77                  $(echo-cmd) $(cmd_$(1)) && $(dep-cmd))
 78
 79# if_changed      - execute command if any prerequisite is newer than
 80#                   target, or command line has changed
 81if_changed = $(if $(strip $(any-prereq) $(arg-check)),                   \
 82              @set -e;                                                   \
 83              $(echo-cmd) $(cmd_$(1));                                   \
 84              printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
 85
 86###
 87# C flags to be used in rule definitions, includes:
 88# - depfile generation
 89# - global $(CFLAGS)
 90# - per target C flags
 91# - per object C flags
 92# - BUILD_STR macro to allow '-D"$(variable)"' constructs
 93c_flags_1 = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
 94c_flags_2 = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(c_flags_1))
 95c_flags   = $(filter-out $(CFLAGS_REMOVE_$(obj)), $(c_flags_2))
 96cxx_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj))
 97
 98###
 99## HOSTCC C flags
100
101host_c_flags = -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CHOSTFLAGS) -D"BUILD_STR(s)=\#s" $(CHOSTFLAGS_$(basetarget).o) $(CHOSTFLAGS_$(obj))