Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # -*- mode: makefile -*-
  2. .include "config.mk"
  3. CC=clang
  4. CFLAGS=-g -std=c11 -Wall ${SQLITE3_CFLAGS}
  5. LD=clang
  6. LDFLAGS=-lgpio -lfigpar -lpthread ${SQLITE3_LDFLAGS}
  7. SRCS=src/main.c src/util.c src/lcd.c src/ths.c src/button.c src/ui/screen.c\
  8. src/ui/datesel.c src/ui/statsby.c src/ui/datapoints.c src/ui/timesel.c\
  9. src/ui/statrange.c src/config.c src/ui/blankscreen.c src/drive.c\
  10. src/ui/exportscreen.c src/ui/setdatescreen.c src/ui/viewdatescreen.c\
  11. src/ui/powerscreen.c src/ui/settzscreen.c src/ui/cleardatascreen.c\
  12. src/async.c
  13. PROG=rpi4b-temp-humidity
  14. all: config.conf bin/${PROG}
  15. OBJS=${SRCS:C/^src/bin/:C/.c$/.o/}
  16. bin/${PROG}: ${OBJS}
  17. ${LD} ${LDFLAGS} -o ${@} ${OBJS}
  18. bin/main.o bin/config.o: config.mk
  19. bin/main.o bin/util.o bin/lcd.o bin/ths.o bin/button.o: src/util.h
  20. bin/ui/screen.o bin/ui/statsby.o bin/ui/datesel.o: src/util.h
  21. bin/ui/datapoints.o bin/ui/timesel.o bin/ui/statrange.o: src/util.h
  22. bin/ui/viewdatescreen.o bin/ui/setdatescreen.o bin/ui/powerscreen.o: src/util.h
  23. bin/ui/settzscreen.o bin/ui/cleardatascreen.o bin/async.o: src/util.h
  24. bin/main.o bin/lcd.o bin/screen.o bin/ui/datesel.o: src/lcd.h
  25. bin/ui/statsby.o bin/ui/timesel.o bin/ui/statrange.o: src/lcd.h
  26. bin/ui/datapoints.o bin/ui/viewdatescreen.o: src/lcd.h
  27. bin/ui/setdatescreen.o bin/ui/powerscreen.o: src/lcd.h
  28. bin/ui/settzscreen.o bin/ui/cleardatascreen.o: src/lcd.h
  29. bin/main.o bin/ui/screen.o bin/ui/statsby.o: src/ui/screen.h
  30. bin/ui/datesel.o bin/ui/datapoints.o bin/ui/timesel.o: src/ui/screen.h
  31. bin/ui/statrange.o bin/ui/setdatescreen.o: src/ui/screen.h
  32. bin/ui/viewdatescreen.o bin/ui/powerscreen.o: src/ui/screen.h
  33. bin/ui/settzscreen.o bin/ui/cleardatascreen.o: src/ui/screen.h
  34. bin/main.o bin/ui/datesel.o bin/ui/statsby.o: src/ui/datesel.h
  35. bin/ui/datapoints.o bin/ui/timesel.o bin/ui/statrange.o: src/ui/datesel.h
  36. bin/ui/setdatescreen.o: src/ui/datesel.h
  37. bin/main.o bin/ui/timesel.o bin/ui/datapoints.o: src/ui/timesel.h
  38. bin/ui/statrange.o bin/ui/setdatescreen.o: src/ui/timesel.h
  39. bin/main.o bin/ths.o: src/ths.h
  40. bin/main.o bin/config.o: src/config.h
  41. bin/main.o bin/button.o bin/ui/screen.o: src/button.h
  42. bin/main.o bin/ui/statsby.o: src/ui/statsby.h
  43. bin/main.o bin/ui/datapoints.o: src/ui/datapoints.h
  44. bin/main.o bin/ui/blankscreen.o: src/ui/blankscreen.h
  45. bin/main.o bin/ui/statrange.o: src/ui/statrange.h
  46. bin/main.o bin/ui/exportscreen.o: src/ui/exportscreen.h
  47. bin/main.o bin/ui/setdatescreen.o: src/ui/setdatescreen.h
  48. bin/main.o bin/ui/viewdatescreen.o: src/ui/viewdatescreen.h
  49. bin/main.o bin/ui/powerscreen.o: src/ui/powerscreen.h
  50. bin/main.o bin/ui/settzscreen.o: src/ui/settzscreen.h
  51. bin/main.o bin/ui/cleardatascreen.o: src/ui/cleardatascreen.h
  52. bin/main.o bin/drive.o bin/ui/exportscreen.o: src/drive.h
  53. bin/main.o bin/drive.o bin/ui/exportscreen.o: src/async.h
  54. .if "${DEFAULT_TEMP_UNIT}" != "F" && "${DEFAULT_TEMP_UNIT}" != "C" &&\
  55. "${DEFAULT_TEMP_UNIT}" != "c" && "${DEFAULT_TEMP_UNIT}" != "c"
  56. .error Invalid temperature unit "${DEFAULT_TEMP_UNIT}"
  57. .endif
  58. DEFINES:=\
  59. -DDEFAULT_CONFIG_PATH="${DEFAULT_CONFIG_PATH}"\
  60. -DDEFAULT_GPIO_DEVICE="${DEFAULT_GPIO_DEVICE}"\
  61. -DDEFAULT_TEMP_KEY="${DEFAULT_TEMP_KEY}"\
  62. -DDEFAULT_HUMID_KEY="${DEFAULT_HUMID_KEY}"\
  63. -DDEFAULT_FAIL_KEY="${DEFAULT_FAIL_KEY}"\
  64. -DDEFAULT_FAIL_LIMIT="${DEFAULT_FAIL_LIMIT}"\
  65. -DDEFAULT_DATABASE_LOCATION="${DEFAULT_DATABASE_LOCATION}"\
  66. -DDEFAULT_REFRESH_TIME="${DEFAULT_REFRESH_TIME}"\
  67. -DDEFAULT_TEMP_UNIT="${DEFAULT_TEMP_UNIT}"\
  68. -DDEFAULT_EXPORT_FILE_NAME="${DEFAULT_EXPORT_FILE_NAME}"\
  69. -DDEFAULT_TIMEZONE="${DEFAULT_TIMEZONE}"\
  70. ${OBJS}: ${.TARGET:C/^bin/src/:C/.o$/.c/}
  71. @mkdir -p ${.TARGET:H}
  72. ${CC} ${CFLAGS} -c ${DEFINES} -o ${@} ${.TARGET:C/^bin/src/:C/.o$/.c/}
  73. config.conf: config.conf.m4
  74. m4 ${DEFINES} config.conf.m4 >config.conf
  75. install: all
  76. mkdir -p "${PREFIX}/bin"
  77. install -o root -g wheel "bin/${PROG}" "${PREFIX}/bin"
  78. mkdir -p "${PREFIX}/etc/rpi4b-temp-humidity"
  79. install -b -o root -g wheel -m 0644 config.conf "${PREFIX}/etc/rpi4b-temp-humidity"
  80. install -o root -g wheel -m 0555 rpi4b-temp-humidity "${PREFIX}/etc/rc.d"
  81. clean:
  82. rm -rf config.conf bin/
  83. .SUFFIXES: .c .o
  84. .PHONY: all install clean