Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / tools / lib / subcmd / Makefile
blob95563b8e1ad743433076257d8f04d3740e2e55da
1 # SPDX-License-Identifier: GPL-2.0
2 include ../../scripts/Makefile.include
3 include ../../scripts/utilities.mak # QUIET_CLEAN
5 ifeq ($(srctree),)
6 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
7 srctree := $(patsubst %/,%,$(dir $(srctree)))
8 srctree := $(patsubst %/,%,$(dir $(srctree)))
9 #$(info Determined 'srctree' to be $(srctree))
10 endif
12 CC ?= $(CROSS_COMPILE)gcc
13 LD ?= $(CROSS_COMPILE)ld
14 AR ?= $(CROSS_COMPILE)ar
16 RM = rm -f
18 MAKEFLAGS += --no-print-directory
20 LIBFILE = $(OUTPUT)libsubcmd.a
22 CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
23 CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
25 ifeq ($(CC_NO_CLANG), 0)
26 CFLAGS += -O3
27 else
28 CFLAGS += -O6
29 endif
31 # Treat warnings as errors unless directed not to
32 ifneq ($(WERROR),0)
33 CFLAGS += -Werror
34 endif
36 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
38 CFLAGS += -I$(srctree)/tools/include/
39 CFLAGS += -I$(srctree)/include/uapi
40 CFLAGS += -I$(srctree)/include
42 SUBCMD_IN := $(OUTPUT)libsubcmd-in.o
44 all:
46 export srctree OUTPUT CC LD CFLAGS V
47 include $(srctree)/tools/build/Makefile.include
49 all: fixdep $(LIBFILE)
51 $(SUBCMD_IN): FORCE
52 @$(MAKE) $(build)=libsubcmd
54 $(LIBFILE): $(SUBCMD_IN)
55 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SUBCMD_IN)
57 clean:
58 $(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \
59 find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
61 FORCE:
63 .PHONY: clean FORCE