]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - tools/lib/lockdep/Makefile
Merge remote-tracking branches 'spi/topic/s3c64xx', 'spi/topic/sc18is602', 'spi/topic...
[mirror_ubuntu-jammy-kernel.git] / tools / lib / lockdep / Makefile
CommitLineData
5634bd7d
SL
1# liblockdep version
2LL_VERSION = 0
3LL_PATCHLEVEL = 0
4LL_EXTRAVERSION = 1
5
6# file format version
7FILE_VERSION = 1
8
9MAKEFLAGS += --no-print-directory
10
11
12# Makefiles suck: This macro sets a default value of $(2) for the
13# variable named by $(1), unless the variable has been set by
14# environment or command line. This is necessary for CC and AR
15# because make sets default values, so the simpler ?= approach
16# won't work as expected.
17define allow-override
18 $(if $(or $(findstring environment,$(origin $(1))),\
19 $(findstring command line,$(origin $(1)))),,\
20 $(eval $(1) = $(2)))
21endef
22
23# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
24$(call allow-override,CC,$(CROSS_COMPILE)gcc)
25$(call allow-override,AR,$(CROSS_COMPILE)ar)
26
27INSTALL = install
28
29# Use DESTDIR for installing into a different root directory.
30# This is useful for building a package. The program will be
31# installed in this directory as if it was the root directory.
32# Then the build tool can move it later.
33DESTDIR ?=
34DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
35
36prefix ?= /usr/local
37libdir_relative = lib
38libdir = $(prefix)/$(libdir_relative)
39bindir_relative = bin
40bindir = $(prefix)/$(bindir_relative)
41
42export DESTDIR DESTDIR_SQ INSTALL
43
44# copy a bit from Linux kbuild
45
46ifeq ("$(origin V)", "command line")
47 VERBOSE = $(V)
48endif
49ifndef VERBOSE
50 VERBOSE = 0
51endif
52
53ifeq ("$(origin O)", "command line")
54 BUILD_OUTPUT := $(O)
55endif
56
57ifeq ($(BUILD_SRC),)
58ifneq ($(BUILD_OUTPUT),)
59
60define build_output
61 $(if $(VERBOSE:1=),@)$(MAKE) -C $(BUILD_OUTPUT) \
62 BUILD_SRC=$(CURDIR) -f $(CURDIR)/Makefile $1
63endef
64
65saved-output := $(BUILD_OUTPUT)
66BUILD_OUTPUT := $(shell cd $(BUILD_OUTPUT) && /bin/pwd)
67$(if $(BUILD_OUTPUT),, \
68 $(error output directory "$(saved-output)" does not exist))
69
70all: sub-make
71
72gui: force
73 $(call build_output, all_cmd)
74
75$(filter-out gui,$(MAKECMDGOALS)): sub-make
76
77sub-make: force
78 $(call build_output, $(MAKECMDGOALS))
79
80
81# Leave processing to above invocation of make
82skip-makefile := 1
83
84endif # BUILD_OUTPUT
85endif # BUILD_SRC
86
87# We process the rest of the Makefile if this is the final invocation of make
88ifeq ($(skip-makefile),)
89
7b885341
WN
90srctree := $(realpath $(if $(BUILD_SRC),$(BUILD_SRC),$(CURDIR)))
91objtree := $(realpath $(CURDIR))
5634bd7d
SL
92src := $(srctree)
93obj := $(objtree)
94
95export prefix libdir bindir src obj
96
97# Shell quotes
98libdir_SQ = $(subst ','\'',$(libdir))
99bindir_SQ = $(subst ','\'',$(bindir))
100
101LIB_FILE = liblockdep.a liblockdep.so
102BIN_FILE = lockdep
103
104CONFIG_INCLUDES =
105CONFIG_LIBS =
106CONFIG_FLAGS =
107
108OBJ = $@
109N =
110
111export Q VERBOSE
112
113LIBLOCKDEP_VERSION = $(LL_VERSION).$(LL_PATCHLEVEL).$(LL_EXTRAVERSION)
114
aef5976f 115INCLUDES = -I. -I/usr/local/include -I./uinclude -I./include $(CONFIG_INCLUDES)
5634bd7d
SL
116
117# Set compile option CFLAGS if not set elsewhere
118CFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING -DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='"$(LIBLOCKDEP_VERSION)"' -rdynamic -O0 -g
119
120override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ)
121
122ifeq ($(VERBOSE),1)
123 Q =
124 print_compile =
125 print_app_build =
126 print_fpic_compile =
127 print_shared_lib_compile =
128 print_install =
129else
130 Q = @
131 print_compile = echo ' CC '$(OBJ);
132 print_app_build = echo ' BUILD '$(OBJ);
133 print_fpic_compile = echo ' CC FPIC '$(OBJ);
134 print_shared_lib_compile = echo ' BUILD SHARED LIB '$(OBJ);
135 print_static_lib_build = echo ' BUILD STATIC LIB '$(OBJ);
136 print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2';
137endif
138
139do_fpic_compile = \
140 ($(print_fpic_compile) \
141 $(CC) -c $(CFLAGS) $(EXT) -fPIC $< -o $@)
142
143do_app_build = \
144 ($(print_app_build) \
145 $(CC) $^ -rdynamic -o $@ $(CONFIG_LIBS) $(LIBS))
146
147do_compile_shared_library = \
148 ($(print_shared_lib_compile) \
149 $(CC) --shared $^ -o $@ -lpthread -ldl)
150
151do_build_static_lib = \
152 ($(print_static_lib_build) \
153 $(RM) $@; $(AR) rcs $@ $^)
154
155
156define do_compile
157 $(print_compile) \
158 $(CC) -c $(CFLAGS) $(EXT) $< -o $(obj)/$@;
159endef
160
161$(obj)/%.o: $(src)/%.c
162 $(Q)$(call do_compile)
163
164%.o: $(src)/%.c
165 $(Q)$(call do_compile)
166
167PEVENT_LIB_OBJS = common.o lockdep.o preload.o rbtree.o
168
169ALL_OBJS = $(PEVENT_LIB_OBJS)
170
171CMD_TARGETS = $(LIB_FILE)
172
173TARGETS = $(CMD_TARGETS)
174
175
176all: all_cmd
177
178all_cmd: $(CMD_TARGETS)
179
180liblockdep.so: $(PEVENT_LIB_OBJS)
181 $(Q)$(do_compile_shared_library)
182
183liblockdep.a: $(PEVENT_LIB_OBJS)
184 $(Q)$(do_build_static_lib)
185
186$(PEVENT_LIB_OBJS): %.o: $(src)/%.c
187 $(Q)$(do_fpic_compile)
188
189## make deps
190
191all_objs := $(sort $(ALL_OBJS))
192all_deps := $(all_objs:%.o=.%.d)
193
194# let .d file also depends on the source and header files
195define check_deps
196 @set -e; $(RM) $@; \
197 $(CC) -MM $(CFLAGS) $< > $@.$$$$; \
198 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
199 $(RM) $@.$$$$
200endef
201
202$(all_deps): .%.d: $(src)/%.c
203 $(Q)$(call check_deps)
204
205$(all_objs) : %.o : .%.d
206
207dep_includes := $(wildcard $(all_deps))
208
209ifneq ($(dep_includes),)
210 include $(dep_includes)
211endif
212
213### Detect environment changes
214TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):$(ARCH):$(CROSS_COMPILE)
215
216tags: force
217 $(RM) tags
218 find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
219 --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
220
221TAGS: force
222 $(RM) TAGS
223 find . -name '*.[ch]' | xargs etags \
224 --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'
225
226define do_install
227 $(print_install) \
228 if [ ! -d '$(DESTDIR_SQ)$2' ]; then \
229 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \
230 fi; \
231 $(INSTALL) $1 '$(DESTDIR_SQ)$2'
232endef
233
234install_lib: all_cmd
235 $(Q)$(call do_install,$(LIB_FILE),$(libdir_SQ))
236 $(Q)$(call do_install,$(BIN_FILE),$(bindir_SQ))
237
238install: install_lib
239
240clean:
241 $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d
242 $(RM) tags TAGS
243
244endif # skip-makefile
245
246PHONY += force
247force:
248
249# Declare the contents of the .PHONY variable as phony. We keep that
250# information in a variable so we can use it in if_changed and friends.
251.PHONY: $(PHONY)