prereq-build.mk 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. #
  2. # Copyright (C) 2006-2012 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. include $(INCLUDE_DIR)/host-build.mk
  11. PKG_NAME:=Build dependency
  12. define Require/non-root
  13. [ "$$(shell whoami)" != "root" ]
  14. endef
  15. $(eval $(call Require,non-root, \
  16. Please do not compile as root. \
  17. ))
  18. # Required for the toolchain
  19. define Require/working-make
  20. $(MAKE) -v | awk '($$$$1 == "GNU") && ($$$$2 == "Make") && ($$$$3 >= "3.81") { print "ok" }' | grep ok > /dev/null
  21. endef
  22. $(eval $(call Require,working-make, \
  23. Please install GNU make v3.81 or later. (This version has bugs) \
  24. ))
  25. define Require/case-sensitive-fs
  26. rm -f $(TMP_DIR)/test.*
  27. touch $(TMP_DIR)/test.fs
  28. [ \! -f $(TMP_DIR)/test.FS ]
  29. endef
  30. $(eval $(call Require,case-sensitive-fs, \
  31. libreCMC can only be built on a case-sensitive filesystem \
  32. ))
  33. define Require/getopt
  34. gnugetopt --help 2>&1 | grep long >/dev/null || \
  35. /usr/local/bin/getopt --help 2>&1 | grep long >/dev/null || \
  36. getopt --help 2>&1 | grep long >/dev/null
  37. endef
  38. $(eval $(call Require,getopt, \
  39. Please install GNU getopt \
  40. ))
  41. define Require/fileutils
  42. gcp --help || cp --help
  43. endef
  44. $(eval $(call Require,fileutils, \
  45. Please install GNU fileutils \
  46. ))
  47. define Require/working-gcc
  48. echo 'int main(int argc, char **argv) { return 0; }' | \
  49. gcc -x c -o $(TMP_DIR)/a.out -
  50. endef
  51. $(eval $(call Require,working-gcc, \
  52. Please install the GNU C Compiler (gcc). \
  53. ))
  54. define Require/working-g++
  55. echo 'int main(int argc, char **argv) { return 0; }' | \
  56. g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
  57. $(TMP_DIR)/a.out
  58. endef
  59. $(eval $(call Require,working-g++, \
  60. Please install the GNU C++ Compiler (g++). \
  61. ))
  62. ifneq ($(HOST_STATIC_LINKING),)
  63. define Require/working-gcc-static
  64. echo 'int main(int argc, char **argv) { return 0; }' | \
  65. gcc -x c $(HOST_STATIC_LINKING) -o $(TMP_DIR)/a.out -
  66. endef
  67. $(eval $(call Require,working-gcc-static, \
  68. Please install the static libc development package (glibc-static on CentOS/Fedora/RHEL). \
  69. ))
  70. define Require/working-g++-static
  71. echo 'int main(int argc, char **argv) { return 0; }' | \
  72. g++ -x c++ $(HOST_STATIC_LINKING) -o $(TMP_DIR)/a.out - -lstdc++ && \
  73. $(TMP_DIR)/a.out
  74. endef
  75. $(eval $(call Require,working-g++-static, \
  76. Please install the static libstdc++ development package (libstdc++-static on CentOS/Fedora/RHEL). \
  77. ))
  78. endif
  79. define Require/ncurses
  80. echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
  81. gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses
  82. endef
  83. $(eval $(call Require,ncurses, \
  84. Please install ncurses. (Missing libncurses.so or ncurses.h) \
  85. ))
  86. define Require/zlib
  87. echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
  88. gcc -include zlib.h -x c -o $(TMP_DIR)/a.out - -lz
  89. endef
  90. $(eval $(call Require,zlib, \
  91. Please install zlib. (Missing libz.so or zlib.h) \
  92. ))
  93. ifneq ($(HOST_STATIC_LINKING),)
  94. define Require/zlib-static
  95. echo 'int main(int argc, char **argv) { gzdopen(0, "rb"); return 0; }' | \
  96. gcc -include zlib.h -x c $(HOST_STATIC_LINKING) -o $(TMP_DIR)/a.out - -lz
  97. endef
  98. $(eval $(call Require,zlib-static, \
  99. Please install a static zlib. (zlib-static on CentOS/Fedora/RHEL). \
  100. ))
  101. endif
  102. $(eval $(call RequireCommand,gawk, \
  103. Please install GNU awk. \
  104. ))
  105. $(eval $(call RequireCommand,unzip, \
  106. Please install unzip. \
  107. ))
  108. $(eval $(call RequireCommand,bzip2, \
  109. Please install bzip2. \
  110. ))
  111. $(eval $(call RequireCommand,perl, \
  112. Please install perl. \
  113. ))
  114. $(eval $(call RequireCommand,$(PYTHON), \
  115. Please install python. \
  116. ))
  117. $(eval $(call RequireCommand,wget, \
  118. Please install wget. \
  119. ))
  120. define Require/git
  121. git --version | awk '($$$$1 == "git") && ($$$$2 == "version") && ($$$$3 >= "1.6.5") { print "ok" }' | grep ok > /dev/null
  122. endef
  123. $(eval $(call Require,git, \
  124. Please install git (git-core) v1.6.5 or later. \
  125. ))
  126. define Require/gnutar
  127. $(TAR) --version 2>&1 | grep GNU > /dev/null
  128. endef
  129. $(eval $(call Require,gnutar, \
  130. Please install GNU tar. \
  131. ))
  132. $(eval $(call RequireCommand,svn, \
  133. Please install the subversion client. \
  134. ))
  135. define Require/libssl
  136. echo 'int main(int argc, char **argv) { SSL_library_init(); return 0; }' | \
  137. gcc -include openssl/ssl.h -x c -o $(TMP_DIR)/a.out - -lcrypto -lssl
  138. endef
  139. $(eval $(call Require,libssl, \
  140. Please install the openssl library (with development headers) \
  141. ))
  142. $(eval $(call RequireCommand,openssl, \
  143. Please install openssl. \
  144. ))
  145. define Require/gnu-find
  146. $(FIND) --version 2>/dev/null
  147. endef
  148. $(eval $(call Require,gnu-find, \
  149. Please install GNU find \
  150. ))
  151. define Require/getopt-extended
  152. getopt --long - - >/dev/null
  153. endef
  154. $(eval $(call Require,getopt-extended, \
  155. Please install an extended getopt version that supports --long \
  156. ))
  157. $(eval $(call RequireCommand,file, \
  158. Please install the 'file' package. \
  159. ))