0001
0002 include ../../scripts/Makefile.include
0003 include ../../scripts/utilities.mak
0004
0005 ifeq ($(srctree),)
0006 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
0007 srctree := $(patsubst %/,%,$(dir $(srctree)))
0008 srctree := $(patsubst %/,%,$(dir $(srctree)))
0009
0010 endif
0011
0012 CC ?= $(CROSS_COMPILE)gcc
0013 LD ?= $(CROSS_COMPILE)ld
0014 AR ?= $(CROSS_COMPILE)ar
0015
0016 RM = rm -f
0017
0018 MAKEFLAGS += --no-print-directory
0019
0020 LIBFILE = $(OUTPUT)libsubcmd.a
0021
0022 CFLAGS := -ggdb3 -Wall -Wextra -std=gnu99 -fPIC
0023
0024 ifeq ($(DEBUG),0)
0025 ifeq ($(feature-fortify-source), 1)
0026 CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
0027 endif
0028 endif
0029
0030 ifeq ($(DEBUG),1)
0031 CFLAGS += -O0
0032 else ifeq ($(CC_NO_CLANG), 0)
0033 CFLAGS += -O3
0034 else
0035 CFLAGS += -O6
0036 endif
0037
0038
0039 ifneq ($(WERROR),0)
0040 CFLAGS += -Werror
0041 endif
0042
0043 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
0044
0045 CFLAGS += -I$(srctree)/tools/include/
0046
0047 CFLAGS += $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
0048
0049 SUBCMD_IN := $(OUTPUT)libsubcmd-in.o
0050
0051 all:
0052
0053 export srctree OUTPUT CC LD CFLAGS V
0054 include $(srctree)/tools/build/Makefile.include
0055
0056 all: fixdep $(LIBFILE)
0057
0058 $(SUBCMD_IN): FORCE
0059 @$(MAKE) $(build)=libsubcmd
0060
0061 $(LIBFILE): $(SUBCMD_IN)
0062 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SUBCMD_IN)
0063
0064 clean:
0065 $(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \
0066 find $(or $(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
0067
0068 FORCE:
0069
0070 .PHONY: clean FORCE