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 ifeq ($(CC_NO_CLANG), 0) 34 ifeq ($(CC_NO_CLANG), 0) 35 CFLAGS += -O3 35 CFLAGS += -O3 36 else 36 else 37 CFLAGS += -O6 37 CFLAGS += -O6 38 endif 38 endif 39 endif 39 endif 40 40 41 ifeq ($(DEBUG),0) 41 ifeq ($(DEBUG),0) 42 CFLAGS += -D_FORTIFY_SOURCE 42 CFLAGS += -D_FORTIFY_SOURCE 43 endif 43 endif 44 44 45 # Treat warnings as errors unless directed not 45 # Treat warnings as errors unless directed not to 46 ifneq ($(WERROR),0) 46 ifneq ($(WERROR),0) 47 CFLAGS += -Werror 47 CFLAGS += -Werror 48 endif 48 endif 49 49 50 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET 50 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 51 51 52 CFLAGS += -I$(srctree)/tools/lib 52 CFLAGS += -I$(srctree)/tools/lib 53 CFLAGS += -I$(srctree)/tools/include 53 CFLAGS += -I$(srctree)/tools/include 54 54 55 RM = rm -f 55 RM = rm -f 56 56 57 SYMBOL_IN := $(OUTPUT)libsymbol-in.o 57 SYMBOL_IN := $(OUTPUT)libsymbol-in.o 58 58 59 ifeq ($(LP64), 1) 59 ifeq ($(LP64), 1) 60 libdir_relative = lib64 60 libdir_relative = lib64 61 else 61 else 62 libdir_relative = lib 62 libdir_relative = lib 63 endif 63 endif 64 64 65 prefix ?= 65 prefix ?= 66 libdir = $(prefix)/$(libdir_relative) 66 libdir = $(prefix)/$(libdir_relative) 67 67 68 # Shell quotes 68 # Shell quotes 69 libdir_SQ = $(subst ','\'',$(libdir)) 69 libdir_SQ = $(subst ','\'',$(libdir)) 70 70 71 all: 71 all: 72 72 73 export srctree OUTPUT CC LD CFLAGS V 73 export srctree OUTPUT CC LD CFLAGS V 74 include $(srctree)/tools/build/Makefile.includ 74 include $(srctree)/tools/build/Makefile.include 75 include $(srctree)/tools/scripts/Makefile.incl 75 include $(srctree)/tools/scripts/Makefile.include 76 76 77 all: fixdep $(LIBFILE) 77 all: fixdep $(LIBFILE) 78 78 79 $(SYMBOL_IN): FORCE 79 $(SYMBOL_IN): FORCE 80 @$(MAKE) $(build)=libsymbol 80 @$(MAKE) $(build)=libsymbol 81 81 82 $(LIBFILE): $(SYMBOL_IN) 82 $(LIBFILE): $(SYMBOL_IN) 83 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $( 83 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SYMBOL_IN) 84 84 85 define do_install_mkdir 85 define do_install_mkdir 86 if [ ! -d '$(DESTDIR_SQ)$1' ]; then 86 if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ 87 $(INSTALL) -d -m 755 '$(DESTDI 87 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ 88 fi 88 fi 89 endef 89 endef 90 90 91 define do_install 91 define do_install 92 if [ ! -d '$2' ]; then \ 92 if [ ! -d '$2' ]; then \ 93 $(INSTALL) -d -m 755 '$2'; \ 93 $(INSTALL) -d -m 755 '$2'; \ 94 fi; \ 94 fi; \ 95 $(INSTALL) $1 $(if $3,-m $3,) '$2' 95 $(INSTALL) $1 $(if $3,-m $3,) '$2' 96 endef 96 endef 97 97 98 install_lib: $(LIBFILE) 98 install_lib: $(LIBFILE) 99 $(call QUIET_INSTALL, $(LIBFILE)) \ 99 $(call QUIET_INSTALL, $(LIBFILE)) \ 100 $(call do_install_mkdir,$(libd 100 $(call do_install_mkdir,$(libdir_SQ)); \ 101 cp -fpR $(LIBFILE) $(DESTDIR)$ 101 cp -fpR $(LIBFILE) $(DESTDIR)$(libdir_SQ) 102 102 103 HDRS := kallsyms.h 103 HDRS := kallsyms.h 104 INSTALL_HDRS_PFX := $(DESTDIR)$(prefix)/includ 104 INSTALL_HDRS_PFX := $(DESTDIR)$(prefix)/include/symbol 105 INSTALL_HDRS := $(addprefix $(INSTALL_HDRS_PFX 105 INSTALL_HDRS := $(addprefix $(INSTALL_HDRS_PFX)/, $(HDRS)) 106 106 107 $(INSTALL_HDRS): $(INSTALL_HDRS_PFX)/%.h: %.h 107 $(INSTALL_HDRS): $(INSTALL_HDRS_PFX)/%.h: %.h 108 $(call QUIET_INSTALL, $@) \ 108 $(call QUIET_INSTALL, $@) \ 109 $(call do_install,$<,$(INSTALL 109 $(call do_install,$<,$(INSTALL_HDRS_PFX)/,644) 110 110 111 install_headers: $(INSTALL_HDRS) 111 install_headers: $(INSTALL_HDRS) 112 $(call QUIET_INSTALL, libsymbol_header 112 $(call QUIET_INSTALL, libsymbol_headers) 113 113 114 install: install_lib install_headers 114 install: install_lib install_headers 115 115 116 clean: 116 clean: 117 $(call QUIET_CLEAN, libsymbol) $(RM) $ 117 $(call QUIET_CLEAN, libsymbol) $(RM) $(LIBFILE); \ 118 find $(or $(OUTPUT),.) -name \*.o -or 118 find $(or $(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM) 119 119 120 FORCE: 120 FORCE: 121 121 122 .PHONY: clean FORCE 122 .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.