]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - tools/lib/lockdep/Makefile
tools/lib/lockdep: Remove double-quotes from soname
[mirror_ubuntu-bionic-kernel.git] / tools / lib / lockdep / Makefile
CommitLineData
5634bd7d
SL
1# file format version
2FILE_VERSION = 1
3
0041898e 4LIBLOCKDEP_VERSION=$(shell make --no-print-directory -sC ../../.. kernelversion)
5634bd7d
SL
5
6# Makefiles suck: This macro sets a default value of $(2) for the
7# variable named by $(1), unless the variable has been set by
8# environment or command line. This is necessary for CC and AR
9# because make sets default values, so the simpler ?= approach
10# won't work as expected.
11define allow-override
12 $(if $(or $(findstring environment,$(origin $(1))),\
13 $(findstring command line,$(origin $(1)))),,\
14 $(eval $(1) = $(2)))
15endef
16
d1e40e59 17# Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix.
5634bd7d
SL
18$(call allow-override,CC,$(CROSS_COMPILE)gcc)
19$(call allow-override,AR,$(CROSS_COMPILE)ar)
d1e40e59 20$(call allow-override,LD,$(CROSS_COMPILE)ld)
5634bd7d
SL
21
22INSTALL = install
23
24# Use DESTDIR for installing into a different root directory.
25# This is useful for building a package. The program will be
26# installed in this directory as if it was the root directory.
27# Then the build tool can move it later.
28DESTDIR ?=
29DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
30
31prefix ?= /usr/local
32libdir_relative = lib
33libdir = $(prefix)/$(libdir_relative)
34bindir_relative = bin
35bindir = $(prefix)/$(bindir_relative)
36
37export DESTDIR DESTDIR_SQ INSTALL
38
9244e2c6
JO
39MAKEFLAGS += --no-print-directory
40
41include ../../scripts/Makefile.include
42
5634bd7d
SL
43# copy a bit from Linux kbuild
44
45ifeq ("$(origin V)", "command line")
46 VERBOSE = $(V)
47endif
48ifndef VERBOSE
49 VERBOSE = 0
50endif
51
9244e2c6 52ifeq ($(srctree),)
e19b7cee 53srctree := $(patsubst %/,%,$(dir $(CURDIR)))
9244e2c6
JO
54srctree := $(patsubst %/,%,$(dir $(srctree)))
55srctree := $(patsubst %/,%,$(dir $(srctree)))
56#$(info Determined 'srctree' to be $(srctree))
5634bd7d
SL
57endif
58
5634bd7d
SL
59# Shell quotes
60libdir_SQ = $(subst ','\'',$(libdir))
61bindir_SQ = $(subst ','\'',$(bindir))
62
9244e2c6
JO
63LIB_IN := $(OUTPUT)liblockdep-in.o
64
5634bd7d 65BIN_FILE = lockdep
9244e2c6 66LIB_FILE = $(OUTPUT)liblockdep.a $(OUTPUT)liblockdep.so.$(LIBLOCKDEP_VERSION)
5634bd7d
SL
67
68CONFIG_INCLUDES =
69CONFIG_LIBS =
70CONFIG_FLAGS =
71
72OBJ = $@
73N =
74
75export Q VERBOSE
76
8baeccdc 77INCLUDES = -I. -I./uinclude -I./include -I../../include $(CONFIG_INCLUDES)
5634bd7d
SL
78
79# Set compile option CFLAGS if not set elsewhere
80CFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING -DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='"$(LIBLOCKDEP_VERSION)"' -rdynamic -O0 -g
9244e2c6 81CFLAGS += -fPIC
db8f7796 82CFLAGS += -Wall
5634bd7d
SL
83
84override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ)
85
86ifeq ($(VERBOSE),1)
87 Q =
5634bd7d
SL
88 print_shared_lib_compile =
89 print_install =
90else
91 Q = @
9244e2c6
JO
92 print_shared_lib_compile = echo ' LD '$(OBJ);
93 print_static_lib_build = echo ' LD '$(OBJ);
94 print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2';
5634bd7d
SL
95endif
96
7c422f55
JO
97all:
98
9244e2c6 99export srctree OUTPUT CC LD CFLAGS V
ab6201d0 100include $(srctree)/tools/build/Makefile.include
5634bd7d
SL
101
102do_compile_shared_library = \
103 ($(print_shared_lib_compile) \
e3addcc0 104 $(CC) --shared $^ -o $@ -lpthread -ldl -Wl,-soname='$(@F)';$(shell ln -sf $(@F) $(@D)/liblockdep.so))
5634bd7d
SL
105
106do_build_static_lib = \
107 ($(print_static_lib_build) \
108 $(RM) $@; $(AR) rcs $@ $^)
109
5634bd7d
SL
110CMD_TARGETS = $(LIB_FILE)
111
112TARGETS = $(CMD_TARGETS)
113
114
7c422f55 115all: fixdep all_cmd
5634bd7d
SL
116
117all_cmd: $(CMD_TARGETS)
118
9244e2c6
JO
119$(LIB_IN): force
120 $(Q)$(MAKE) $(build)=liblockdep
121
ea59f30d 122$(OUTPUT)liblockdep.so.$(LIBLOCKDEP_VERSION): $(LIB_IN)
5634bd7d
SL
123 $(Q)$(do_compile_shared_library)
124
ea59f30d 125$(OUTPUT)liblockdep.a: $(LIB_IN)
5634bd7d
SL
126 $(Q)$(do_build_static_lib)
127
5634bd7d
SL
128tags: force
129 $(RM) tags
130 find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
131 --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
132
133TAGS: force
134 $(RM) TAGS
135 find . -name '*.[ch]' | xargs etags \
136 --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'
137
138define do_install
139 $(print_install) \
140 if [ ! -d '$(DESTDIR_SQ)$2' ]; then \
141 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \
142 fi; \
143 $(INSTALL) $1 '$(DESTDIR_SQ)$2'
144endef
145
146install_lib: all_cmd
147 $(Q)$(call do_install,$(LIB_FILE),$(libdir_SQ))
148 $(Q)$(call do_install,$(BIN_FILE),$(bindir_SQ))
149
150install: install_lib
151
152clean:
ea59f30d 153 $(RM) $(OUTPUT)*.o *~ $(TARGETS) $(OUTPUT)*.a $(OUTPUT)*liblockdep*.so* $(VERSION_FILES) $(OUTPUT).*.d $(OUTPUT).*.cmd
5634bd7d
SL
154 $(RM) tags TAGS
155
5634bd7d
SL
156PHONY += force
157force:
158
159# Declare the contents of the .PHONY variable as phony. We keep that
160# information in a variable so we can use it in if_changed and friends.
161.PHONY: $(PHONY)