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