1 | # This file is part of MKF. |
---|
2 | # |
---|
3 | # MKF is free software; you can redistribute it and/or modify |
---|
4 | # it under the terms of the GNU General Public License as published by |
---|
5 | # the Free Software Foundation; either version 2 of the License, or |
---|
6 | # (at your option) any later version. |
---|
7 | # |
---|
8 | # MKF is distributed in the hope that it will be useful, |
---|
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | # GNU General Public License for more details. |
---|
12 | # |
---|
13 | # You should have received a copy of the GNU General Public License |
---|
14 | # along with MKF; if not, write to the Free Software |
---|
15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
16 | # |
---|
17 | # Copyright (c) 2004 Alexandre Becoulet <alexandre.becoulet@epita.fr> |
---|
18 | |
---|
19 | # look for available c complier if none was specified on the command line |
---|
20 | |
---|
21 | _if_var_eq cmd_c_compiler |
---|
22 | _if_in_path gcc |
---|
23 | var_define cmd_c_compiler gcc |
---|
24 | _else |
---|
25 | var_define cmd_c_compiler cc |
---|
26 | _end_if |
---|
27 | _end_if |
---|
28 | |
---|
29 | _if_var_eq use_c_compiler |
---|
30 | |
---|
31 | _if_in_path {PVAR,cmd_c_compiler} |
---|
32 | |
---|
33 | _if_stdout_match gcc {PVAR,cmd_c_compiler} -v |
---|
34 | msg_info GNU C compiler ({PVAR,cmd_c_compiler}) found |
---|
35 | var_define use_c_compiler gcc |
---|
36 | |
---|
37 | var_append opt_c_compiler -Wall -Wshadow -Wpointer-arith -Winline -pipe |
---|
38 | var_append opt_c_compiler -Wwrite-strings -Waggregate-return |
---|
39 | var_append opt_c_compiler -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations |
---|
40 | |
---|
41 | _if_var_eq debug yes |
---|
42 | var_append opt_c_compiler -g -DDEBUG -fno-inline -gstabs |
---|
43 | _else |
---|
44 | var_append opt_c_compiler -O3 |
---|
45 | var_append opt_c_compiler -fomit-frame-pointer |
---|
46 | var_append opt_c_compiler -march=athlon -mcpu=athlon |
---|
47 | _end_if |
---|
48 | |
---|
49 | _else |
---|
50 | |
---|
51 | _if_stdout_match Intel {PVAR,cmd_c_compiler} -V |
---|
52 | msg_info Intel C compiler ({PVAR,cmd_c_compiler}) found |
---|
53 | var_define use_c_compiler intel |
---|
54 | |
---|
55 | var_append opt_c_compiler -axiM -tpp6 |
---|
56 | |
---|
57 | _if_var_eq debug yes |
---|
58 | var_append opt_c_compiler -g |
---|
59 | _else |
---|
60 | var_append opt_c_compiler -O3 |
---|
61 | _end_if |
---|
62 | |
---|
63 | _else |
---|
64 | |
---|
65 | _if_stdout_match Sun|Solaris {PVAR,cmd_c_compiler} -V |
---|
66 | msg_info Sun C compiler ({PVAR,cmd_c_compiler}) found |
---|
67 | var_define use_c_compiler sun |
---|
68 | |
---|
69 | _if_var_eq debug yes |
---|
70 | var_append opt_c_compiler -g |
---|
71 | _else |
---|
72 | var_append opt_c_compiler -xO3 |
---|
73 | _end_if |
---|
74 | |
---|
75 | _else |
---|
76 | |
---|
77 | msg_info native C compiler ({PVAR,cmd_c_compiler}) found |
---|
78 | var_define use_c_compiler cc |
---|
79 | _end_if |
---|
80 | _end_if |
---|
81 | _end_if |
---|
82 | |
---|
83 | _else |
---|
84 | msg_error invalid or no c complier specified |
---|
85 | _end_if |
---|
86 | _end_if |
---|
87 | |
---|
88 | _if_stdout_match x86_64 uname -m |
---|
89 | msg_info using -fPIC for compilation |
---|
90 | var_append cmd_c_compiler -fPIC |
---|
91 | _end_if |
---|
92 | |
---|
93 | _if_var_eq mkf_pretty_print yes |
---|
94 | command_add c o echo " CC {SRC,.*\.c} -> {OUT}" |
---|
95 | _end_if |
---|
96 | command_add c o {PVAR,cmd_c_compiler} -c {JVAR,opt_c_compiler} \ |
---|
97 | -o {OUT} -I. {JLIST,-I,inc_dirs} {SRC,.*\.c} |
---|
98 | |
---|
99 | _if_var_eq mkf_pretty_print yes |
---|
100 | command_add S o echo " CC (.S file) {SRC,.*\.c} -> {OUT}" |
---|
101 | _end_if |
---|
102 | command_add S o {PVAR,cmd_c_compiler} -c {JVAR,opt_c_compiler} \ |
---|
103 | -o {OUT} -I. {JLIST,-I,inc_dirs} {SRC,.*\.S} |
---|
104 | |
---|
105 | # check c compiler is working |
---|
106 | |
---|
107 | _if_exec_ok echo 'int main() { return (0);}' > {TEMP,1,.c} ; {PVAR,cmd_c_compiler} \ |
---|
108 | -o {TEMP,2,.bin} {TEMP,1,.c} && test -x {TEMP,2,.bin} |
---|
109 | |
---|
110 | msg_info C compiler is working |
---|
111 | _else |
---|
112 | msg_warning C compiler failed to create executable file |
---|
113 | _end_if |
---|
114 | |
---|