2 # Copyright (C) 2006-2012 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 include $(TOPDIR)/rules.mk
9 include $(INCLUDE_DIR)/prereq.mk
12 PKG_NAME:=Build dependency
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]\.)'))
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))
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]))
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 gcc --version | grep -E 'Apple.(LLVM|clang)' ))
35 $(eval $(call TestHostCommand,working-gcc, \
36 \nPlease reinstall the GNU C Compiler (4.8 or later) - \
37 it appears to be broken, \
38 echo 'int main(int argc, char **argv) { return 0; }' | \
39 gcc -x c -o $(TMP_DIR)/a.out -))
41 $(eval $(call SetupHostCommand,g++, \
42 Please install the GNU C++ Compiler (g++) 4.8 or later, \
43 $(CXX) -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
44 g++ -dumpversion | grep -E '^(4\.[8-9]|[5-9]\.?|10\.?)', \
45 g++ --version | grep -E 'Apple.(LLVM|clang)' ))
47 $(eval $(call TestHostCommand,working-g++, \
48 \nPlease reinstall the GNU C++ Compiler (4.8 or later) - \
49 it appears to be broken, \
50 echo 'int main(int argc, char **argv) { return 0; }' | \
51 g++ -x c++ -o $(TMP_DIR)/a.out - -lstdc++ && \
54 $(eval $(call TestHostCommand,ncurses, \
55 Please install ncurses. (Missing libncurses.so or ncurses.h), \
56 echo 'int main(int argc, char **argv) { initscr(); return 0; }' | \
57 gcc -include ncurses.h -x c -o $(TMP_DIR)/a.out - -lncurses))
59 ifeq ($(HOST_OS),Linux)
60 zlib_link_flags := -Wl,-Bstatic -lz -Wl,-Bdynamic
62 zlib_link_flags := -lz
65 $(eval $(call TestHostCommand,perl-thread-queue, \
66 Please install the Perl Thread::Queue module, \
67 perl -MThread::Queue -e 1))
70 $(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \
71 gtar --version 2>&1 | grep GNU, \
72 gnutar --version 2>&1 | grep GNU, \
73 tar --version 2>&1 | grep GNU))
75 $(eval $(call SetupHostCommand,find,Please install GNU 'find', \
76 gfind --version 2>&1 | grep GNU, \
77 find --version 2>&1 | grep GNU))
79 $(eval $(call SetupHostCommand,bash,Please install GNU 'bash', \
80 bash --version 2>&1 | grep GNU))
82 $(eval $(call SetupHostCommand,patch,Please install GNU 'patch', \
83 gpatch --version 2>&1 | grep 'Free Software Foundation', \
84 patch --version 2>&1 | grep 'Free Software Foundation'))
86 $(eval $(call SetupHostCommand,diff,Please install diffutils, \
87 gdiff --version 2>&1 | grep diff, \
88 diff --version 2>&1 | grep diff))
90 $(eval $(call SetupHostCommand,cp,Please install GNU fileutils, \
91 gcp --help 2>&1 | grep 'Copy SOURCE', \
92 cp --help 2>&1 | grep 'Copy SOURCE'))
94 $(eval $(call SetupHostCommand,seq,, \
98 $(eval $(call SetupHostCommand,awk,Please install GNU 'awk', \
99 gawk --version 2>&1 | grep GNU, \
100 awk --version 2>&1 | grep GNU))
102 $(eval $(call SetupHostCommand,grep,Please install GNU 'grep', \
103 ggrep --version 2>&1 | grep GNU, \
104 grep --version 2>&1 | grep GNU))
106 $(eval $(call SetupHostCommand,getopt, \
107 Please install an extended getopt version that supports --long, \
108 gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
109 /usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
110 getopt -o t --long test -- --test | grep '^ *--test *--'))
112 $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \
113 gnustat -c%s $(TOPDIR)/Makefile, \
114 gstat -c%s $(TOPDIR)/Makefile, \
115 stat -c%s $(TOPDIR)/Makefile))
117 $(eval $(call SetupHostCommand,unzip,Please install 'unzip', \
118 unzip 2>&1 | grep zipfile, \
121 $(eval $(call SetupHostCommand,bzip2,Please install 'bzip2', \
122 bzip2 --version </dev/null))
124 $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
125 wget --version | grep GNU))
127 $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
128 perl --version | grep "perl.*v5"))
130 $(eval $(call CleanupPython2))
132 $(eval $(call SetupHostCommand,python,Please install Python >= 3.5, \
133 python3.8 -V 2>&1 | grep 'Python 3', \
134 python3.7 -V 2>&1 | grep 'Python 3', \
135 python3.6 -V 2>&1 | grep 'Python 3', \
136 python3.5 -V 2>&1 | grep 'Python 3', \
137 python3 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?'))
139 $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.7.12.2, \
140 git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule))
142 $(eval $(call SetupHostCommand,file,Please install the 'file' package, \
143 file --version 2>&1 | grep file))
145 $(STAGING_DIR_HOST)/bin/mkhash: $(SCRIPT_DIR)/mkhash.c
147 $(CC) -O2 -I$(TOPDIR)/tools/include -o $@ $<
149 prereq: $(STAGING_DIR_HOST)/bin/mkhash
151 # Install ldconfig stub
152 $(eval $(call TestHostCommand,ldconfig-stub,Failed to install stub, \
153 touch $(STAGING_DIR_HOST)/bin/ldconfig && \
154 chmod +x $(STAGING_DIR_HOST)/bin/ldconfig))