I2C toy code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

44 lines
891 B

  1. objify = $(patsubst %.c,obj/%.$2,$(patsubst %.s,obj/%.$2,$1))
  2. CC=clang
  3. INC = -Iext/libtomcrypt/src/headers
  4. CFLAGS = -std=c99 -D_GNU_SOURCE
  5. CFLAGS += -Wextra -Wall -Werror -Wno-missing-braces -Wno-missing-field-initializers $(INC)
  6. LDFLAGS = -Lext/libtomcrypt -ltomcrypt
  7. DIRS=bin obj out
  8. OBJS = $(call objify,$(SRC),o)
  9. # Enable for testing only
  10. DEBUG=1
  11. ifeq ($(DEBUG), 1)
  12. CFLAGS += -g -O0 -fsanitize=undefined,leak,address
  13. LDFLAGS += -fsanitize=undefined,leak,address
  14. CC=clang
  15. else
  16. CFLAGS += -O2
  17. endif
  18. # source files
  19. SRC = \
  20. src/crypt.c \
  21. src/i2c.c \
  22. src/main.c
  23. all: libtomcrypt bin/main
  24. obj/%.o: %.c
  25. case $@ in */*) f=$@; mkdir -p $${f%/*} ;; esac
  26. $(CC) -o $@ -c $< $(CFLAGS)
  27. bin/main: $(OBJS)
  28. case $@ in */*) f=$@; mkdir -p $${f%/*} ;; esac
  29. $(CC) -o bin/main $(OBJS) $(LDFLAGS)
  30. clean:
  31. rm -rf $(DIRS)
  32. make -C ext/libtomcrypt clean
  33. libtomcrypt:
  34. make -C ext/libtomcrypt