Merge tag 'ntb-5.11' of git://github.com/jonmason/ntb
[linux/fpc-iii.git] / tools / lib / subcmd / Makefile
blob1c777a72bb398346a24afa192a3d5d30f0d40fa7
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 := -ggdb3 -Wall -Wextra -std=gnu99 -fPIC
24 ifeq ($(DEBUG),0)
25 ifeq ($(feature-fortify-source), 1)
26 CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
27 endif
28 endif
30 ifeq ($(DEBUG),1)
31 CFLAGS += -O0
32 else ifeq ($(CC_NO_CLANG), 0)
33 CFLAGS += -O3
34 else
35 CFLAGS += -O6
36 endif
38 # Treat warnings as errors unless directed not to
39 ifneq ($(WERROR),0)
40 CFLAGS += -Werror
41 endif
43 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
45 CFLAGS += -I$(srctree)/tools/include/
47 CFLAGS += $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
49 SUBCMD_IN := $(OUTPUT)libsubcmd-in.o
51 all:
53 export srctree OUTPUT CC LD CFLAGS V
54 include $(srctree)/tools/build/Makefile.include
56 all: fixdep $(LIBFILE)
58 $(SUBCMD_IN): FORCE
59 @$(MAKE) $(build)=libsubcmd
61 $(LIBFILE): $(SUBCMD_IN)
62 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SUBCMD_IN)
64 clean:
65 $(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \
66 find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
68 FORCE:
70 .PHONY: clean FORCE