Makefile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. $(info TARGET is $(TARGET))
  2. ifeq ($(TARGET), 03)
  3. PROG ?= ./modbus_03 # Program we are building
  4. else ifeq ($(TARGET), 06)
  5. PROG = ./modbus_06 # Program we are building
  6. else
  7. PROG = ./modbus_06 ./modbus_03# Program we are building
  8. endif
  9. PACK ?= ./pack # Packing executable
  10. DELETE = rm -rf # Command to remove files
  11. GZIP ?= gzip # For compressing files in web_root/
  12. OUT ?= -o $(PROG) # Compiler argument for output file
  13. SOURCES = main.c \
  14. ./libmodbus/src/modbus.c \
  15. ./libmodbus/src/modbus-data.c \
  16. ./libmodbus/src/modbus-rtu.c \
  17. ./libmodbus/src/modbus-tcp.c
  18. SHELL := /bin/bash
  19. CFLAGS = -w -g -I. -I./libmodbus -I./libmodbus/src
  20. ifeq ($(TARGET), 03)
  21. CFLAGS += -DCODE_03
  22. else ifeq ($(TARGET), 06)
  23. CFLAGS += -DCODE_06
  24. endif
  25. CFLAGS_EXTRA = -lpthread
  26. NPX ?= npx
  27. # em-500
  28. CC=arm-zen-linux-gnueabihf-gcc
  29. # CC=gcc
  30. # HTNICE GT6517
  31. #CC=arm-linux-gcc -std=c99
  32. ENV_SCRIPT = /home/cyx/environment-arm-zen-gnueabihf-toolchain.sh
  33. # Mongoose build options. See https://mongoose.ws/documentation/#build-options
  34. CFLAGS_MONGOOSE += -DMG_ENABLE_PACKED_FS=0
  35. ifeq ($(OS),Windows_NT) # Windows settings. Assume MinGW compiler. To use VC: make CC=cl CFLAGS=/MD OUT=/Feprog.exe
  36. # PROG = ctn2.exe # Use .exe suffix for the binary
  37. # PACK = pack.exe # Packing executable
  38. CC = arm-none-linux-gnueabihf-gcc # Use MinGW gcc compiler
  39. # CFLAGS += -lws2_32 # Link against Winsock library
  40. # DELETE = cmd /C del /Q /F /S # Command prompt command to delete files
  41. # GZIP = echo # No gzip on Windows
  42. endif
  43. # Default target. Build and run program
  44. all: $(PROG)
  45. # $(RUN) $(PROG) $(ARGS)
  46. # Build program from sources
  47. $(PROG): $(SOURCES)
  48. source $(ENV_SCRIPT) && \
  49. $(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT)
  50. # Cleanup. Delete built program and all build artifacts
  51. clean:
  52. $(DELETE) $(PROG) $(PACK) *.o *.obj *.exe *.dSYM mbedtls