2
0

001-fix_build.patch 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. --- a/Makefile
  2. +++ b/Makefile
  3. @@ -5,7 +5,7 @@
  4. ifeq ($(KERNELRELEASE),)
  5. MAKEFLAGS += --no-print-directory
  6. -SHELL := /bin/bash
  7. +SHELL := /usr/bin/env bash
  8. BACKPORT_DIR := $(shell pwd)
  9. KMODDIR ?= updates
  10. @@ -19,6 +19,7 @@ KLIB_BUILD ?= $(KLIB)/build/
  11. KERNEL_CONFIG := $(KLIB_BUILD)/.config
  12. KERNEL_MAKEFILE := $(KLIB_BUILD)/Makefile
  13. CONFIG_MD5 := $(shell md5sum $(KERNEL_CONFIG) 2>/dev/null | sed 's/\s.*//')
  14. +STAMP_KERNEL_CONFIG := .kernel_config_md5_$(CONFIG_MD5)
  15. export KLIB KLIB_BUILD BACKPORT_DIR KMODDIR KMODPATH_ARG
  16. @@ -36,7 +37,8 @@ mrproper:
  17. @rm -f .kernel_config_md5 Kconfig.versions Kconfig.kernel
  18. @rm -f backport-include/backport/autoconf.h
  19. -.DEFAULT:
  20. +.SILENT: $(STAMP_KERNEL_CONFIG)
  21. +$(STAMP_KERNEL_CONFIG):
  22. @set -e ; test -f .local-symbols || ( \
  23. echo "/--------------" ;\
  24. echo "| You shouldn't run make in the backports tree, but only in" ;\
  25. @@ -60,57 +62,61 @@ mrproper:
  26. echo "| (that isn't currently running.)" ;\
  27. echo "\\--" ;\
  28. false)
  29. - @set -e ; if [ "$$(cat .kernel_config_md5 2>/dev/null)" != "$(CONFIG_MD5)" ] ;\
  30. - then \
  31. - echo -n "Generating local configuration database from kernel ..." ;\
  32. - grep -v -f .local-symbols $(KERNEL_CONFIG) | grep = | ( \
  33. - while read l ; do \
  34. - if [ "$${l:0:7}" != "CONFIG_" ] ; then \
  35. - continue ;\
  36. - fi ;\
  37. - l=$${l:7} ;\
  38. - n=$${l%%=*} ;\
  39. - v=$${l#*=} ;\
  40. - if [ "$$v" = "m" ] ; then \
  41. - echo config $$n ;\
  42. - echo ' tristate' ;\
  43. - elif [ "$$v" = "y" ] ; then \
  44. - echo config $$n ;\
  45. - echo ' bool' ;\
  46. - else \
  47. - continue ;\
  48. - fi ;\
  49. - echo " default $$v" ;\
  50. - echo "" ;\
  51. - done \
  52. - ) > Kconfig.kernel ;\
  53. - kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion | \
  54. - sed 's/^\(\([3-4]\|2\.6\)\.[0-9]\+\).*/\1/;t;d') ;\
  55. - test "$$kver" != "" || echo "Kernel version parse failed!" ;\
  56. - test "$$kver" != "" ;\
  57. - kvers="$$(seq 14 39 | sed 's/^/2.6./')" ;\
  58. - kvers="$$kvers $$(seq 0 19 | sed 's/^/3./')" ;\
  59. - kvers="$$kvers $$(seq 0 99 | sed 's/^/4./')" ;\
  60. - print=0 ;\
  61. - for v in $$kvers ; do \
  62. - if [ "$$print" = "1" ] ; then \
  63. - echo config KERNEL_$$(echo $$v | tr . _) ;\
  64. - echo " def_bool y" ;\
  65. - fi ;\
  66. - if [ "$$v" = "$$kver" ] ; then print=1 ; fi ;\
  67. - done > Kconfig.versions ;\
  68. - # RHEL as well, sadly we need to grep for it ;\
  69. - RHEL_MAJOR=$$(grep '^RHEL_MAJOR' $(KERNEL_MAKEFILE) | \
  70. - sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\
  71. - RHEL_MINOR=$$(grep '^RHEL_MINOR' $(KERNEL_MAKEFILE) | \
  72. - sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\
  73. - for v in $$(seq 0 $$RHEL_MINOR) ; do \
  74. - echo config BACKPORT_RHEL_KERNEL_$${RHEL_MAJOR}_$$v ;\
  75. - echo " def_bool y" ;\
  76. - done >> Kconfig.versions ;\
  77. - echo " done." ;\
  78. - fi ;\
  79. - echo "$(CONFIG_MD5)" > .kernel_config_md5
  80. + @rm -f .kernel_config_md5_*
  81. + @touch $@
  82. +
  83. +Kconfig.kernel: $(STAMP_KERNEL_CONFIG) .local-symbols
  84. + @printf "Generating local configuration database from kernel ..."
  85. + @grep -v -f .local-symbols $(KERNEL_CONFIG) | grep = | ( \
  86. + while read l ; do \
  87. + if [ "$${l:0:7}" != "CONFIG_" ] ; then \
  88. + continue ;\
  89. + fi ;\
  90. + l=$${l:7} ;\
  91. + n=$${l%%=*} ;\
  92. + v=$${l#*=} ;\
  93. + if [ "$$v" = "m" ] ; then \
  94. + echo config $$n ;\
  95. + echo ' tristate' ;\
  96. + elif [ "$$v" = "y" ] ; then \
  97. + echo config $$n ;\
  98. + echo ' bool' ;\
  99. + else \
  100. + continue ;\
  101. + fi ;\
  102. + echo " default $$v" ;\
  103. + echo "" ;\
  104. + done \
  105. + ) > $@
  106. + @echo " done."
  107. +
  108. +Kconfig.versions: Kconfig.kernel
  109. + @kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion | \
  110. + sed 's/^\(\([3-4]\|2\.6\)\.[0-9]\+\).*/\1/;t;d') ;\
  111. + test "$$kver" != "" || echo "Kernel version parse failed!" ;\
  112. + test "$$kver" != "" ;\
  113. + kvers="$$(seq 14 39 | sed 's/^/2.6./')" ;\
  114. + kvers="$$kvers $$(seq 0 19 | sed 's/^/3./')" ;\
  115. + kvers="$$kvers $$(seq 0 99 | sed 's/^/4./')" ;\
  116. + print=0 ;\
  117. + for v in $$kvers ; do \
  118. + if [ "$$print" = "1" ] ; then \
  119. + echo config KERNEL_$$(echo $$v | tr . _) ;\
  120. + echo " def_bool y" ;\
  121. + fi ;\
  122. + if [ "$$v" = "$$kver" ] ; then print=1 ; fi ;\
  123. + done > $@
  124. + @RHEL_MAJOR=$$(grep '^RHEL_MAJOR' $(KERNEL_MAKEFILE) | \
  125. + sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\
  126. + RHEL_MINOR=$$(grep '^RHEL_MINOR' $(KERNEL_MAKEFILE) | \
  127. + sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\
  128. + for v in $$(seq 0 $$RHEL_MINOR) ; do \
  129. + echo config BACKPORT_RHEL_KERNEL_$${RHEL_MAJOR}_$$v ;\
  130. + echo " def_bool y" ;\
  131. + done >> $@
  132. +
  133. +.DEFAULT:
  134. + @$(MAKE) Kconfig.versions
  135. @$(MAKE) -f Makefile.real "$@"
  136. .PHONY: defconfig-help
  137. --- a/Makefile.real
  138. +++ b/Makefile.real
  139. @@ -59,7 +59,7 @@ defconfig-%::
  140. backport-include/backport/autoconf.h: .config Kconfig.versions Kconfig.kernel
  141. @$(MAKE) oldconfig
  142. - @echo -n "Building backport-include/backport/autoconf.h ..."
  143. + @printf "Building backport-include/backport/autoconf.h ..."
  144. @grep -f .local-symbols .config | ( \
  145. echo "#ifndef COMPAT_AUTOCONF_INCLUDED" ;\
  146. echo "#define COMPAT_AUTOCONF_INCLUDED" ;\
  147. @@ -80,7 +80,12 @@ backport-include/backport/autoconf.h: .c
  148. esac ;\
  149. done ;\
  150. echo "#endif /* COMPAT_AUTOCONF_INCLUDED */" ;\
  151. - ) > backport-include/backport/autoconf.h
  152. + ) > $@.new
  153. + @if cmp -s $@ $@.new; then \
  154. + rm -f $@.new; \
  155. + else \
  156. + mv $@.new $@; \
  157. + fi
  158. @echo " done."
  159. .PHONY: modules