18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci# file format version 38c2ecf20Sopenharmony_ciFILE_VERSION = 1 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciLIBLOCKDEP_VERSION=$(shell make --no-print-directory -sC ../../.. kernelversion) 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci# Makefiles suck: This macro sets a default value of $(2) for the 88c2ecf20Sopenharmony_ci# variable named by $(1), unless the variable has been set by 98c2ecf20Sopenharmony_ci# environment or command line. This is necessary for CC and AR 108c2ecf20Sopenharmony_ci# because make sets default values, so the simpler ?= approach 118c2ecf20Sopenharmony_ci# won't work as expected. 128c2ecf20Sopenharmony_cidefine allow-override 138c2ecf20Sopenharmony_ci $(if $(or $(findstring environment,$(origin $(1))),\ 148c2ecf20Sopenharmony_ci $(findstring command line,$(origin $(1)))),,\ 158c2ecf20Sopenharmony_ci $(eval $(1) = $(2))) 168c2ecf20Sopenharmony_ciendef 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci# Allow setting CC and AR and LD, or setting CROSS_COMPILE as a prefix. 198c2ecf20Sopenharmony_ci$(call allow-override,CC,$(CROSS_COMPILE)gcc) 208c2ecf20Sopenharmony_ci$(call allow-override,AR,$(CROSS_COMPILE)ar) 218c2ecf20Sopenharmony_ci$(call allow-override,LD,$(CROSS_COMPILE)ld) 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ciINSTALL = install 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci# Use DESTDIR for installing into a different root directory. 268c2ecf20Sopenharmony_ci# This is useful for building a package. The program will be 278c2ecf20Sopenharmony_ci# installed in this directory as if it was the root directory. 288c2ecf20Sopenharmony_ci# Then the build tool can move it later. 298c2ecf20Sopenharmony_ciDESTDIR ?= 308c2ecf20Sopenharmony_ciDESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciprefix ?= /usr/local 338c2ecf20Sopenharmony_cilibdir_relative = lib 348c2ecf20Sopenharmony_cilibdir = $(prefix)/$(libdir_relative) 358c2ecf20Sopenharmony_cibindir_relative = bin 368c2ecf20Sopenharmony_cibindir = $(prefix)/$(bindir_relative) 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ciexport DESTDIR DESTDIR_SQ INSTALL 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciMAKEFLAGS += --no-print-directory 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ciinclude ../../scripts/Makefile.include 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci# copy a bit from Linux kbuild 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ciifeq ("$(origin V)", "command line") 478c2ecf20Sopenharmony_ci VERBOSE = $(V) 488c2ecf20Sopenharmony_ciendif 498c2ecf20Sopenharmony_ciifndef VERBOSE 508c2ecf20Sopenharmony_ci VERBOSE = 0 518c2ecf20Sopenharmony_ciendif 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ciifeq ($(srctree),) 548c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(CURDIR))) 558c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree))) 568c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree))) 578c2ecf20Sopenharmony_ci#$(info Determined 'srctree' to be $(srctree)) 588c2ecf20Sopenharmony_ciendif 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci# Shell quotes 618c2ecf20Sopenharmony_cilibdir_SQ = $(subst ','\'',$(libdir)) 628c2ecf20Sopenharmony_cibindir_SQ = $(subst ','\'',$(bindir)) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ciLIB_IN := $(OUTPUT)liblockdep-in.o 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ciBIN_FILE = lockdep 678c2ecf20Sopenharmony_ciLIB_FILE = $(OUTPUT)liblockdep.a $(OUTPUT)liblockdep.so.$(LIBLOCKDEP_VERSION) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ciCONFIG_INCLUDES = 708c2ecf20Sopenharmony_ciCONFIG_LIBS = 718c2ecf20Sopenharmony_ciCONFIG_FLAGS = 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciOBJ = $@ 748c2ecf20Sopenharmony_ciN = 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ciexport Q VERBOSE 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ciINCLUDES = -I. -I./uinclude -I./include -I../../include $(CONFIG_INCLUDES) 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci# Set compile option CFLAGS if not set elsewhere 818c2ecf20Sopenharmony_ciCFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING -DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='"$(LIBLOCKDEP_VERSION)"' -rdynamic -O0 -g 828c2ecf20Sopenharmony_ciCFLAGS += -fPIC 838c2ecf20Sopenharmony_ciCFLAGS += -Wall 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_cioverride CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ciifeq ($(VERBOSE),1) 888c2ecf20Sopenharmony_ci Q = 898c2ecf20Sopenharmony_ci print_shared_lib_compile = 908c2ecf20Sopenharmony_ci print_install = 918c2ecf20Sopenharmony_cielse 928c2ecf20Sopenharmony_ci Q = @ 938c2ecf20Sopenharmony_ci print_shared_lib_compile = echo ' LD '$(OBJ); 948c2ecf20Sopenharmony_ci print_static_lib_build = echo ' LD '$(OBJ); 958c2ecf20Sopenharmony_ci print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2'; 968c2ecf20Sopenharmony_ciendif 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ciall: 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ciexport srctree OUTPUT CC LD CFLAGS V 1018c2ecf20Sopenharmony_ciinclude $(srctree)/tools/build/Makefile.include 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_cido_compile_shared_library = \ 1048c2ecf20Sopenharmony_ci ($(print_shared_lib_compile) \ 1058c2ecf20Sopenharmony_ci $(CC) $(LDFLAGS) --shared $^ -o $@ -lpthread -ldl -Wl,-soname='$(@F)';$(shell ln -sf $(@F) $(@D)/liblockdep.so)) 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_cido_build_static_lib = \ 1088c2ecf20Sopenharmony_ci ($(print_static_lib_build) \ 1098c2ecf20Sopenharmony_ci $(RM) $@; $(AR) rcs $@ $^) 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ciCMD_TARGETS = $(LIB_FILE) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ciTARGETS = $(CMD_TARGETS) 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ciall: fixdep all_cmd 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ciall_cmd: $(CMD_TARGETS) 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci$(LIB_IN): force 1218c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=liblockdep 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci$(OUTPUT)liblockdep.so.$(LIBLOCKDEP_VERSION): $(LIB_IN) 1248c2ecf20Sopenharmony_ci $(Q)$(do_compile_shared_library) 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci$(OUTPUT)liblockdep.a: $(LIB_IN) 1278c2ecf20Sopenharmony_ci $(Q)$(do_build_static_lib) 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_citags: force 1308c2ecf20Sopenharmony_ci $(RM) tags 1318c2ecf20Sopenharmony_ci find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \ 1328c2ecf20Sopenharmony_ci --regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/' 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ciTAGS: force 1358c2ecf20Sopenharmony_ci $(RM) TAGS 1368c2ecf20Sopenharmony_ci find . -name '*.[ch]' | xargs etags \ 1378c2ecf20Sopenharmony_ci --regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/' 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_cidefine do_install 1408c2ecf20Sopenharmony_ci $(print_install) \ 1418c2ecf20Sopenharmony_ci if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ 1428c2ecf20Sopenharmony_ci $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ 1438c2ecf20Sopenharmony_ci fi; \ 1448c2ecf20Sopenharmony_ci $(INSTALL) $1 '$(DESTDIR_SQ)$2' 1458c2ecf20Sopenharmony_ciendef 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ciinstall_lib: all_cmd 1488c2ecf20Sopenharmony_ci $(Q)$(call do_install,$(LIB_FILE),$(libdir_SQ)) 1498c2ecf20Sopenharmony_ci $(Q)$(call do_install,$(BIN_FILE),$(bindir_SQ)) 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ciinstall: install_lib 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ciclean: 1548c2ecf20Sopenharmony_ci $(RM) $(OUTPUT)*.o *~ $(TARGETS) $(OUTPUT)*.a $(OUTPUT)*liblockdep*.so* $(VERSION_FILES) $(OUTPUT).*.d $(OUTPUT).*.cmd 1558c2ecf20Sopenharmony_ci $(RM) tags TAGS 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ciPHONY += force 1588c2ecf20Sopenharmony_ciforce: 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci# Declare the contents of the .PHONY variable as phony. We keep that 1618c2ecf20Sopenharmony_ci# information in a variable so we can use it in if_changed and friends. 1628c2ecf20Sopenharmony_ci.PHONY: $(PHONY) 163