1 # SPDX-License-Identifier: GPL-2.0 1 # SPDX-License-Identifier: GPL-2.0 2 include ../../scripts/Makefile.include 2 include ../../scripts/Makefile.include 3 include ../../scripts/utilities.mak 3 include ../../scripts/utilities.mak # QUIET_CLEAN 4 4 5 ifeq ($(srctree),) 5 ifeq ($(srctree),) 6 srctree := $(patsubst %/,%,$(dir $(CURDIR))) 6 srctree := $(patsubst %/,%,$(dir $(CURDIR))) 7 srctree := $(patsubst %/,%,$(dir $(srctree))) 7 srctree := $(patsubst %/,%,$(dir $(srctree))) 8 srctree := $(patsubst %/,%,$(dir $(srctree))) 8 srctree := $(patsubst %/,%,$(dir $(srctree))) 9 #$(info Determined 'srctree' to be $(srctree)) 9 #$(info Determined 'srctree' to be $(srctree)) 10 endif 10 endif 11 11 12 CC ?= $(CROSS_COMPILE)gcc 12 CC ?= $(CROSS_COMPILE)gcc 13 AR ?= $(CROSS_COMPILE)ar 13 AR ?= $(CROSS_COMPILE)ar 14 LD ?= $(CROSS_COMPILE)ld 14 LD ?= $(CROSS_COMPILE)ld 15 15 16 MAKEFLAGS += --no-print-directory 16 MAKEFLAGS += --no-print-directory 17 17 18 INSTALL = install 18 INSTALL = install 19 19 20 20 21 # Use DESTDIR for installing into a different 21 # Use DESTDIR for installing into a different root directory. 22 # This is useful for building a package. The p 22 # This is useful for building a package. The program will be 23 # installed in this directory as if it was the 23 # installed in this directory as if it was the root directory. 24 # Then the build tool can move it later. 24 # Then the build tool can move it later. 25 DESTDIR ?= 25 DESTDIR ?= 26 DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' 26 DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' 27 27 28 LIBFILE = $(OUTPUT)libsymbol.a 28 LIBFILE = $(OUTPUT)libsymbol.a 29 29 30 CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) 30 CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) 31 CFLAGS += -ggdb3 -Wall -Wextra -std=gnu11 -U_F 31 CFLAGS += -ggdb3 -Wall -Wextra -std=gnu11 -U_FORTIFY_SOURCE -fPIC 32 32 33 ifeq ($(DEBUG),0) 33 ifeq ($(DEBUG),0) 34 CFLAGS += -O3 34 CFLAGS += -O3 35 endif 35 endif 36 36 37 ifeq ($(DEBUG),0) 37 ifeq ($(DEBUG),0) 38 CFLAGS += -D_FORTIFY_SOURCE 38 CFLAGS += -D_FORTIFY_SOURCE 39 endif 39 endif 40 40 41 # Treat warnings as errors unless directed not 41 # Treat warnings as errors unless directed not to 42 ifneq ($(WERROR),0) 42 ifneq ($(WERROR),0) 43 CFLAGS += -Werror 43 CFLAGS += -Werror 44 endif 44 endif 45 45 46 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET 46 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 47 47 48 CFLAGS += -I$(srctree)/tools/lib 48 CFLAGS += -I$(srctree)/tools/lib 49 CFLAGS += -I$(srctree)/tools/include 49 CFLAGS += -I$(srctree)/tools/include 50 50 51 RM = rm -f 51 RM = rm -f 52 52 53 SYMBOL_IN := $(OUTPUT)libsymbol-in.o 53 SYMBOL_IN := $(OUTPUT)libsymbol-in.o 54 54 55 ifeq ($(LP64), 1) 55 ifeq ($(LP64), 1) 56 libdir_relative = lib64 56 libdir_relative = lib64 57 else 57 else 58 libdir_relative = lib 58 libdir_relative = lib 59 endif 59 endif 60 60 61 prefix ?= 61 prefix ?= 62 libdir = $(prefix)/$(libdir_relative) 62 libdir = $(prefix)/$(libdir_relative) 63 63 64 # Shell quotes 64 # Shell quotes 65 libdir_SQ = $(subst ','\'',$(libdir)) 65 libdir_SQ = $(subst ','\'',$(libdir)) 66 66 67 all: 67 all: 68 68 69 export srctree OUTPUT CC LD CFLAGS V 69 export srctree OUTPUT CC LD CFLAGS V 70 include $(srctree)/tools/build/Makefile.includ 70 include $(srctree)/tools/build/Makefile.include 71 include $(srctree)/tools/scripts/Makefile.incl 71 include $(srctree)/tools/scripts/Makefile.include 72 72 73 all: fixdep $(LIBFILE) 73 all: fixdep $(LIBFILE) 74 74 75 $(SYMBOL_IN): FORCE 75 $(SYMBOL_IN): FORCE 76 @$(MAKE) $(build)=libsymbol 76 @$(MAKE) $(build)=libsymbol 77 77 78 $(LIBFILE): $(SYMBOL_IN) 78 $(LIBFILE): $(SYMBOL_IN) 79 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $( 79 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SYMBOL_IN) 80 80 81 define do_install_mkdir 81 define do_install_mkdir 82 if [ ! -d '$(DESTDIR_SQ)$1' ]; then 82 if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ 83 $(INSTALL) -d -m 755 '$(DESTDI 83 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ 84 fi 84 fi 85 endef 85 endef 86 86 87 define do_install 87 define do_install 88 if [ ! -d '$2' ]; then \ 88 if [ ! -d '$2' ]; then \ 89 $(INSTALL) -d -m 755 '$2'; \ 89 $(INSTALL) -d -m 755 '$2'; \ 90 fi; \ 90 fi; \ 91 $(INSTALL) $1 $(if $3,-m $3,) '$2' 91 $(INSTALL) $1 $(if $3,-m $3,) '$2' 92 endef 92 endef 93 93 94 install_lib: $(LIBFILE) 94 install_lib: $(LIBFILE) 95 $(call QUIET_INSTALL, $(LIBFILE)) \ 95 $(call QUIET_INSTALL, $(LIBFILE)) \ 96 $(call do_install_mkdir,$(libd 96 $(call do_install_mkdir,$(libdir_SQ)); \ 97 cp -fpR $(LIBFILE) $(DESTDIR)$ 97 cp -fpR $(LIBFILE) $(DESTDIR)$(libdir_SQ) 98 98 99 HDRS := kallsyms.h 99 HDRS := kallsyms.h 100 INSTALL_HDRS_PFX := $(DESTDIR)$(prefix)/includ 100 INSTALL_HDRS_PFX := $(DESTDIR)$(prefix)/include/symbol 101 INSTALL_HDRS := $(addprefix $(INSTALL_HDRS_PFX 101 INSTALL_HDRS := $(addprefix $(INSTALL_HDRS_PFX)/, $(HDRS)) 102 102 103 $(INSTALL_HDRS): $(INSTALL_HDRS_PFX)/%.h: %.h 103 $(INSTALL_HDRS): $(INSTALL_HDRS_PFX)/%.h: %.h 104 $(call QUIET_INSTALL, $@) \ 104 $(call QUIET_INSTALL, $@) \ 105 $(call do_install,$<,$(INSTALL 105 $(call do_install,$<,$(INSTALL_HDRS_PFX)/,644) 106 106 107 install_headers: $(INSTALL_HDRS) 107 install_headers: $(INSTALL_HDRS) 108 $(call QUIET_INSTALL, libsymbol_header 108 $(call QUIET_INSTALL, libsymbol_headers) 109 109 110 install: install_lib install_headers 110 install: install_lib install_headers 111 111 112 clean: 112 clean: 113 $(call QUIET_CLEAN, libsymbol) $(RM) $ 113 $(call QUIET_CLEAN, libsymbol) $(RM) $(LIBFILE); \ 114 find $(or $(OUTPUT),.) -name \*.o -or 114 find $(or $(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM) 115 115 116 FORCE: 116 FORCE: 117 117 118 .PHONY: clean FORCE 118 .PHONY: clean FORCE
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.