119 lines · plain
1# SPDX-License-Identifier: GPL-2.02include ../../scripts/Makefile.include3include ../../scripts/utilities.mak # QUIET_CLEAN4 5ifeq ($(srctree),)6srctree := $(patsubst %/,%,$(dir $(CURDIR)))7srctree := $(patsubst %/,%,$(dir $(srctree)))8srctree := $(patsubst %/,%,$(dir $(srctree)))9#$(info Determined 'srctree' to be $(srctree))10endif11 12CC ?= $(CROSS_COMPILE)gcc13AR ?= $(CROSS_COMPILE)ar14LD ?= $(CROSS_COMPILE)ld15 16MAKEFLAGS += --no-print-directory17 18INSTALL = install19 20 21# Use DESTDIR for installing into a different root directory.22# This is useful for building a package. The program will be23# installed in this directory as if it was the root directory.24# Then the build tool can move it later.25DESTDIR ?=26DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'27 28LIBFILE = $(OUTPUT)libsymbol.a29 30CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)31CFLAGS += -ggdb3 -Wall -Wextra -std=gnu11 -U_FORTIFY_SOURCE -fPIC32 33ifeq ($(DEBUG),0)34 CFLAGS += -O335endif36 37ifeq ($(DEBUG),0)38 CFLAGS += -D_FORTIFY_SOURCE39endif40 41# Treat warnings as errors unless directed not to42ifneq ($(WERROR),0)43 CFLAGS += -Werror44endif45 46CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=6447 48CFLAGS += -I$(srctree)/tools/lib49CFLAGS += -I$(srctree)/tools/include50 51RM = rm -f52 53SYMBOL_IN := $(OUTPUT)libsymbol-in.o54 55ifeq ($(LP64), 1)56 libdir_relative = lib6457else58 libdir_relative = lib59endif60 61prefix ?=62libdir = $(prefix)/$(libdir_relative)63 64# Shell quotes65libdir_SQ = $(subst ','\'',$(libdir))66 67all:68 69export srctree OUTPUT CC LD CFLAGS V70include $(srctree)/tools/build/Makefile.include71include $(srctree)/tools/scripts/Makefile.include72 73all: fixdep $(LIBFILE)74 75$(SYMBOL_IN): FORCE76 @$(MAKE) $(build)=libsymbol77 78$(LIBFILE): $(SYMBOL_IN)79 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SYMBOL_IN)80 81define do_install_mkdir82 if [ ! -d '$(DESTDIR_SQ)$1' ]; then \83 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \84 fi85endef86 87define do_install88 if [ ! -d '$2' ]; then \89 $(INSTALL) -d -m 755 '$2'; \90 fi; \91 $(INSTALL) $1 $(if $3,-m $3,) '$2'92endef93 94install_lib: $(LIBFILE)95 $(call QUIET_INSTALL, $(LIBFILE)) \96 $(call do_install_mkdir,$(libdir_SQ)); \97 cp -fpR $(LIBFILE) $(DESTDIR)$(libdir_SQ)98 99HDRS := kallsyms.h100INSTALL_HDRS_PFX := $(DESTDIR)$(prefix)/include/symbol101INSTALL_HDRS := $(addprefix $(INSTALL_HDRS_PFX)/, $(HDRS))102 103$(INSTALL_HDRS): $(INSTALL_HDRS_PFX)/%.h: %.h104 $(call QUIET_INSTALL, $@) \105 $(call do_install,$<,$(INSTALL_HDRS_PFX)/,644)106 107install_headers: $(INSTALL_HDRS)108 $(call QUIET_INSTALL, libsymbol_headers)109 110install: install_lib install_headers111 112clean:113 $(call QUIET_CLEAN, libsymbol) $(RM) $(LIBFILE); \114 find $(or $(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)115 116FORCE:117 118.PHONY: clean FORCE119