on 2d95669 help sign in
searx/utils/makefile.include
140 lines 4.4 kB history raw
1# -*- coding: utf-8; mode: makefile-gmake -*-
3ifeq (,$(wildcard /.lxcenv.mk))
4PHONY += lxc-activate
5lxc-activate:
6 @$(MAKE) -s -f /share/searx/utils/makefile.lxc lxc-activate
7else
8 include /.lxcenv.mk
9endif
11ifeq (,$(wildcard /.lxcenv.mk))
12make-help:
13else
14make-help: lxc-help
15endif
16 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
17 @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
19quiet_cmd_common_clean = CLEAN $@
20 cmd_common_clean = \
21 find . -name '*.orig' -exec rm -f {} + ;\
22 find . -name '*.rej' -exec rm -f {} + ;\
23 find . -name '*~' -exec rm -f {} + ;\
24 find . -name '*.bak' -exec rm -f {} + ;\
26FMT = cat
27ifeq ($(shell which fmt >/dev/null 2>&1; echo $$?), 0)
28FMT = fmt
29endif
31# MS-Windows
33# For a minimal *make-environment*, I'am using the gnu-tools from:
35# - GNU MCU Eclipse Windows Build Tools, which brings 'make', 'rm' etc.
36# https://github.com/gnu-mcu-eclipse/windows-build-tools/releases
38# - git for Windows, which brings 'find', 'grep' etc.
39# https://git-scm.com/download/win
42# normpath
44# System-dependent normalization of the path name
46# usage: $(call normpath,/path/to/file)
48normpath = $1
49ifeq ($(OS),Windows_NT)
50 normpath = $(subst /,\,$1)
51endif
54# stolen from linux/Makefile
57ifeq ("$(origin V)", "command line")
58 KBUILD_VERBOSE = $(V)
59endif
60ifndef KBUILD_VERBOSE
61 KBUILD_VERBOSE = 0
62endif
64ifeq ($(KBUILD_VERBOSE),1)
65 quiet =
66 Q =
67else
68 quiet=quiet_
69 Q = @
70endif
72# stolen from linux/scripts/Kbuild.include
75# Convenient variables
76comma := ,
77quote := "
78#" this comment is only for emacs highlighting
79squote := '
80#' this comment is only for emacs highlighting
81empty :=
82space := $(empty) $(empty)
83space_escape := _-_SPACE_-_
85# Find any prerequisites that is newer than target or that does not exist.
86# PHONY targets skipped in both cases.
87any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
89###
90# why - tell why a a target got build
91# enabled by make V=2
92# Output (listed in the order they are checked):
93# (1) - due to target is PHONY
94# (2) - due to target missing
95# (3) - due to: file1.h file2.h
96# (4) - due to command line change
97# (5) - due to missing .cmd file
98# (6) - due to target not in $(targets)
99# (1) PHONY targets are always build
100# (2) No target, so we better build it
101# (3) Prerequisite is newer than target
102# (4) The command line stored in the file named dir/.target.cmd
103# differed from actual command line. This happens when compiler
104# options changes
105# (5) No dir/.target.cmd file (used to store command line)
106# (6) No dir/.target.cmd file and target not listed in $(targets)
107# This is a good hint that there is a bug in the kbuild file
108ifeq ($(KBUILD_VERBOSE),2)
109why = \
110 $(if $(filter $@, $(PHONY)),- due to target is PHONY, \
111 $(if $(wildcard $@), \
112 $(if $(strip $(any-prereq)),- due to: $(any-prereq), \
113 $(if $(arg-check), \
114 $(if $(cmd_$@),- due to command line change, \
115 $(if $(filter $@, $(targets)), \
116 - due to missing .cmd file, \
117 - due to $(notdir $@) not in $$(targets) \
118 ) \
119 ) \
120 ) \
121 ), \
122 - due to target missing \
123 ) \
124 )
126echo-why = $(call escsq, $(strip $(why)))
127endif
129###
130# Escape single quote for use in echo statements
131escsq = $(subst $(squote),'\$(squote)',$1)
133# echo command.
134# Short version is used, if $(quiet) equals `quiet_', otherwise full one.
135echo-cmd = $(if $($(quiet)cmd_$(1)),echo '$(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
137# printing commands
138cmd = @$(echo-cmd) $(cmd_$(1))
140.PHONY: $(PHONY)