build: add GCC 10 version detection
[librecmc/librecmc.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         libreCMC 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 $(eval $(call SetupHostCommand,gcc, \
30         Please install the GNU C Compiler (gcc) 4.8 or later, \
31         $(CC) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
32         gcc -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
33         gcc48 --version | grep gcc, \
34         gcc49 --version | grep gcc, \
35         gcc5 --version | grep gcc, \
36         gcc6 --version | grep gcc, \
37         gcc7 --version | grep gcc, \
38         gcc8 --version | grep gcc, \
39         gcc9 --version | grep gcc, \
40         gcc10 --version | grep gcc, \
41         gcc --version | grep -E 'Apple.(LLVM|clang)' ))
42
43 $(eval $(call TestHostCommand,working-gcc, \
44         \nPlease reinstall the GNU C Compiler (4.8 or later) - \
45         it appears to be broken, \
46         echo 'int main(int argc, char **argv) { return 0; }' | \
47                 gcc -x c -o $(TMP_DIR)/a.out -))
48
49 $(eval $(call SetupHostCommand,g++, \
50         Please install the GNU C++ Compiler (g++) 4.8 or later, \
51         $(CXX) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
52         g++ -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
53         g++48 --version | grep g++, \
54         g++49 --version | grep g++, \
55         g++5 --version | grep g++, \
56         g++6 --version | grep g++, \
57         g++7 --version | grep g++, \
58         g++8 --version | grep g++, \
59         g++9 --version | grep g++, \
60         g++10 --version | grep g++, \
61         g++ --version | grep -E 'Apple.(LLVM|clang)' ))
62
63 $(eval $(call TestHostCommand,working-g++, \
64         \nPlease reinstall the GNU C++ Compiler (4.8 or later) - \
65         it appears to be broken, \
66         echo 'int main(int argc, char **argv) { return 0; }' | \
67                 g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
68                 $(TMP_DIR)/a.out))
69
70 $(eval $(call TestHostCommand,ncurses, \
71         Please install ncurses. (Missing libncurses.so or ncurses.h), \
72         echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
73                 gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses))
74
75 ifeq ($(HOST_OS),Linux)
76   zlib_link_flags := -Wl,-Bstatic -lz -Wl,-Bdynamic
77 else
78   zlib_link_flags := -lz
79 endif
80
81 $(eval $(call TestHostCommand,perl-thread-queue, \
82         Please install the Perl Thread::Queue module, \
83         perl -MThread::Queue -e 1))
84
85
86 $(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \
87         gtar --version 2>&1 | grep GNU, \
88         gnutar --version 2>&1 | grep GNU, \
89         tar --version 2>&1 | grep GNU))
90
91 $(eval $(call SetupHostCommand,find,Please install GNU 'find', \
92         gfind --version 2>&1 | grep GNU, \
93         find --version 2>&1 | grep GNU))
94
95 $(eval $(call SetupHostCommand,bash,Please install GNU 'bash', \
96         bash --version 2>&1 | grep GNU))
97
98 $(eval $(call SetupHostCommand,patch,Please install GNU 'patch', \
99         gpatch --version 2>&1 | grep 'Free Software Foundation', \
100         patch --version 2>&1 | grep 'Free Software Foundation'))
101
102 $(eval $(call SetupHostCommand,diff,Please install diffutils, \
103         gdiff --version 2>&1 | grep diff, \
104         diff --version 2>&1 | grep diff))
105
106 $(eval $(call SetupHostCommand,cp,Please install GNU fileutils, \
107         gcp --help 2>&1 | grep 'Copy SOURCE', \
108         cp --help 2>&1 | grep 'Copy SOURCE'))
109
110 $(eval $(call SetupHostCommand,seq,, \
111         gseq --version, \
112         seq --version))
113
114 $(eval $(call SetupHostCommand,awk,Please install GNU 'awk', \
115         gawk --version 2>&1 | grep GNU, \
116         awk --version 2>&1 | grep GNU))
117
118 $(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \
119         ggrep --version 2>&1 | grep GNU, \
120         grep --version 2>&1 | grep GNU))
121
122 $(eval $(call SetupHostCommand,getopt, \
123         Please install an extended getopt version that supports --long, \
124         gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
125         /usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
126         getopt -o t --long test -- --test | grep '^ *--test *--'))
127
128 $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
129         gnustat -c%s $(TOPDIR)/Makefile, \
130         gstat -c%s $(TOPDIR)/Makefile, \
131         stat -c%s $(TOPDIR)/Makefile))
132
133 $(eval $(call SetupHostCommand,unzip,Please install 'unzip', \
134         unzip 2>&1 | grep zipfile, \
135         unzip))
136
137 $(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \
138         bzip2 --version </dev/null))
139
140 $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
141         wget --version | grep GNU))
142
143 $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
144         perl --version | grep "perl.*v5"))
145
146 $(eval $(call CleanupPython3))
147
148 $(eval $(call SetupHostCommand,python,Please install Python 2.x, \
149         python2.7 -V 2>&1 | grep 'Python 2.7', \
150         python2 -V 2>&1 | grep 'Python 2', \
151         python -V 2>&1 | grep 'Python 2'))
152
153 $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \
154         git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule))
155
156 $(eval $(call SetupHostCommand,file,Please install the 'file' package, \
157         file --version 2>&1 | grep file))
158
159 $(STAGING_DIR_HOST)/bin/mkhash: $(SCRIPT_DIR)/mkhash.c
160         mkdir -p $(dir $@)
161         $(CC) -O2 -I$(TOPDIR)/tools/include -o $@ $<
162
163 prereq: $(STAGING_DIR_HOST)/bin/mkhash
164
165 # Install ldconfig stub
166 $(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \
167         touch $(STAGING_DIR_HOST)/bin/ldconfig && \
168         chmod +x $(STAGING_DIR_HOST)/bin/ldconfig))