blob: c7ceea6dd6cb7f0186623c7c9f6d75fe5d0461fe [file] [log] [blame]
Borislav Petkov85c66be2013-02-20 16:32:30 +01001include ../../scripts/Makefile.include
Arnaldo Carvalho de Meloca70c242016-03-18 13:57:20 -03002include ../../scripts/utilities.mak # QUIET_CLEAN
Borislav Petkov85c66be2013-02-20 16:32:30 +01003
Jiri Olsab4f916682015-01-09 16:38:25 +01004ifeq ($(srctree),)
5srctree := $(patsubst %/,%,$(dir $(shell pwd)))
6srctree := $(patsubst %/,%,$(dir $(srctree)))
7srctree := $(patsubst %/,%,$(dir $(srctree)))
8#$(info Determined 'srctree' to be $(srctree))
9endif
10
Rabin Vincent3c4797d2013-05-17 22:27:44 +020011CC = $(CROSS_COMPILE)gcc
12AR = $(CROSS_COMPILE)ar
Lucas Stach703e0162016-03-17 18:27:50 +010013LD = $(CROSS_COMPILE)ld
Rabin Vincent3c4797d2013-05-17 22:27:44 +020014
Jiri Olsab4f916682015-01-09 16:38:25 +010015MAKEFLAGS += --no-print-directory
Borislav Petkov85c66be2013-02-20 16:32:30 +010016
Jiri Olsa285a8f22015-01-10 20:53:13 +010017LIBFILE = $(OUTPUT)libapi.a
Borislav Petkov85c66be2013-02-20 16:32:30 +010018
Jiri Olsab4f916682015-01-09 16:38:25 +010019CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
Chris Phlipotb983d542016-06-30 22:12:32 -070020CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
21
22# Treat warnings as errors unless directed not to
23ifneq ($(WERROR),0)
24 CFLAGS += -Werror
25endif
26
Jiri Olsab4f916682015-01-09 16:38:25 +010027CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
Jiri Olsa975f14f2016-02-14 17:03:42 +010028CFLAGS += -I$(srctree)/tools/lib/api
Borislav Petkov85c66be2013-02-20 16:32:30 +010029
30RM = rm -f
31
Jiri Olsa285a8f22015-01-10 20:53:13 +010032API_IN := $(OUTPUT)libapi-in.o
Borislav Petkov85c66be2013-02-20 16:32:30 +010033
Jiri Olsa7c422f52015-09-23 12:34:02 +020034all:
35
Jiri Olsab4f916682015-01-09 16:38:25 +010036export srctree OUTPUT CC LD CFLAGS V
Jiri Olsaab6201d2015-09-23 12:33:56 +020037include $(srctree)/tools/build/Makefile.include
Borislav Petkov85c66be2013-02-20 16:32:30 +010038
Jiri Olsa7c422f52015-09-23 12:34:02 +020039all: fixdep $(LIBFILE)
Borislav Petkov553873e2013-12-09 17:14:23 +010040
Jiri Olsab4f916682015-01-09 16:38:25 +010041$(API_IN): FORCE
Jiri Olsa285a8f22015-01-10 20:53:13 +010042 @$(MAKE) $(build)=libapi
Jiri Olsab4f916682015-01-09 16:38:25 +010043
44$(LIBFILE): $(API_IN)
45 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(API_IN)
Borislav Petkov85c66be2013-02-20 16:32:30 +010046
47clean:
Jiri Olsa285a8f22015-01-10 20:53:13 +010048 $(call QUIET_CLEAN, libapi) $(RM) $(LIBFILE); \
Riku Voipioc867b152015-06-18 15:52:18 +030049 find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
Borislav Petkov85c66be2013-02-20 16:32:30 +010050
Jiri Olsab4f916682015-01-09 16:38:25 +010051FORCE:
52
53.PHONY: clean FORCE