summaryrefslogblamecommitdiffstats
path: root/Kbuild
blob: 519be4a3c22beda83a565e7f1838e03f97becb85 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                  
 



                                           


                                               
                           

                                            







                                                                           


                                                                             










                                                       
                      

     

                                                        
# SPDX-License-Identifier: GPL-2.0
#
# Kbuild for top-level directory of Barebox

#####
# Generate asm-offsets.h

offsets-file := include/generated/asm-offsets.h

always-y += $(offsets-file)
targets += arch/$(SRCARCH)/lib/asm-offsets.s

# Default sed regexp - multiline due to syntax constraints
define sed-y
	"/^->/{s:->#\(.*\):/* \1 */:; \
	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
	s:->::; p;}"
endef

# Use filechk to avoid rebuilds when a header changes, but the resulting file
# does not
define filechk_offsets
	 echo "#ifndef __ASM_OFFSETS_H__"; \
	 echo "#define __ASM_OFFSETS_H__"; \
	 echo "/*"; \
	 echo " * DO NOT MODIFY."; \
	 echo " *"; \
	 echo " * This file was generated by Kbuild"; \
	 echo " *"; \
	 echo " */"; \
	 echo ""; \
	 sed -ne $(sed-y) $<; \
	 echo ""; \
	 echo "#endif"
endef

$(offsets-file): arch/$(SRCARCH)/lib/asm-offsets.s FORCE
	$(call filechk,offsets)