diff options
| author | Jiri Olsa <jolsa@kernel.org> | 2015-01-09 11:11:04 -0500 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-02-12 15:56:01 -0500 |
| commit | 9244e2c673fb148abb7706e47b602d009c537c9b (patch) | |
| tree | bc666652f557daddff6d746bacab91768e75a364 /tools/lib | |
| parent | 2d58ab9bdb1958e94f1007882d67c77edda810c0 (diff) | |
tools lib lockdep: Use tools build framework
Move the lockdep library building under tools build framework.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexis Berlemont <alexis.berlemont@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: S. Lockwood-Childs <sjl@vctlabs.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-i0t25buqyo5jfvzpw2347h1h@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib')
| -rw-r--r-- | tools/lib/lockdep/Build | 1 | ||||
| -rw-r--r-- | tools/lib/lockdep/Makefile | 132 |
2 files changed, 24 insertions, 109 deletions
diff --git a/tools/lib/lockdep/Build b/tools/lib/lockdep/Build new file mode 100644 index 000000000000..6f667355b068 --- /dev/null +++ b/tools/lib/lockdep/Build | |||
| @@ -0,0 +1 @@ | |||
| liblockdep-y += common.o lockdep.o preload.o rbtree.o | |||
diff --git a/tools/lib/lockdep/Makefile b/tools/lib/lockdep/Makefile index 52f9279c6c13..8c3340a4b9f8 100644 --- a/tools/lib/lockdep/Makefile +++ b/tools/lib/lockdep/Makefile | |||
| @@ -35,6 +35,10 @@ bindir = $(prefix)/$(bindir_relative) | |||
| 35 | 35 | ||
| 36 | export DESTDIR DESTDIR_SQ INSTALL | 36 | export DESTDIR DESTDIR_SQ INSTALL |
| 37 | 37 | ||
| 38 | MAKEFLAGS += --no-print-directory | ||
| 39 | |||
| 40 | include ../../scripts/Makefile.include | ||
| 41 | |||
| 38 | # copy a bit from Linux kbuild | 42 | # copy a bit from Linux kbuild |
| 39 | 43 | ||
| 40 | ifeq ("$(origin V)", "command line") | 44 | ifeq ("$(origin V)", "command line") |
| @@ -44,56 +48,21 @@ ifndef VERBOSE | |||
| 44 | VERBOSE = 0 | 48 | VERBOSE = 0 |
| 45 | endif | 49 | endif |
| 46 | 50 | ||
| 47 | ifeq ("$(origin O)", "command line") | 51 | ifeq ($(srctree),) |
| 48 | BUILD_OUTPUT := $(O) | 52 | srctree := $(patsubst %/,%,$(dir $(shell pwd))) |
| 53 | srctree := $(patsubst %/,%,$(dir $(srctree))) | ||
| 54 | srctree := $(patsubst %/,%,$(dir $(srctree))) | ||
| 55 | #$(info Determined 'srctree' to be $(srctree)) | ||
| 49 | endif | 56 | endif |
| 50 | 57 | ||
| 51 | ifeq ($(BUILD_SRC),) | ||
| 52 | ifneq ($(BUILD_OUTPUT),) | ||
| 53 | |||
| 54 | define build_output | ||
| 55 | $(if $(VERBOSE:1=),@)$(MAKE) -C $(BUILD_OUTPUT) \ | ||
| 56 | BUILD_SRC=$(CURDIR) -f $(CURDIR)/Makefile $1 | ||
| 57 | endef | ||
| 58 | |||
| 59 | saved-output := $(BUILD_OUTPUT) | ||
| 60 | BUILD_OUTPUT := $(shell cd $(BUILD_OUTPUT) && /bin/pwd) | ||
| 61 | $(if $(BUILD_OUTPUT),, \ | ||
| 62 | $(error output directory "$(saved-output)" does not exist)) | ||
| 63 | |||
| 64 | all: sub-make | ||
| 65 | |||
| 66 | gui: force | ||
| 67 | $(call build_output, all_cmd) | ||
| 68 | |||
| 69 | $(filter-out gui,$(MAKECMDGOALS)): sub-make | ||
| 70 | |||
| 71 | sub-make: force | ||
| 72 | $(call build_output, $(MAKECMDGOALS)) | ||
| 73 | |||
| 74 | |||
| 75 | # Leave processing to above invocation of make | ||
| 76 | skip-makefile := 1 | ||
| 77 | |||
| 78 | endif # BUILD_OUTPUT | ||
| 79 | endif # BUILD_SRC | ||
| 80 | |||
| 81 | # We process the rest of the Makefile if this is the final invocation of make | ||
| 82 | ifeq ($(skip-makefile),) | ||
| 83 | |||
| 84 | srctree := $(realpath $(if $(BUILD_SRC),$(BUILD_SRC),$(CURDIR))) | ||
| 85 | objtree := $(realpath $(CURDIR)) | ||
| 86 | src := $(srctree) | ||
| 87 | obj := $(objtree) | ||
| 88 | |||
| 89 | export prefix libdir bindir src obj | ||
| 90 | |||
| 91 | # Shell quotes | 58 | # Shell quotes |
| 92 | libdir_SQ = $(subst ','\'',$(libdir)) | 59 | libdir_SQ = $(subst ','\'',$(libdir)) |
| 93 | bindir_SQ = $(subst ','\'',$(bindir)) | 60 | bindir_SQ = $(subst ','\'',$(bindir)) |
| 94 | 61 | ||
| 95 | LIB_FILE = liblockdep.a liblockdep.so.$(LIBLOCKDEP_VERSION) | 62 | LIB_IN := $(OUTPUT)liblockdep-in.o |
| 63 | |||
| 96 | BIN_FILE = lockdep | 64 | BIN_FILE = lockdep |
| 65 | LIB_FILE = $(OUTPUT)liblockdep.a $(OUTPUT)liblockdep.so.$(LIBLOCKDEP_VERSION) | ||
| 97 | 66 | ||
| 98 | CONFIG_INCLUDES = | 67 | CONFIG_INCLUDES = |
| 99 | CONFIG_LIBS = | 68 | CONFIG_LIBS = |
| @@ -108,33 +77,23 @@ INCLUDES = -I. -I/usr/local/include -I./uinclude -I./include -I../../include $(C | |||
| 108 | 77 | ||
| 109 | # Set compile option CFLAGS if not set elsewhere | 78 | # Set compile option CFLAGS if not set elsewhere |
| 110 | CFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING -DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='"$(LIBLOCKDEP_VERSION)"' -rdynamic -O0 -g | 79 | CFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING -DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='"$(LIBLOCKDEP_VERSION)"' -rdynamic -O0 -g |
| 80 | CFLAGS += -fPIC | ||
| 111 | 81 | ||
| 112 | override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ) | 82 | override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ) |
| 113 | 83 | ||
| 114 | ifeq ($(VERBOSE),1) | 84 | ifeq ($(VERBOSE),1) |
| 115 | Q = | 85 | Q = |
| 116 | print_compile = | ||
| 117 | print_app_build = | ||
| 118 | print_fpic_compile = | ||
| 119 | print_shared_lib_compile = | 86 | print_shared_lib_compile = |
| 120 | print_install = | 87 | print_install = |
| 121 | else | 88 | else |
| 122 | Q = @ | 89 | Q = @ |
| 123 | print_compile = echo ' CC '$(OBJ); | 90 | print_shared_lib_compile = echo ' LD '$(OBJ); |
| 124 | print_app_build = echo ' BUILD '$(OBJ); | 91 | print_static_lib_build = echo ' LD '$(OBJ); |
| 125 | print_fpic_compile = echo ' CC FPIC '$(OBJ); | 92 | print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2'; |
| 126 | print_shared_lib_compile = echo ' BUILD SHARED LIB '$(OBJ); | ||
| 127 | print_static_lib_build = echo ' BUILD STATIC LIB '$(OBJ); | ||
| 128 | print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2'; | ||
| 129 | endif | 93 | endif |
| 130 | 94 | ||
| 131 | do_fpic_compile = \ | 95 | export srctree OUTPUT CC LD CFLAGS V |
| 132 | ($(print_fpic_compile) \ | 96 | build := -f $(srctree)/tools/build/Makefile.build dir=. obj |
| 133 | $(CC) -c $(CFLAGS) $(EXT) -fPIC $< -o $@) | ||
| 134 | |||
| 135 | do_app_build = \ | ||
| 136 | ($(print_app_build) \ | ||
| 137 | $(CC) $^ -rdynamic -o $@ $(CONFIG_LIBS) $(LIBS)) | ||
| 138 | 97 | ||
| 139 | do_compile_shared_library = \ | 98 | do_compile_shared_library = \ |
| 140 | ($(print_shared_lib_compile) \ | 99 | ($(print_shared_lib_compile) \ |
| @@ -144,22 +103,6 @@ do_build_static_lib = \ | |||
| 144 | ($(print_static_lib_build) \ | 103 | ($(print_static_lib_build) \ |
| 145 | $(RM) $@; $(AR) rcs $@ $^) | 104 | $(RM) $@; $(AR) rcs $@ $^) |
| 146 | 105 | ||
| 147 | |||
| 148 | define do_compile | ||
| 149 | $(print_compile) \ | ||
| 150 | $(CC) -c $(CFLAGS) $(EXT) $< -o $(obj)/$@; | ||
| 151 | endef | ||
| 152 | |||
| 153 | $(obj)/%.o: $(src)/%.c | ||
| 154 | $(Q)$(call do_compile) | ||
| 155 | |||
| 156 | %.o: $(src)/%.c | ||
| 157 | $(Q)$(call do_compile) | ||
| 158 | |||
| 159 | PEVENT_LIB_OBJS = common.o lockdep.o preload.o rbtree.o | ||
| 160 | |||
| 161 | ALL_OBJS = $(PEVENT_LIB_OBJS) | ||
| 162 | |||
| 163 | CMD_TARGETS = $(LIB_FILE) | 106 | CMD_TARGETS = $(LIB_FILE) |
| 164 | 107 | ||
| 165 | TARGETS = $(CMD_TARGETS) | 108 | TARGETS = $(CMD_TARGETS) |
| @@ -169,42 +112,15 @@ all: all_cmd | |||
| 169 | 112 | ||
| 170 | all_cmd: $(CMD_TARGETS) | 113 | all_cmd: $(CMD_TARGETS) |
| 171 | 114 | ||
| 172 | liblockdep.so.$(LIBLOCKDEP_VERSION): $(PEVENT_LIB_OBJS) | 115 | $(LIB_IN): force |
| 116 | $(Q)$(MAKE) $(build)=liblockdep | ||
| 117 | |||
| 118 | liblockdep.so.$(LIBLOCKDEP_VERSION): $(LIB_IN) | ||
| 173 | $(Q)$(do_compile_shared_library) | 119 | $(Q)$(do_compile_shared_library) |
| 174 | 120 | ||
| 175 | liblockdep.a: $(PEVENT_LIB_OBJS) | 121 | liblockdep.a: $(LIB_IN) |
| 176 | $(Q)$(do_build_static_lib) | 122 | $(Q)$(do_build_static_lib) |
| 177 | 123 | ||
| 178 | $(PEVENT_LIB_OBJS): %.o: $(src)/%.c | ||
| 179 | $(Q)$(do_fpic_compile) | ||
| 180 | |||
| 181 | ## make deps | ||
| 182 | |||
| 183 | all_objs := $(sort $(ALL_OBJS)) | ||
| 184 | all_deps := $(all_objs:%.o=.%.d) | ||
| 185 | |||
| 186 | # let .d file also depends on the source and header files | ||
| 187 | define check_deps | ||
| 188 | @set -e; $(RM) $@; \ | ||
| 189 | $(CC) -MM $(CFLAGS) $< > $@.$$$$; \ | ||
| 190 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ | ||
| 191 | $(RM) $@.$$$$ | ||
| 192 | endef | ||
| 193 | |||
| 194 | $(all_deps): .%.d: $(src)/%.c | ||
| 195 | $(Q)$(call check_deps) | ||
| 196 | |||
| 197 | $(all_objs) : %.o : .%.d | ||
| 198 | |||
| 199 | dep_includes := $(wildcard $(all_deps)) | ||
| 200 | |||
| 201 | ifneq ($(dep_includes),) | ||
| 202 | include $(dep_includes) | ||
| 203 | endif | ||
| 204 | |||
| 205 | ### Detect environment changes | ||
| 206 | TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):$(ARCH):$(CROSS_COMPILE) | ||
| 207 | |||
| 208 | tags: force | 124 | tags: force |
| 209 | $(RM) tags | 125 | $(RM) tags |
| 210 | find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \ | 126 | find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \ |
| @@ -233,8 +149,6 @@ clean: | |||
| 233 | $(RM) *.o *~ $(TARGETS) *.a *liblockdep*.so* $(VERSION_FILES) .*.d | 149 | $(RM) *.o *~ $(TARGETS) *.a *liblockdep*.so* $(VERSION_FILES) .*.d |
| 234 | $(RM) tags TAGS | 150 | $(RM) tags TAGS |
| 235 | 151 | ||
| 236 | endif # skip-makefile | ||
| 237 | |||
| 238 | PHONY += force | 152 | PHONY += force |
| 239 | force: | 153 | force: |
| 240 | 154 | ||
