blob: 0451f69353bad4d07de34fd4658f40b805bd467a [file] [log] [blame]
Sam Ravnborg86feeaa2005-09-09 19:28:28 +02001#
2# Kbuild for top-level directory of the kernel
3# This file takes care of the following:
4# 1) Generate asm-offsets.h
5
6#####
Sam Ravnborg8d36a622005-09-10 21:05:36 +02007# 1) Generate asm-offsets.h
Sam Ravnborg86feeaa2005-09-09 19:28:28 +02008#
9
10offsets-file := include/asm-$(ARCH)/asm-offsets.h
11
12always := $(offsets-file)
13targets := $(offsets-file)
14targets += arch/$(ARCH)/kernel/asm-offsets.s
15
Sam Ravnborg048eb582005-09-09 22:32:31 +020016# Default sed regexp - multiline due to syntax constraints
17define sed-y
18 "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"
19endef
20# Override default regexp for specific architectures
Atsushi Nemoto09476402006-03-28 00:18:54 +090021sed-$(CONFIG_MIPS) := "/^@@@/{s/^@@@//; s/ \#.*\$$//; p;}"
Sam Ravnborg048eb582005-09-09 22:32:31 +020022
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020023quiet_cmd_offsets = GEN $@
24define cmd_offsets
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020025 (set -e; \
26 echo "#ifndef __ASM_OFFSETS_H__"; \
27 echo "#define __ASM_OFFSETS_H__"; \
28 echo "/*"; \
29 echo " * DO NOT MODIFY."; \
30 echo " *"; \
Olaf Hering65ff22e2006-07-25 18:42:26 -070031 echo " * This file was generated by Kbuild"; \
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020032 echo " *"; \
33 echo " */"; \
34 echo ""; \
Brian Gerstac448af2006-01-06 18:28:45 -050035 sed -ne $(sed-y) $<; \
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020036 echo ""; \
37 echo "#endif" ) > $@
38endef
39
40# We use internal kbuild rules to avoid the "is up to date" message from make
41arch/$(ARCH)/kernel/asm-offsets.s: arch/$(ARCH)/kernel/asm-offsets.c FORCE
42 $(Q)mkdir -p $(dir $@)
43 $(call if_changed_dep,cc_s_c)
44
Sam Ravnborg8d36a622005-09-10 21:05:36 +020045$(obj)/$(offsets-file): arch/$(ARCH)/kernel/asm-offsets.s Kbuild
Brian Gerstac448af2006-01-06 18:28:45 -050046 $(Q)mkdir -p $(dir $@)
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020047 $(call cmd,offsets)
48