1
0

Makefile 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ARTIFACT = testwolfcrypt
  2. #Build architecture/variant string, possible values: x86, armv7le, etc...
  3. PLATFORM ?= armv7le
  4. #Build profile, possible values: release, debug, profile, coverage
  5. BUILD_PROFILE ?= debug
  6. CONFIG_NAME ?= $(PLATFORM)-$(BUILD_PROFILE)
  7. OUTPUT_DIR = build/$(CONFIG_NAME)
  8. TARGET = $(OUTPUT_DIR)/$(ARTIFACT)
  9. #Compiler definitions
  10. CC = qcc -Vgcc_nto$(PLATFORM)
  11. CXX = q++ -Vgcc_nto$(PLATFORM)_cxx
  12. LD = $(CC)
  13. #User defined include/preprocessor flags and libraries
  14. INCLUDES += -I../wolfssl
  15. INCLUDES += -I../../..
  16. #LIBS += -L/path/to/my/lib/$(PLATFORM)/usr/lib -lmylib
  17. LIBS += -L../wolfssl/$(OUTPUT_DIR) -lwolfssl -lm -lsocket
  18. #Compiler flags for build profiles
  19. CCFLAGS_release += -O2
  20. CCFLAGS_debug += -g -O0 -fno-builtin
  21. CCFLAGS_coverage += -g -O0 -ftest-coverage -fprofile-arcs -nopipe -Wc,-auxbase-strip,$@
  22. LDFLAGS_coverage += -ftest-coverage -fprofile-arcs
  23. CCFLAGS_profile += -g -O0 -finstrument-functions
  24. LIBS_profile += -lprofilingS
  25. #Generic compiler flags (which include build type flags)
  26. CCFLAGS_all += -DWOLFSSL_USER_SETTINGS -Wall -fmessage-length=0
  27. CCFLAGS_all += $(CCFLAGS_$(BUILD_PROFILE))
  28. #Shared library has to be compiled with -fPIC
  29. #CCFLAGS_all += -fPIC
  30. LDFLAGS_all += $(LDFLAGS_$(BUILD_PROFILE))
  31. LIBS_all += $(LIBS_$(BUILD_PROFILE))
  32. DEPS = -Wp,-MMD,$(OUTPUT_DIR)/$(notdir $(@:%.o=%.d)),-MT,$(OUTPUT_DIR)/$(notdir $@)
  33. #Macro to expand files recursively: parameters $1 - directory, $2 - extension, i.e. cpp
  34. rwildcard = $(wildcard $(addprefix $1/*.,$2)) $(foreach d,$(wildcard $1/*),$(call rwildcard,$d,$2))
  35. #Source list
  36. SRCS = $(call rwildcard, src, c)
  37. SRCS += ../../../wolfcrypt/test/test.c
  38. #Object files list
  39. OBJS = $(addprefix $(OUTPUT_DIR)/,$(addsuffix .o, $(basename $(SRCS))))
  40. #Compiling rule
  41. $(OUTPUT_DIR)/%.o: %.c
  42. @mkdir -p $(dir $(OUTPUT_DIR)/$(notdir $@))
  43. $(CC) -c $(DEPS) -o $(OUTPUT_DIR)/$(notdir $@) $(INCLUDES) $(CCFLAGS_all) $(CCFLAGS) $<
  44. #Linking rule
  45. $(TARGET):$(OBJS)
  46. $(LD) -o $(TARGET) $(LDFLAGS_all) $(LDFLAGS) $(foreach f, $(OBJS), $(OUTPUT_DIR)/$(notdir $(f))) $(LIBS_all) $(LIBS)
  47. #Rules section for default compilation and linking
  48. all: $(TARGET)
  49. clean:
  50. rm -fr $(OUTPUT_DIR)
  51. rebuild: clean all
  52. #Inclusion of dependencies (object files to source and includes)
  53. -include $(OBJS:%.o=%.d)