1# SPDX-License-Identifier: GPL-2.0 2include ../../scripts/Makefile.include 3include ../../scripts/utilities.mak # QUIET_CLEAN 4 5ifeq ($(srctree),) 6srctree := $(patsubst %/,%,$(dir $(CURDIR))) 7srctree := $(patsubst %/,%,$(dir $(srctree))) 8srctree := $(patsubst %/,%,$(dir $(srctree))) 9#$(info Determined 'srctree' to be $(srctree)) 10endif 11 12CC ?= $(CROSS_COMPILE)gcc 13LD ?= $(CROSS_COMPILE)ld 14AR ?= $(CROSS_COMPILE)ar 15 16RM = rm -f 17 18MAKEFLAGS += --no-print-directory 19 20LIBFILE = $(OUTPUT)libsubcmd.a 21 22CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) 23CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC 24 25ifeq ($(CC_NO_CLANG), 0) 26 CFLAGS += -O3 27else 28 CFLAGS += -O6 29endif 30 31# Treat warnings as errors unless directed not to 32ifneq ($(WERROR),0) 33 CFLAGS += -Werror 34endif 35 36CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 37 38CFLAGS += -I$(srctree)/tools/include/ 39 40SUBCMD_IN := $(OUTPUT)libsubcmd-in.o 41 42all: 43 44export srctree OUTPUT CC LD CFLAGS V 45include $(srctree)/tools/build/Makefile.include 46 47all: fixdep $(LIBFILE) 48 49$(SUBCMD_IN): FORCE 50 @$(MAKE) $(build)=libsubcmd 51 52$(LIBFILE): $(SUBCMD_IN) 53 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SUBCMD_IN) 54 55clean: 56 $(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \ 57 find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM) 58 59FORCE: 60 61.PHONY: clean FORCE 62