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