Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
9244e2c6 2d58ab9b

+24 -109
+1
tools/lib/lockdep/Build
··· 1 + liblockdep-y += common.o lockdep.o preload.o rbtree.o
+23 -109
tools/lib/lockdep/Makefile
··· 35 35 36 36 export DESTDIR DESTDIR_SQ INSTALL 37 37 38 + MAKEFLAGS += --no-print-directory 39 + 40 + include ../../scripts/Makefile.include 41 + 38 42 # copy a bit from Linux kbuild 39 43 40 44 ifeq ("$(origin V)", "command line") ··· 48 44 VERBOSE = 0 49 45 endif 50 46 51 - ifeq ("$(origin O)", "command line") 52 - BUILD_OUTPUT := $(O) 47 + ifeq ($(srctree),) 48 + srctree := $(patsubst %/,%,$(dir $(shell pwd))) 49 + srctree := $(patsubst %/,%,$(dir $(srctree))) 50 + srctree := $(patsubst %/,%,$(dir $(srctree))) 51 + #$(info Determined 'srctree' to be $(srctree)) 53 52 endif 54 - 55 - ifeq ($(BUILD_SRC),) 56 - ifneq ($(BUILD_OUTPUT),) 57 - 58 - define build_output 59 - $(if $(VERBOSE:1=),@)$(MAKE) -C $(BUILD_OUTPUT) \ 60 - BUILD_SRC=$(CURDIR) -f $(CURDIR)/Makefile $1 61 - endef 62 - 63 - saved-output := $(BUILD_OUTPUT) 64 - BUILD_OUTPUT := $(shell cd $(BUILD_OUTPUT) && /bin/pwd) 65 - $(if $(BUILD_OUTPUT),, \ 66 - $(error output directory "$(saved-output)" does not exist)) 67 - 68 - all: sub-make 69 - 70 - gui: force 71 - $(call build_output, all_cmd) 72 - 73 - $(filter-out gui,$(MAKECMDGOALS)): sub-make 74 - 75 - sub-make: force 76 - $(call build_output, $(MAKECMDGOALS)) 77 - 78 - 79 - # Leave processing to above invocation of make 80 - skip-makefile := 1 81 - 82 - endif # BUILD_OUTPUT 83 - endif # BUILD_SRC 84 - 85 - # We process the rest of the Makefile if this is the final invocation of make 86 - ifeq ($(skip-makefile),) 87 - 88 - srctree := $(realpath $(if $(BUILD_SRC),$(BUILD_SRC),$(CURDIR))) 89 - objtree := $(realpath $(CURDIR)) 90 - src := $(srctree) 91 - obj := $(objtree) 92 - 93 - export prefix libdir bindir src obj 94 53 95 54 # Shell quotes 96 55 libdir_SQ = $(subst ','\'',$(libdir)) 97 56 bindir_SQ = $(subst ','\'',$(bindir)) 98 57 99 - LIB_FILE = liblockdep.a liblockdep.so.$(LIBLOCKDEP_VERSION) 58 + LIB_IN := $(OUTPUT)liblockdep-in.o 59 + 100 60 BIN_FILE = lockdep 61 + LIB_FILE = $(OUTPUT)liblockdep.a $(OUTPUT)liblockdep.so.$(LIBLOCKDEP_VERSION) 101 62 102 63 CONFIG_INCLUDES = 103 64 CONFIG_LIBS = ··· 77 108 78 109 # Set compile option CFLAGS if not set elsewhere 79 110 CFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING -DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='"$(LIBLOCKDEP_VERSION)"' -rdynamic -O0 -g 111 + CFLAGS += -fPIC 80 112 81 113 override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ) 82 114 83 115 ifeq ($(VERBOSE),1) 84 116 Q = 85 - print_compile = 86 - print_app_build = 87 - print_fpic_compile = 88 117 print_shared_lib_compile = 89 118 print_install = 90 119 else 91 120 Q = @ 92 - print_compile = echo ' CC '$(OBJ); 93 - print_app_build = echo ' BUILD '$(OBJ); 94 - print_fpic_compile = echo ' CC FPIC '$(OBJ); 95 - print_shared_lib_compile = echo ' BUILD SHARED LIB '$(OBJ); 96 - print_static_lib_build = echo ' BUILD STATIC LIB '$(OBJ); 97 - print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2'; 121 + print_shared_lib_compile = echo ' LD '$(OBJ); 122 + print_static_lib_build = echo ' LD '$(OBJ); 123 + print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2'; 98 124 endif 99 125 100 - do_fpic_compile = \ 101 - ($(print_fpic_compile) \ 102 - $(CC) -c $(CFLAGS) $(EXT) -fPIC $< -o $@) 103 - 104 - do_app_build = \ 105 - ($(print_app_build) \ 106 - $(CC) $^ -rdynamic -o $@ $(CONFIG_LIBS) $(LIBS)) 126 + export srctree OUTPUT CC LD CFLAGS V 127 + build := -f $(srctree)/tools/build/Makefile.build dir=. obj 107 128 108 129 do_compile_shared_library = \ 109 130 ($(print_shared_lib_compile) \ ··· 102 143 do_build_static_lib = \ 103 144 ($(print_static_lib_build) \ 104 145 $(RM) $@; $(AR) rcs $@ $^) 105 - 106 - 107 - define do_compile 108 - $(print_compile) \ 109 - $(CC) -c $(CFLAGS) $(EXT) $< -o $(obj)/$@; 110 - endef 111 - 112 - $(obj)/%.o: $(src)/%.c 113 - $(Q)$(call do_compile) 114 - 115 - %.o: $(src)/%.c 116 - $(Q)$(call do_compile) 117 - 118 - PEVENT_LIB_OBJS = common.o lockdep.o preload.o rbtree.o 119 - 120 - ALL_OBJS = $(PEVENT_LIB_OBJS) 121 146 122 147 CMD_TARGETS = $(LIB_FILE) 123 148 ··· 112 169 113 170 all_cmd: $(CMD_TARGETS) 114 171 115 - liblockdep.so.$(LIBLOCKDEP_VERSION): $(PEVENT_LIB_OBJS) 172 + $(LIB_IN): force 173 + $(Q)$(MAKE) $(build)=liblockdep 174 + 175 + liblockdep.so.$(LIBLOCKDEP_VERSION): $(LIB_IN) 116 176 $(Q)$(do_compile_shared_library) 117 177 118 - liblockdep.a: $(PEVENT_LIB_OBJS) 178 + liblockdep.a: $(LIB_IN) 119 179 $(Q)$(do_build_static_lib) 120 - 121 - $(PEVENT_LIB_OBJS): %.o: $(src)/%.c 122 - $(Q)$(do_fpic_compile) 123 - 124 - ## make deps 125 - 126 - all_objs := $(sort $(ALL_OBJS)) 127 - all_deps := $(all_objs:%.o=.%.d) 128 - 129 - # let .d file also depends on the source and header files 130 - define check_deps 131 - @set -e; $(RM) $@; \ 132 - $(CC) -MM $(CFLAGS) $< > $@.$$$$; \ 133 - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 134 - $(RM) $@.$$$$ 135 - endef 136 - 137 - $(all_deps): .%.d: $(src)/%.c 138 - $(Q)$(call check_deps) 139 - 140 - $(all_objs) : %.o : .%.d 141 - 142 - dep_includes := $(wildcard $(all_deps)) 143 - 144 - ifneq ($(dep_includes),) 145 - include $(dep_includes) 146 - endif 147 - 148 - ### Detect environment changes 149 - TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):$(ARCH):$(CROSS_COMPILE) 150 180 151 181 tags: force 152 182 $(RM) tags ··· 148 232 clean: 149 233 $(RM) *.o *~ $(TARGETS) *.a *liblockdep*.so* $(VERSION_FILES) .*.d 150 234 $(RM) tags TAGS 151 - 152 - endif # skip-makefile 153 235 154 236 PHONY += force 155 237 force: