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