xref: /openbmc/linux/tools/lib/subcmd/Makefile (revision c0c74acb)
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 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
23
24ifeq ($(CC), clang)
25  CFLAGS += -O3
26else
27  CFLAGS += -O6
28endif
29
30# Treat warnings as errors unless directed not to
31ifneq ($(WERROR),0)
32  CFLAGS += -Werror
33endif
34
35CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
36
37CFLAGS += -I$(srctree)/tools/include/
38CFLAGS += -I$(srctree)/include/uapi
39CFLAGS += -I$(srctree)/include
40
41SUBCMD_IN := $(OUTPUT)libsubcmd-in.o
42
43all:
44
45export srctree OUTPUT CC LD CFLAGS V
46include $(srctree)/tools/build/Makefile.include
47
48all: fixdep $(LIBFILE)
49
50$(SUBCMD_IN): FORCE
51	@$(MAKE) $(build)=libsubcmd
52
53$(LIBFILE): $(SUBCMD_IN)
54	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SUBCMD_IN)
55
56clean:
57	$(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \
58	find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
59
60FORCE:
61
62.PHONY: clean FORCE
63