prereq-build.mk 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #
  2. # Copyright (C) 2006 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/prereq.mk
  9. include $(INCLUDE_DIR)/host.mk
  10. PKG_NAME:=Build dependency
  11. define Require/non-root
  12. [ "$$(shell whoami)" != "root" ]
  13. endef
  14. $(eval $(call Require,non-root, \
  15. Please do not compile as root. \
  16. ))
  17. # Required for the toolchain
  18. define Require/working-make
  19. echo 'all: test' > $(TMP_DIR)/check.mk
  20. echo 'e0 = $$$$(foreach s,foobar,$$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
  21. echo 'e1 = $$$$(foreach s,foobar, $$$$(eval $$$$s:))' >> $(TMP_DIR)/check.mk
  22. echo 'test: $$$$(strip $$$$(e0)) $$$$(strip $$$$(e1))' >> $(TMP_DIR)/check.mk
  23. $(NO_TRACE_MAKE) -f $(TMP_DIR)/check.mk
  24. endef
  25. $(eval $(call Require,working-make, \
  26. Please install GNU make v3.81 or later. (This version has bugs) \
  27. ))
  28. define Require/case-sensitive-fs
  29. rm -f $(TMP_DIR)/test.*
  30. touch $(TMP_DIR)/test.fs
  31. [ \! -f $(TMP_DIR)/test.FS ]
  32. endef
  33. $(eval $(call Require,case-sensitive-fs, \
  34. OpenWrt can only be built on a case-sensitive filesystem \
  35. ))
  36. define Require/working-gcc
  37. echo 'int main(int argc, char **argv) { return 0; }' | \
  38. gcc -x c -o $(TMP_DIR)/a.out -
  39. endef
  40. $(eval $(call Require,working-gcc, \
  41. Please install the GNU C Compiler (gcc). \
  42. ))
  43. define Require/working-g++
  44. echo 'int main(int argc, char **argv) { return 0; }' | \
  45. g++ -x c++ -o $(TMP_DIR)/a.out -lstdc++ -
  46. endef
  47. $(eval $(call Require,working-g++, \
  48. Please install the GNU C++ Compiler (g++). \
  49. ))
  50. define Require/ncurses
  51. echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
  52. gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out -lncurses -
  53. endef
  54. $(eval $(call Require,ncurses, \
  55. Please install ncurses. (Missing libncurses.so or ncurses.h) \
  56. ))
  57. define Require/zlib
  58. echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
  59. gcc -include zlib.h -x c -o $(TMP_DIR)/a.out -lz -
  60. endef
  61. $(eval $(call Require,zlib, \
  62. Please install zlib. (Missing libz.so or zlib.h) \
  63. ))
  64. $(eval $(call RequireCommand,bison, \
  65. Please install GNU bison. \
  66. ))
  67. $(eval $(call RequireCommand,flex, \
  68. Please install flex. \
  69. ))
  70. $(eval $(call RequireCommand,unzip, \
  71. Please install unzip. \
  72. ))
  73. $(eval $(call RequireCommand,bzip2, \
  74. Please install bzip2. \
  75. ))
  76. $(eval $(call RequireCommand,patch, \
  77. Please install patch. \
  78. ))
  79. $(eval $(call RequireCommand,perl, \
  80. Please install perl. \
  81. ))
  82. $(eval $(call RequireCommand,wget, \
  83. Please install wget. \
  84. ))
  85. define Require/gnutar
  86. $(TAR) --version 2>&1 | grep GNU > /dev/null
  87. endef
  88. $(eval $(call Require,gnutar, \
  89. Please install GNU tar. \
  90. ))
  91. $(eval $(call RequireCommand,autoconf, \
  92. Please install GNU autoconf. \
  93. ))