1160be157SIan Rogers# SPDX-License-Identifier: GPL-2.0 2160be157SIan Rogersinclude ../../scripts/Makefile.include 3160be157SIan Rogersinclude ../../scripts/utilities.mak # QUIET_CLEAN 4160be157SIan Rogers 5160be157SIan Rogersifeq ($(srctree),) 6160be157SIan Rogerssrctree := $(patsubst %/,%,$(dir $(CURDIR))) 7160be157SIan Rogerssrctree := $(patsubst %/,%,$(dir $(srctree))) 8160be157SIan Rogerssrctree := $(patsubst %/,%,$(dir $(srctree))) 9160be157SIan Rogers#$(info Determined 'srctree' to be $(srctree)) 10160be157SIan Rogersendif 11160be157SIan Rogers 12160be157SIan RogersCC ?= $(CROSS_COMPILE)gcc 13160be157SIan RogersAR ?= $(CROSS_COMPILE)ar 14160be157SIan RogersLD ?= $(CROSS_COMPILE)ld 15160be157SIan Rogers 16160be157SIan RogersMAKEFLAGS += --no-print-directory 17160be157SIan Rogers 18160be157SIan RogersINSTALL = install 19160be157SIan Rogers 20160be157SIan Rogers 21160be157SIan Rogers# Use DESTDIR for installing into a different root directory. 22160be157SIan Rogers# This is useful for building a package. The program will be 23160be157SIan Rogers# installed in this directory as if it was the root directory. 24160be157SIan Rogers# Then the build tool can move it later. 25160be157SIan RogersDESTDIR ?= 26160be157SIan RogersDESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' 27160be157SIan Rogers 28160be157SIan RogersLIBFILE = $(OUTPUT)libsymbol.a 29160be157SIan Rogers 30160be157SIan RogersCFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) 31160be157SIan RogersCFLAGS += -ggdb3 -Wall -Wextra -std=gnu11 -U_FORTIFY_SOURCE -fPIC 32160be157SIan Rogers 33160be157SIan Rogersifeq ($(DEBUG),0) 34160be157SIan Rogers CFLAGS += -O3 35160be157SIan Rogersendif 36160be157SIan Rogers 37160be157SIan Rogersifeq ($(DEBUG),0) 38160be157SIan Rogers CFLAGS += -D_FORTIFY_SOURCE 39160be157SIan Rogersendif 40160be157SIan Rogers 41160be157SIan Rogers# Treat warnings as errors unless directed not to 42160be157SIan Rogersifneq ($(WERROR),0) 43160be157SIan Rogers CFLAGS += -Werror 44160be157SIan Rogersendif 45160be157SIan Rogers 46160be157SIan RogersCFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 47160be157SIan Rogers 48160be157SIan RogersCFLAGS += -I$(srctree)/tools/lib 49160be157SIan RogersCFLAGS += -I$(srctree)/tools/include 50160be157SIan Rogers 51160be157SIan RogersRM = rm -f 52160be157SIan Rogers 53160be157SIan RogersSYMBOL_IN := $(OUTPUT)libsymbol-in.o 54160be157SIan Rogers 55160be157SIan Rogersifeq ($(LP64), 1) 56160be157SIan Rogers libdir_relative = lib64 57160be157SIan Rogerselse 58160be157SIan Rogers libdir_relative = lib 59160be157SIan Rogersendif 60160be157SIan Rogers 61160be157SIan Rogersprefix ?= 62160be157SIan Rogerslibdir = $(prefix)/$(libdir_relative) 63160be157SIan Rogers 64160be157SIan Rogers# Shell quotes 65160be157SIan Rogerslibdir_SQ = $(subst ','\'',$(libdir)) 66160be157SIan Rogers 67160be157SIan Rogersall: 68160be157SIan Rogers 69160be157SIan Rogersexport srctree OUTPUT CC LD CFLAGS V 70160be157SIan Rogersinclude $(srctree)/tools/build/Makefile.include 71160be157SIan Rogersinclude $(srctree)/tools/scripts/Makefile.include 72160be157SIan Rogers 73160be157SIan Rogersall: fixdep $(LIBFILE) 74160be157SIan Rogers 75160be157SIan Rogers$(SYMBOL_IN): FORCE 76806dda31SIan Rogers @$(MAKE) $(build)=libsymbol 77160be157SIan Rogers 78160be157SIan Rogers$(LIBFILE): $(SYMBOL_IN) 79160be157SIan Rogers $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SYMBOL_IN) 80160be157SIan Rogers 81160be157SIan Rogersdefine do_install_mkdir 82160be157SIan Rogers if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ 83160be157SIan Rogers $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ 84160be157SIan Rogers fi 85160be157SIan Rogersendef 86160be157SIan Rogers 87160be157SIan Rogersdefine do_install 88*113bb396SIan Rogers if [ ! -d '$2' ]; then \ 89*113bb396SIan Rogers $(INSTALL) -d -m 755 '$2'; \ 90160be157SIan Rogers fi; \ 91*113bb396SIan Rogers $(INSTALL) $1 $(if $3,-m $3,) '$2' 92160be157SIan Rogersendef 93160be157SIan Rogers 94160be157SIan Rogersinstall_lib: $(LIBFILE) 95160be157SIan Rogers $(call QUIET_INSTALL, $(LIBFILE)) \ 96160be157SIan Rogers $(call do_install_mkdir,$(libdir_SQ)); \ 97160be157SIan Rogers cp -fpR $(LIBFILE) $(DESTDIR)$(libdir_SQ) 98160be157SIan Rogers 99*113bb396SIan RogersHDRS := kallsyms.h 100*113bb396SIan RogersINSTALL_HDRS_PFX := $(DESTDIR)$(prefix)/include/symbol 101*113bb396SIan RogersINSTALL_HDRS := $(addprefix $(INSTALL_HDRS_PFX)/, $(HDRS)) 102*113bb396SIan Rogers 103*113bb396SIan Rogers$(INSTALL_HDRS): $(INSTALL_HDRS_PFX)/%.h: %.h 104*113bb396SIan Rogers $(call QUIET_INSTALL, $@) \ 105*113bb396SIan Rogers $(call do_install,$<,$(INSTALL_HDRS_PFX)/,644) 106*113bb396SIan Rogers 107*113bb396SIan Rogersinstall_headers: $(INSTALL_HDRS) 108*113bb396SIan Rogers $(call QUIET_INSTALL, libsymbol_headers) 109160be157SIan Rogers 110160be157SIan Rogersinstall: install_lib install_headers 111160be157SIan Rogers 112160be157SIan Rogersclean: 113160be157SIan Rogers $(call QUIET_CLEAN, libsymbol) $(RM) $(LIBFILE); \ 114160be157SIan Rogers find $(or $(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM) 115160be157SIan Rogers 116160be157SIan RogersFORCE: 117160be157SIan Rogers 118160be157SIan Rogers.PHONY: clean FORCE 119