Makefile 1.4 KB

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