netns xfrm: fix "ip xfrm state|policy count" misreport
[safe/jmp/linux-2.6] / scripts / Makefile.build
index b5efa98..0b94d2f 100644 (file)
@@ -27,6 +27,9 @@ ccflags-y  :=
 cppflags-y :=
 ldflags-y  :=
 
+subdir-asflags-y :=
+subdir-ccflags-y :=
+
 # Read auto.conf if it exists, otherwise ignore
 -include include/config/auto.conf
 
@@ -151,16 +154,16 @@ cmd_cc_i_c       = $(CPP) $(c_flags)   -o $@ $<
 $(obj)/%.i: $(src)/%.c FORCE
        $(call if_changed_dep,cc_i_c)
 
-cmd_genksyms =                                                              \
+cmd_gensymtypes =                                                           \
     $(CPP) -D__GENKSYMS__ $(c_flags) $< |                                   \
-    $(GENKSYMS) -T $@ -A -a $(ARCH)                                         \
+    $(GENKSYMS) -T $@ -a $(ARCH)                                            \
      $(if $(KBUILD_PRESERVE),-p)                                            \
      $(if $(1),-r $(firstword $(wildcard $(@:.symtypes=.symref) /dev/null)))
 
 quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
 cmd_cc_symtypes_c =                                                         \
     set -e;                                                                 \
-    $(call cmd_genksyms, true) >/dev/null;                                  \
+    $(call cmd_gensymtypes, true) >/dev/null;                               \
     test -s $@ || rm -f $@
 
 $(obj)/%.symtypes : $(src)/%.c FORCE
@@ -177,43 +180,34 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
 
 else
 # When module versioning is enabled the following steps are executed:
-# o compile a .tmp_<file>.s from <file>.c
-# o if .tmp_<file>.s doesn't contain a __ksymtab version, i.e. does
-#   not export symbols, we just assemble .tmp_<file>.s to <file>.o and
+# o compile a .tmp_<file>.o from <file>.c
+# o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does
+#   not export symbols, we just rename .tmp_<file>.o to <file>.o and
 #   are done.
 # o otherwise, we calculate symbol versions using the good old
 #   genksyms on the preprocessed source and postprocess them in a way
-#   that they are usable as assembly source
-# o assemble <file>.o from .tmp_<file>.s forcing inclusion of directives
-#   defining the actual values of __crc_*, followed by objcopy-ing them
-#   to force these symbols to be local to permit stripping them later.
-s_file = $(@D)/.tmp_$(@F:.o=.s)
-v_file = $(@D)/.tmp_$(@F:.o=.v)
-tmp_o_file = $(@D)/.tmp_$(@F)
-no_g_c_flags = $(filter-out -g%,$(c_flags))
-
-cmd_cc_o_c = $(CC) $(c_flags) -S -o $(s_file) $<
+#   that they are usable as a linker script
+# o generate <file>.o from .tmp_<file>.o using the linker to
+#   replace the unresolved symbols __crc_exported_symbol with
+#   the actual value of the checksum generated by genksyms
 
+cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
 cmd_modversions =                                                      \
-       if grep -q __ksymtab $(s_file); then                            \
-               if $(call cmd_genksyms, $(KBUILD_SYMTYPES)) > $(v_file) \
-                  && $(CC) $(no_g_c_flags) -c -Wa,$(v_file)            \
-                           -o $(tmp_o_file) $(s_file)                  \
-                  && $(OBJCOPY) -L '__crc_*' -L '___crc_*' -w          \
-                                $(tmp_o_file) $@;                      \
-               then                                                    \
-                       : ;                                             \
-               else                                                    \
-                       rm -f $@; exit 1;                               \
-               fi;                                                     \
+       if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then     \
+               $(call cmd_gensymtypes, $(KBUILD_SYMTYPES))             \
+                   > $(@D)/.tmp_$(@F:.o=.ver);                         \
+                                                                       \
+               $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F)              \
+                       -T $(@D)/.tmp_$(@F:.o=.ver);                    \
+               rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver);        \
        else                                                            \
-               rm -f $(v_file);                                        \
-               $(CC) $(no_g_c_flags) -c -o $@ $(s_file);               \
+               mv -f $(@D)/.tmp_$(@F) $@;                              \
        fi;
 endif
 
 ifdef CONFIG_FTRACE_MCOUNT_RECORD
-cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
+cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
+       "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
        "$(if $(CONFIG_64BIT),64,32)" \
        "$(OBJDUMP)" "$(OBJCOPY)" "$(CC)" "$(LD)" "$(NM)" "$(RM)" "$(MV)" \
        "$(if $(part-of-module),1,0)" "$(@)";
@@ -223,15 +217,11 @@ define rule_cc_o_c
        $(call echo-cmd,checksrc) $(cmd_checksrc)                         \
        $(call echo-cmd,cc_o_c) $(cmd_cc_o_c);                            \
        $(cmd_modversions)                                                \
+       $(call echo-cmd,record_mcount)                                    \
        $(cmd_record_mcount)                                              \
        scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' >    \
                                                      $(dot-target).tmp;  \
-       if [ -r $(@D)/.tmp_$(@F:.o=.v) ]; then                            \
-               echo >> $(dot-target).tmp;                                \
-               echo '$@: $(GENKSYMS)' >> $(dot-target).tmp;              \
-               echo '$(GENKSYMS):: ;' >> $(dot-target).tmp;              \
-       fi;                                                               \
-       rm -f $(depfile) $(@D)/.tmp_$(@F:.o=.?);                          \
+       rm -f $(depfile);                                                 \
        mv -f $(dot-target).tmp $(dot-target).cmd
 endef
 
@@ -281,7 +271,8 @@ targets += $(extra-y) $(MAKECMDGOALS) $(always)
 # Linker scripts preprocessor (.lds.S -> .lds)
 # ---------------------------------------------------------------------------
 quiet_cmd_cpp_lds_S = LDS     $@
-      cmd_cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -o $@ $<
+      cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
+                            -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
 
 $(obj)/%.lds: $(src)/%.lds.S FORCE
        $(call if_changed_dep,cpp_lds_S)