54ed0e6f90b1752587045b19e5b83c60a21f5acc
[openwrt/openwrt.git] / include / prereq-build.mk
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
11 SHELL:=sh
12 PKG_NAME:=Build dependency
13
14
15 # Required for the toolchain
16 $(eval $(call TestHostCommand,working-make, \
17 Please install GNU make v3.81 or later. (This version has bugs), \
18 $(MAKE) -v | grep -E 'Make (3\.8[1-9]|3\.9[0-9]|[4-9]\.)'))
19
20 $(eval $(call TestHostCommand,case-sensitive-fs, \
21 OpenWrt can only be built on a case-sensitive filesystem, \
22 rm -f $(TMP_DIR)/test.*; touch $(TMP_DIR)/test.fs; \
23 test ! -f $(TMP_DIR)/test.FS))
24
25 $(eval $(call TestHostCommand,proper-umask, \
26 Please build with umask 022 - other values produce broken packages, \
27 umask | grep -xE 0?0[012][012]))
28
29 ifndef IB
30 $(eval $(call SetupHostCommand,gcc, \
31 Please install the GNU C Compiler (gcc) 4.8 or later, \
32 $(CC) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|1[0-9]\.?)', \
33 gcc -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|1[0-9]\.?)', \
34 gcc --version | grep -E 'Apple.(LLVM|clang)' ))
35
36 $(eval $(call TestHostCommand,working-gcc, \
37 \nPlease reinstall the GNU C Compiler (4.8 or later) - \
38 it appears to be broken, \
39 echo 'int main(int argc, char **argv) { return 0; }' | \
40 gcc -x c -o $(TMP_DIR)/a.out -))
41
42 $(eval $(call SetupHostCommand,g++, \
43 Please install the GNU C++ Compiler (g++) 4.8 or later, \
44 $(CXX) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|1[0-9]\.?)', \
45 g++ -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|1[0-9]\.?)', \
46 g++ --version | grep -E 'Apple.(LLVM|clang)' ))
47
48 $(eval $(call TestHostCommand,working-g++, \
49 \nPlease reinstall the GNU C++ Compiler (4.8 or later) - \
50 it appears to be broken, \
51 echo 'int main(int argc, char **argv) { return 0; }' | \
52 g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
53 $(TMP_DIR)/a.out))
54
55 $(eval $(call TestHostCommand,ncurses, \
56 Please install ncurses. (Missing libncurses.so or ncurses.h), \
57 echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
58 gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses))
59 endif # IB
60
61 ifeq ($(HOST_OS),Linux)
62 zlib_link_flags := -Wl,-Bstatic -lz -Wl,-Bdynamic
63 else
64 zlib_link_flags := -lz
65 endif
66
67 $(eval $(call TestHostCommand,perl-data-dumper, \
68 Please install the Perl Data::Dumper module, \
69 perl -MData::Dumper -e 1))
70
71 $(eval $(call TestHostCommand,perl-thread-queue, \
72 Please install the Perl Thread::Queue module, \
73 perl -MThread::Queue -e 1))
74
75
76 $(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \
77 gtar --version 2>&1 | grep GNU, \
78 gnutar --version 2>&1 | grep GNU, \
79 tar --version 2>&1 | grep GNU))
80
81 $(eval $(call SetupHostCommand,find,Please install GNU 'find', \
82 gfind --version 2>&1 | grep GNU, \
83 find --version 2>&1 | grep GNU))
84
85 $(eval $(call SetupHostCommand,bash,Please install GNU 'bash', \
86 bash --version 2>&1 | grep GNU))
87
88 $(eval $(call SetupHostCommand,patch,Please install GNU 'patch', \
89 gpatch --version 2>&1 | grep 'Free Software Foundation', \
90 patch --version 2>&1 | grep 'Free Software Foundation'))
91
92 $(eval $(call SetupHostCommand,diff,Please install diffutils, \
93 gdiff --version 2>&1 | grep diff, \
94 diff --version 2>&1 | grep diff))
95
96 $(eval $(call SetupHostCommand,cp,Please install GNU fileutils, \
97 gcp --help 2>&1 | grep 'Copy SOURCE', \
98 cp --help 2>&1 | grep 'Copy SOURCE'))
99
100 $(eval $(call SetupHostCommand,seq,, \
101 gseq --version, \
102 seq --version))
103
104 $(eval $(call SetupHostCommand,awk,Please install GNU 'awk', \
105 gawk --version 2>&1 | grep GNU, \
106 awk --version 2>&1 | grep GNU))
107
108 $(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \
109 ggrep --version 2>&1 | grep GNU, \
110 grep --version 2>&1 | grep GNU))
111
112 $(eval $(call SetupHostCommand,getopt, \
113 Please install an extended getopt version that supports --long, \
114 gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
115 /usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
116 getopt -o t --long test -- --test | grep '^ *--test *--'))
117
118 $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
119 gnustat -c%s $(TOPDIR)/Makefile, \
120 gstat -c%s $(TOPDIR)/Makefile, \
121 stat -c%s $(TOPDIR)/Makefile))
122
123 $(eval $(call SetupHostCommand,unzip,Please install 'unzip', \
124 unzip 2>&1 | grep zipfile, \
125 unzip))
126
127 $(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \
128 bzip2 --version </dev/null))
129
130 $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
131 wget --version | grep GNU))
132
133 $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
134 perl --version | grep "perl.*v5"))
135
136 $(eval $(call CleanupPython3))
137
138 $(eval $(call SetupHostCommand,python,Please install Python 2.x, \
139 python2.7 -V 2>&1 | grep 'Python 2.7', \
140 python2 -V 2>&1 | grep 'Python 2', \
141 python -V 2>&1 | grep 'Python 2'))
142
143 $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \
144 git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule))
145
146 $(eval $(call SetupHostCommand,file,Please install the 'file' package, \
147 file --version 2>&1 | grep file))
148
149 $(STAGING_DIR_HOST)/bin/mkhash: $(SCRIPT_DIR)/mkhash.c
150 mkdir -p $(dir $@)
151 $(CC) -O2 -I$(TOPDIR)/tools/include -o $@ $<
152
153 prereq: $(STAGING_DIR_HOST)/bin/mkhash
154
155 # Install ldconfig stub
156 $(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \
157 touch $(STAGING_DIR_HOST)/bin/ldconfig && \
158 chmod +x $(STAGING_DIR_HOST)/bin/ldconfig))