Linux 6.9-rc4
[sfrench/cifs-2.6.git] / tools / lib / api / 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 AR ?= $(CROSS_COMPILE)ar
14 LD ?= $(CROSS_COMPILE)ld
15
16 MAKEFLAGS += --no-print-directory
17
18 LIBFILE = $(OUTPUT)libapi.a
19
20 CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
21 CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -fPIC
22
23 ifeq ($(DEBUG),0)
24 ifeq ($(CC_NO_CLANG), 0)
25   CFLAGS += -O3
26 else
27   CFLAGS += -O6
28 endif
29 endif
30
31 ifeq ($(DEBUG),0)
32   CFLAGS += -D_FORTIFY_SOURCE
33 endif
34
35 # Treat warnings as errors unless directed not to
36 ifneq ($(WERROR),0)
37   CFLAGS += -Werror
38 endif
39
40 CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
41 CFLAGS += -I$(srctree)/tools/lib/api
42 CFLAGS += -I$(srctree)/tools/include
43
44 RM = rm -f
45
46 API_IN := $(OUTPUT)libapi-in.o
47
48 all:
49
50 export srctree OUTPUT CC LD CFLAGS V
51 include $(srctree)/tools/build/Makefile.include
52
53 all: 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
61 clean:
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
65 FORCE:
66
67 .PHONY: clean FORCE