Makefile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Linux port: run from this directory.
  2. # make test panel core tests (no hardware, no libraries)
  3. # make lib panel core library for the Python UI (./radio-ui)
  4. # make pytest UI tests: MPD client, rendering, simulated panel
  5. # make dtbo device tree overlay
  6. # make module DRM driver, against KDIR (default: running kernel source)
  7. BUILD := build
  8. CC ?= gcc
  9. CFLAGS ?= -O2 -g
  10. CFLAGS += -std=gnu11 -Wall -Wextra -MMD -MP
  11. CFLAGS += -Idriver -Isim
  12. KDIR ?= /usr/src/linux
  13. CORE := driver/s1d13700_core.c
  14. SIM := sim/s1d13700_sim.c
  15. PYTHON ?= python3
  16. PANEL_LIB := $(BUILD)/libradiopanel.so
  17. .PHONY: all test asan lib pytest dtbo module clean
  18. all: test lib
  19. # ---- tests -----------------------------------------------------------------
  20. $(BUILD)/test_panel: tests/test_panel.c $(CORE) $(SIM)
  21. @mkdir -p $(dir $@)
  22. $(CC) $(CFLAGS) -o $@ $^
  23. $(BUILD)/test_panel_asan: tests/test_panel.c $(CORE) $(SIM)
  24. @mkdir -p $(dir $@)
  25. $(CC) $(CFLAGS) -fsanitize=address,undefined -fno-sanitize-recover=all -o $@ $^
  26. test: $(BUILD)/test_panel
  27. $<
  28. asan: $(BUILD)/test_panel_asan
  29. $<
  30. # ---- Python UI -------------------------------------------------------------
  31. lib: $(PANEL_LIB)
  32. $(PANEL_LIB): radio/libpanel.c $(CORE) $(SIM)
  33. @mkdir -p $(dir $@)
  34. $(CC) $(CFLAGS) -fPIC -shared -o $@ $^
  35. pytest: $(PANEL_LIB)
  36. $(PYTHON) -W 'ignore::DeprecationWarning:gi.events' -m unittest discover -s tests -p 'test_*.py' -v
  37. # ---- device tree and kernel module -----------------------------------------
  38. dtbo: $(BUILD)/radio-panel.dtbo
  39. $(BUILD)/radio-panel.dtbo: dts/radio-panel.dts
  40. @mkdir -p $(dir $@)
  41. dtc -@ -I dts -O dtb -o $@ $<
  42. module:
  43. $(MAKE) -C $(KDIR) M=$(CURDIR)/driver modules
  44. clean:
  45. rm -rf $(BUILD)
  46. -$(MAKE) -C $(KDIR) M=$(CURDIR)/driver clean
  47. -include $(shell find $(BUILD) -name '*.d' 2>/dev/null)