blob: 95563b8e1ad743433076257d8f04d3740e2e55da [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Josh Poimboeuf4b6ab942015-12-15 09:39:39 -06002include ../../scripts/Makefile.include
Arnaldo Carvalho de Meloca70c242016-03-18 13:57:20 -03003include ../../scripts/utilities.mak # QUIET_CLEAN
Josh Poimboeuf4b6ab942015-12-15 09:39:39 -06004
5ifeq ($(srctree),)
Uwe Kleine-Könige19b7ce2016-11-22 09:30:26 +01006srctree := $(patsubst %/,%,$(dir $(CURDIR)))
Josh Poimboeuf4b6ab942015-12-15 09:39:39 -06007srctree := $(patsubst %/,%,$(dir $(srctree)))
8srctree := $(patsubst %/,%,$(dir $(srctree)))
9#$(info Determined 'srctree' to be $(srctree))
10endif
11
Josh Poimboeufc1d45c32016-03-02 18:39:37 -060012CC ?= $(CROSS_COMPILE)gcc
13LD ?= $(CROSS_COMPILE)ld
14AR ?= $(CROSS_COMPILE)ar
15
Josh Poimboeuf4b6ab942015-12-15 09:39:39 -060016RM = rm -f
17
18MAKEFLAGS += --no-print-directory
19
20LIBFILE = $(OUTPUT)libsubcmd.a
21
22CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
Arnaldo Carvalho de Melo49b3cd32017-02-14 10:55:27 -030023CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
24
David Carrillo-Cisneros38660582017-08-27 00:54:40 -070025ifeq ($(CC_NO_CLANG), 0)
Arnaldo Carvalho de Melo49b3cd32017-02-14 10:55:27 -030026 CFLAGS += -O3
27else
28 CFLAGS += -O6
29endif
Chris Phlipotfd01d062016-06-30 22:12:33 -070030
31# Treat warnings as errors unless directed not to
32ifneq ($(WERROR),0)
33 CFLAGS += -Werror
34endif
35
Josh Poimboeuf4b6ab942015-12-15 09:39:39 -060036CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
37
38CFLAGS += -I$(srctree)/tools/include/
39CFLAGS += -I$(srctree)/include/uapi
40CFLAGS += -I$(srctree)/include
41
42SUBCMD_IN := $(OUTPUT)libsubcmd-in.o
43
44all:
45
46export srctree OUTPUT CC LD CFLAGS V
47include $(srctree)/tools/build/Makefile.include
48
49all: fixdep $(LIBFILE)
50
51$(SUBCMD_IN): FORCE
52 @$(MAKE) $(build)=libsubcmd
53
54$(LIBFILE): $(SUBCMD_IN)
55 $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SUBCMD_IN)
56
57clean:
58 $(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \
59 find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
60
61FORCE:
62
63.PHONY: clean FORCE