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