Makefile 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # SPDX-License-Identifier: GPL-2.0
  2. include ../../scripts/Makefile.include
  3. include ../../scripts/utilities.mak # QUIET_CLEAN
  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. CC ?= $(CROSS_COMPILE)gcc
  11. LD ?= $(CROSS_COMPILE)ld
  12. AR ?= $(CROSS_COMPILE)ar
  13. RM = rm -f
  14. MAKEFLAGS += --no-print-directory
  15. LIBFILE = $(OUTPUT)libsubcmd.a
  16. CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
  17. CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -fPIC
  18. ifeq ($(DEBUG),0)
  19. ifeq ($(feature-fortify-source), 1)
  20. CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
  21. endif
  22. endif
  23. ifeq ($(DEBUG),1)
  24. CFLAGS += -O0
  25. else ifeq ($(CC_NO_CLANG), 0)
  26. CFLAGS += -O3
  27. else
  28. CFLAGS += -O6
  29. endif
  30. # Treat warnings as errors unless directed not to
  31. ifneq ($(WERROR),0)
  32. CFLAGS += -Werror
  33. endif
  34. CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
  35. CFLAGS += -I$(srctree)/tools/include/
  36. SUBCMD_IN := $(OUTPUT)libsubcmd-in.o
  37. all:
  38. export srctree OUTPUT CC LD CFLAGS V
  39. include $(srctree)/tools/build/Makefile.include
  40. all: fixdep $(LIBFILE)
  41. $(SUBCMD_IN): FORCE
  42. @$(MAKE) $(build)=libsubcmd
  43. $(LIBFILE): $(SUBCMD_IN)
  44. $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SUBCMD_IN)
  45. clean:
  46. $(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \
  47. find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
  48. FORCE:
  49. .PHONY: clean FORCE