Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Josh Poimboeuf | 4b6ab94 | 2015-12-15 09:39:39 -0600 | [diff] [blame] | 2 | include ../../scripts/Makefile.include |
Arnaldo Carvalho de Melo | ca70c24 | 2016-03-18 13:57:20 -0300 | [diff] [blame] | 3 | include ../../scripts/utilities.mak # QUIET_CLEAN |
Josh Poimboeuf | 4b6ab94 | 2015-12-15 09:39:39 -0600 | [diff] [blame] | 4 | |
| 5 | ifeq ($(srctree),) |
Uwe Kleine-König | e19b7ce | 2016-11-22 09:30:26 +0100 | [diff] [blame] | 6 | srctree := $(patsubst %/,%,$(dir $(CURDIR))) |
Josh Poimboeuf | 4b6ab94 | 2015-12-15 09:39:39 -0600 | [diff] [blame] | 7 | srctree := $(patsubst %/,%,$(dir $(srctree))) |
| 8 | srctree := $(patsubst %/,%,$(dir $(srctree))) |
| 9 | #$(info Determined 'srctree' to be $(srctree)) |
| 10 | endif |
| 11 | |
Josh Poimboeuf | c1d45c3 | 2016-03-02 18:39:37 -0600 | [diff] [blame] | 12 | CC ?= $(CROSS_COMPILE)gcc |
| 13 | LD ?= $(CROSS_COMPILE)ld |
| 14 | AR ?= $(CROSS_COMPILE)ar |
| 15 | |
Josh Poimboeuf | 4b6ab94 | 2015-12-15 09:39:39 -0600 | [diff] [blame] | 16 | RM = rm -f |
| 17 | |
| 18 | MAKEFLAGS += --no-print-directory |
| 19 | |
| 20 | LIBFILE = $(OUTPUT)libsubcmd.a |
| 21 | |
| 22 | CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) |
Arnaldo Carvalho de Melo | 49b3cd3 | 2017-02-14 10:55:27 -0300 | [diff] [blame] | 23 | CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC |
| 24 | |
David Carrillo-Cisneros | 3866058 | 2017-08-27 00:54:40 -0700 | [diff] [blame] | 25 | ifeq ($(CC_NO_CLANG), 0) |
Arnaldo Carvalho de Melo | 49b3cd3 | 2017-02-14 10:55:27 -0300 | [diff] [blame] | 26 | CFLAGS += -O3 |
| 27 | else |
| 28 | CFLAGS += -O6 |
| 29 | endif |
Chris Phlipot | fd01d06 | 2016-06-30 22:12:33 -0700 | [diff] [blame] | 30 | |
| 31 | # Treat warnings as errors unless directed not to |
| 32 | ifneq ($(WERROR),0) |
| 33 | CFLAGS += -Werror |
| 34 | endif |
| 35 | |
Josh Poimboeuf | 4b6ab94 | 2015-12-15 09:39:39 -0600 | [diff] [blame] | 36 | CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE |
| 37 | |
| 38 | CFLAGS += -I$(srctree)/tools/include/ |
| 39 | CFLAGS += -I$(srctree)/include/uapi |
| 40 | CFLAGS += -I$(srctree)/include |
| 41 | |
| 42 | SUBCMD_IN := $(OUTPUT)libsubcmd-in.o |
| 43 | |
| 44 | all: |
| 45 | |
| 46 | export srctree OUTPUT CC LD CFLAGS V |
| 47 | include $(srctree)/tools/build/Makefile.include |
| 48 | |
| 49 | all: 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 | |
| 57 | clean: |
| 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 | |
| 61 | FORCE: |
| 62 | |
| 63 | .PHONY: clean FORCE |