blob: 79003918f37f2593e157778734f2bb83d131abb1 [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
21sed-$(CONFIG_MIPS) := "/^@@@/s///p"
22
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020023quiet_cmd_offsets = GEN $@
24define cmd_offsets
Sam Ravnborg8d36a622005-09-10 21:05:36 +020025 mkdir -p $(dir $@); \
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020026 cat $< | \
27 (set -e; \
28 echo "#ifndef __ASM_OFFSETS_H__"; \
29 echo "#define __ASM_OFFSETS_H__"; \
30 echo "/*"; \
31 echo " * DO NOT MODIFY."; \
32 echo " *"; \
33 echo " * This file was generated by $(srctree)/Kbuild"; \
34 echo " *"; \
35 echo " */"; \
36 echo ""; \
Sam Ravnborg048eb582005-09-09 22:32:31 +020037 sed -ne $(sed-y); \
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020038 echo ""; \
39 echo "#endif" ) > $@
40endef
41
42# We use internal kbuild rules to avoid the "is up to date" message from make
43arch/$(ARCH)/kernel/asm-offsets.s: arch/$(ARCH)/kernel/asm-offsets.c FORCE
44 $(Q)mkdir -p $(dir $@)
45 $(call if_changed_dep,cc_s_c)
46
Sam Ravnborg8d36a622005-09-10 21:05:36 +020047$(obj)/$(offsets-file): arch/$(ARCH)/kernel/asm-offsets.s Kbuild
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020048 $(call cmd,offsets)
49