xref: /linux/scripts/mod/Makefile (revision 6543becf26fff612cdadeed7250ccc8d49f67f27)
11da177e4SLinus Torvaldshostprogs-y	:= modpost mk_elfconfig
21da177e4SLinus Torvaldsalways		:= $(hostprogs-y) empty.o
31da177e4SLinus Torvalds
41da177e4SLinus Torvaldsmodpost-objs	:= modpost.o file2alias.o sumversion.o
51da177e4SLinus Torvalds
6*6543becfSAndreas Schwabdevicetable-offsets-file := devicetable-offsets.h
7*6543becfSAndreas Schwab
8*6543becfSAndreas Schwabdefine sed-y
9*6543becfSAndreas Schwab	"/^->/{s:->#\(.*\):/* \1 */:; \
10*6543becfSAndreas Schwab	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
11*6543becfSAndreas Schwab	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
12*6543becfSAndreas Schwab	s:->::; p;}"
13*6543becfSAndreas Schwabendef
14*6543becfSAndreas Schwab
15*6543becfSAndreas Schwabquiet_cmd_offsets = GEN     $@
16*6543becfSAndreas Schwabdefine cmd_offsets
17*6543becfSAndreas Schwab	(set -e; \
18*6543becfSAndreas Schwab	 echo "#ifndef __DEVICEVTABLE_OFFSETS_H__"; \
19*6543becfSAndreas Schwab	 echo "#define __DEVICEVTABLE_OFFSETS_H__"; \
20*6543becfSAndreas Schwab	 echo "/*"; \
21*6543becfSAndreas Schwab	 echo " * DO NOT MODIFY."; \
22*6543becfSAndreas Schwab	 echo " *"; \
23*6543becfSAndreas Schwab	 echo " * This file was generated by Kbuild"; \
24*6543becfSAndreas Schwab	 echo " *"; \
25*6543becfSAndreas Schwab	 echo " */"; \
26*6543becfSAndreas Schwab	 echo ""; \
27*6543becfSAndreas Schwab	 sed -ne $(sed-y) $<; \
28*6543becfSAndreas Schwab	 echo ""; \
29*6543becfSAndreas Schwab	 echo "#endif" ) > $@
30*6543becfSAndreas Schwabendef
31*6543becfSAndreas Schwab
32*6543becfSAndreas Schwab# We use internal kbuild rules to avoid the "is up to date" message from make
33*6543becfSAndreas Schwabscripts/mod/devicetable-offsets.s: scripts/mod/devicetable-offsets.c FORCE
34*6543becfSAndreas Schwab	$(Q)mkdir -p $(dir $@)
35*6543becfSAndreas Schwab	$(call if_changed_dep,cc_s_c)
36*6543becfSAndreas Schwab
37*6543becfSAndreas Schwab$(obj)/$(devicetable-offsets-file): scripts/mod/devicetable-offsets.s
38*6543becfSAndreas Schwab	$(call cmd,offsets)
39*6543becfSAndreas Schwab
401da177e4SLinus Torvalds# dependencies on generated files need to be listed explicitly
411da177e4SLinus Torvalds
421da177e4SLinus Torvalds$(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h
43*6543becfSAndreas Schwab$(obj)/file2alias.o: $(obj)/$(devicetable-offsets-file)
441da177e4SLinus Torvalds
451da177e4SLinus Torvaldsquiet_cmd_elfconfig = MKELF   $@
469e1b9b80SAlan Jenkins      cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@
471da177e4SLinus Torvalds
481da177e4SLinus Torvalds$(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE
491da177e4SLinus Torvalds	$(call if_changed,elfconfig)
501da177e4SLinus Torvalds
511da177e4SLinus Torvaldstargets += elfconfig.h
52