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