Makefile 1.38 KB
Newer Older
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 8 9 10 11
srctree := $(patsubst %/,%,$(dir $(srctree)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
#$(info Determined 'srctree' to be $(srctree))
endif

12 13 14
CC ?= $(CROSS_COMPILE)gcc
AR ?= $(CROSS_COMPILE)ar
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 26 27 28
  CFLAGS += -O3
else
  CFLAGS += -O6
endif
29 30 31 32 33
endif

ifeq ($(DEBUG),0)
  CFLAGS += -D_FORTIFY_SOURCE
endif
34 35 36 37 38 39

# Treat warnings as errors unless directed not to
ifneq ($(WERROR),0)
  CFLAGS += -Werror
endif

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 45

RM = rm -f

46
API_IN := $(OUTPUT)libapi-in.o
47

48 49
all:

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 59

$(LIBFILE): $(API_IN)
	$(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