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