Skip to content

Instantly share code, notes, and snippets.

@luaraneda
Created April 17, 2016 21:03
Show Gist options
  • Save luaraneda/c12d5d111d6ccac00319d1948b2fc955 to your computer and use it in GitHub Desktop.
Save luaraneda/c12d5d111d6ccac00319d1948b2fc955 to your computer and use it in GitHub Desktop.
Makefile to compile a single device-tree
# Makefile to compile a single device-tree
# Main .dts file without extension
MAIN_DTS_FILE:=sun6i-a31s-sinovoip-bpi-m2
# C preprocessor flags (for dts parsing)
DTS_CPP_FLAGS := -nostdinc -Iinclude -undef -D__DTS__ -x assembler-with-cpp
## Targets
all: ${MAIN_DTS_FILE}.dtb
# Temporal file generated by the C preprocessor
${MAIN_DTS_FILE}.dts.tmp:
cpp -Wp,-MD,${MAIN_DTS_FILE}.dts.dep.tmp ${DTS_CPP_FLAGS} -o ${MAIN_DTS_FILE}.dts.tmp ${MAIN_DTS_FILE}.dts
# Actual compilation using the temporal file as input
${MAIN_DTS_FILE}.dtb: ${MAIN_DTS_FILE}.dts.tmp
dtc -O dtb -o ${MAIN_DTS_FILE}.dtb -b 0 -d ${MAIN_DTS_FILE}.dts.dep.tmp ${MAIN_DTS_FILE}.dts.tmp
# Clean only temporal files
clean_tmp:
rm -rf *.tmp
# Clean all temporal and outputs files
clean: clean_tmp
rm -rf *.dtb
@arthurafarias
Copy link

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment