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