Merge branch 'master' into isa/arm64
[lunaix-os.git] / lunaix-os / tests / units / device-tree / makefile
diff --git a/lunaix-os/tests/units/device-tree/makefile b/lunaix-os/tests/units/device-tree/makefile
new file mode 100644 (file)
index 0000000..4d9d530
--- /dev/null
@@ -0,0 +1,38 @@
+include test_build.mkinc
+
+tests := $(shell cat tests.txt)
+
+obj = dut/dt_interrupt.o \
+         dut/dt.o \
+         dut/dtspec.o \
+         dut/changeling.o \
+
+dtbs := $(addprefix samples/,$(addsuffix .dtb,$(tests)))
+
+tests := $(addsuffix .test,$(tests))
+run_tests := $(addprefix run.,$(tests))
+
+%.dtb: %.dts
+       $(call status,DTC,$^)
+       @dtc -q -I dts -O dtb $^ -o $@
+
+.PHONY: all run clean
+
+load.%.o:: load.c
+       $(call status,CC,$@)
+       @$(CC) $(CFLAGS) -DTEST_DTBFILE=\"samples/$*.dtb\" -c $^ -o $@
+
+%.test: $(obj-shared) $(obj-stubs) $(obj) test-%.o load.%.o
+       $(call status,LD,$@)
+       @$(CC) $^ -o $@
+
+run.%.test: %.test
+       $(call status,RUN,$^)
+       @./$^
+
+all: $(dtbs) $(tests)
+
+run: $(dtbs) $(tests) $(run_tests)
+
+clean:
+       @rm -f *.o $(obj) $(test) $(dtbs)
\ No newline at end of file