Smart-Home am Beispiel der Präsenzerkennung im Raum Projektarbeit Lennart Heimbs, Johannes Krug, Sebastian Dohle und Kevin Holzschuh bei Prof. Oliver Hofmann SS2019
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.

Makefile 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #############################################################################
  2. #
  3. # Makefile for MySensors
  4. #
  5. #
  6. # The arduino library build part were inspired by
  7. # Arduino-Makefile project, Copyright (C) 2012 Sudar <http://sudarmuthu.com>
  8. #
  9. # Description:
  10. # ------------
  11. # use make all and make install to install the gateway
  12. #
  13. CONFIG_FILE=Makefile.inc
  14. include $(CONFIG_FILE)
  15. CPPFLAGS+=-Ofast -g -Wall -Wextra
  16. DEPFLAGS=-MT $@ -MMD -MP
  17. GATEWAY_BIN=mysgw
  18. GATEWAY=$(BINDIR)/$(GATEWAY_BIN)
  19. GATEWAY_C_SOURCES=$(wildcard drivers/Linux/*.c)
  20. GATEWAY_CPP_SOURCES=$(wildcard drivers/Linux/*.cpp) examples_linux/mysgw.cpp
  21. GATEWAY_OBJECTS=$(patsubst %.c,$(BUILDDIR)/%.o,$(GATEWAY_C_SOURCES)) $(patsubst %.cpp,$(BUILDDIR)/%.o,$(GATEWAY_CPP_SOURCES))
  22. INCLUDES=-I. -I./core -I./drivers/Linux
  23. ifeq ($(SOC),$(filter $(SOC),BCM2835 BCM2836 BCM2837))
  24. BCM_C_SOURCES=$(wildcard drivers/BCM/*.c)
  25. BCM_CPP_SOURCES=$(wildcard drivers/BCM/*.cpp)
  26. GATEWAY_OBJECTS+=$(patsubst %.c,$(BUILDDIR)/%.o,$(BCM_C_SOURCES)) $(patsubst %.cpp,$(BUILDDIR)/%.o,$(BCM_CPP_SOURCES))
  27. INCLUDES+=-I./drivers/BCM
  28. endif
  29. # Gets include flags for library
  30. get_library_includes = $(if $(and $(wildcard $(1)/src), $(wildcard $(1)/library.properties)), \
  31. -I$(1)/src, \
  32. $(addprefix -I,$(1) $(wildcard $(1)/utility)))
  33. # Gets all sources with given extension (param2) for library (path = param1)
  34. # for old (1.0.x) layout looks in . and "utility" directories
  35. # for new (1.5.x) layout looks in src and recursively its subdirectories
  36. get_library_files = $(if $(and $(wildcard $(1)/src), $(wildcard $(1)/library.properties)), \
  37. $(call rwildcard,$(1)/src/,*.$(2)), \
  38. $(wildcard $(1)/*.$(2) $(1)/utility/*.$(2)))
  39. ifdef ARDUINO_LIB_DIR
  40. ARDUINO=arduino
  41. ARDUINO_LIBS:=$(shell find $(ARDUINO_LIB_DIR) -mindepth 1 -maxdepth 1 -type d)
  42. ARDUINO_INCLUDES:=$(foreach lib, $(ARDUINO_LIBS), $(call get_library_includes,$(lib)))
  43. ARDUINO_LIB_CPP_SRCS:=$(foreach lib, $(ARDUINO_LIBS), $(call get_library_files,$(lib),cpp))
  44. ARDUINO_LIB_C_SRCS:=$(foreach lib, $(ARDUINO_LIBS), $(call get_library_files,$(lib),c))
  45. ARDUINO_LIB_AS_SRCS:=$(foreach lib, $(ARDUINO_LIBS), $(call get_library_files,$(lib),S))
  46. ARDUINO_LIB_OBJS=$(patsubst $(ARDUINO_LIB_DIR)/%.cpp,$(BUILDDIR)/arduinolibs/%.cpp.o,$(ARDUINO_LIB_CPP_SRCS)) \
  47. $(patsubst $(ARDUINO_LIB_DIR)/%.c,$(BUILDDIR)/arduinolibs/%.c.o,$(ARDUINO_LIB_C_SRCS)) \
  48. $(patsubst $(ARDUINO_LIB_DIR)/%.S,$(BUILDDIR)/arduinolibs/%.S.o,$(ARDUINO_LIB_AS_SRCS))
  49. INCLUDES+=$(ARDUINO_INCLUDES)
  50. DEPS+=$(ARDUINO_LIB_OBJS:.o=.d)
  51. endif
  52. DEPS+=$(GATEWAY_OBJECTS:.o=.d)
  53. .PHONY: all createdir cleanconfig clean install uninstall
  54. all: createdir $(ARDUINO) $(GATEWAY)
  55. createdir:
  56. @mkdir -p $(BUILDDIR) $(BINDIR)
  57. # Arduino libraries Build
  58. $(ARDUINO): CPPFLAGS+=-DARDUINO=100
  59. $(ARDUINO): $(ARDUINO_LIB_OBJS)
  60. @printf "[Done building Arduino Libraries]\n"
  61. # Gateway Build
  62. $(GATEWAY): $(GATEWAY_OBJECTS) $(ARDUINO_LIB_OBJS)
  63. $(CXX) $(LDFLAGS) -o $@ $(GATEWAY_OBJECTS) $(ARDUINO_LIB_OBJS)
  64. # Include all .d files
  65. -include $(DEPS)
  66. $(BUILDDIR)/arduinolibs/%.cpp.o: $(ARDUINO_LIB_DIR)/%.cpp
  67. @mkdir -p $(dir $@)
  68. $(CXX) $(DEPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
  69. $(BUILDDIR)/arduinolibs/%.c.o: $(ARDUINO_LIB_DIR)/%.c
  70. @mkdir -p $(dir $@)
  71. $(CC) $(DEPFLAGS) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) -c $< -o $@
  72. $(BUILDDIR)/arduinolibs/%.S.o: $(ARDUINO_LIB_DIR)/%.S
  73. @mkdir -p $(dir $@)
  74. $(CC) $(DEPFLAGS) $(CPPFLAGS) $(ASFLAGS) $(INCLUDES) -c $< -o $@
  75. $(BUILDDIR)/%.o: %.cpp
  76. @mkdir -p $(dir $@)
  77. $(CXX) $(DEPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
  78. $(BUILDDIR)/%.o: %.c
  79. @mkdir -p $(dir $@)
  80. $(CC) $(DEPFLAGS) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) -c $< -o $@
  81. # clear configuration files
  82. cleanconfig:
  83. @echo "[Cleaning configuration]"
  84. rm -rf $(CONFIG_FILE)
  85. # clear build files
  86. clean:
  87. @echo "[Cleaning]"
  88. rm -rf $(BUILDDIR) $(BINDIR)
  89. $(CONFIG_FILE):
  90. @echo "[Running configure]"
  91. @./configure --no-clean
  92. install: all install-gateway install-initscripts
  93. install-gateway:
  94. @echo "Installing $(GATEWAY) to ${DESTDIR}$(GATEWAY_DIR)"
  95. @install -m 0755 $(GATEWAY) ${DESTDIR}$(GATEWAY_DIR)
  96. install-initscripts:
  97. ifeq ($(INIT_SYSTEM), systemd)
  98. install -m0644 initscripts/mysgw.systemd ${DESTDIR}/etc/systemd/system/mysgw.service
  99. @sed -i -e "s|%gateway_dir%|${GATEWAY_DIR}|g" ${DESTDIR}/etc/systemd/system/mysgw.service
  100. systemctl daemon-reload
  101. @echo "MySensors gateway has been installed, to add to the boot run:"
  102. @echo " sudo systemctl enable mysgw.service"
  103. @echo "To start the gateway run:"
  104. @echo " sudo systemctl start mysgw.service"
  105. else ifeq ($(INIT_SYSTEM), sysvinit)
  106. install -m0755 initscripts/mysgw.sysvinit ${DESTDIR}/etc/init.d/mysgw
  107. @sed -i -e "s|%gateway_dir%|${GATEWAY_DIR}|g" ${DESTDIR}/etc/init.d/mysgw
  108. @echo "MySensors gateway has been installed, to add to the boot run:"
  109. @echo " sudo update-rc.d mysgw defaults"
  110. @echo "To start the gateway run:"
  111. @echo " sudo service mysgw start"
  112. endif
  113. uninstall:
  114. ifeq ($(INIT_SYSTEM), systemd)
  115. @echo "Stopping daemon mysgw (ignore errors)"
  116. -@systemctl stop mysgw.service
  117. @echo "removing files"
  118. rm /etc/systemd/system/mysgw.service $(GATEWAY_DIR)/$(GATEWAY_BIN)
  119. else ifeq ($(INIT_SYSTEM), sysvinit)
  120. @echo "Stopping daemon mysgw (ignore errors)"
  121. -@service mysgw stop
  122. @echo "removing files"
  123. rm /etc/init.d/mysgw $(GATEWAY_DIR)/$(GATEWAY_BIN)
  124. endif