1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
%%
%%% Purpose : Autoconf for cross environments.
-module(ts_autoconf_vxworks).
-export([configure/1]).
%%% Supported cross platforms:
-define(PLATFORMS, ["vxworks_cpu32", "vxworks_ppc860", "vxworks_ppc603",
"vxworks_sparc", "vxworks_ppc750", "vxworks_simso"]).
-include("ts.hrl").
%% takes an argument {Target_arch, Target_host} (e.g. {vxworks_ppc860, thorin}).
configure({Target_arch, Target_host}) ->
case variables({Target_arch, Target_host}) of
{ok, Vars} ->
ts_lib:subst_file("conf_vars.in", "conf_vars", Vars);
Error ->
Error
end.
variables(Cross_spec) ->
run_tests(Cross_spec, tests(), []).
run_tests(Cross_spec, [{Prompt, Tester}|Rest], Vars) ->
io:format("checking ~s... ", [Prompt]),
case catch Tester(Cross_spec, Vars) of
{'EXIT', Reason} ->
io:format("FAILED~nExit status: ~p~n", [Reason]),
{error, auto_conf_failed};
{Result, NewVars} ->
io:format("~s~n", [lists:concat([Result])]),
run_tests(Cross_spec, Rest, NewVars)
end;
run_tests(_Cross_spec, [], Vars) ->
{ok, Vars}.
%%% The tests.
tests() ->
[{"supported target architecture", fun target_architecture/2},
{"cross target host to run tests on", fun target_host/2},
{"CPU type", fun cpu/2},
{"for cross-compiling gcc", fun find_gcc/2},
{"for cross-linker", fun find_ld/2},
{"for object extension", fun find_obj/2},
{"for shared libraries extension", fun find_dll/2},
{"for executables extension", fun find_exe/2},
{"for make", fun find_make/2}].
target_architecture({Architecture, _Target_host}, Vars) ->
case lists:member(Architecture, ?PLATFORMS) of
true ->
{Architecture, [{host_os, os_type(Architecture)}, {host, Architecture}|Vars]};
false ->
{"unsupported_platform", Vars}
end.
target_host({_Architecture, Target_host}, Vars) ->
{Target_host, [{target_host, Target_host} | Vars]}.
cpu({Arch, _Target_host}, Vars) ->
Cpu = processor(Arch),
{Cpu, [{host_cpu, Cpu}|Vars]}.
find_gcc({Arch, _Target_host}, Vars) ->
Gcc = "cc" ++ gnu_suffix(Arch),
case os:find_executable(Gcc) of
false ->
{no, Vars};
Path when is_list(Path) ->
Cflags = cflags(Arch),
{Path, [{'CC', Gcc},
{'CFLAGS', Cflags},
{'EI_CFLAGS', Cflags},
{'ERTS_CFLAGS', Cflags},
{'DEFS', ""},
{'ERTS_LIBS', ""},
{'LIBS', ""},
{'SHLIB_CFLAGS', Cflags},
{test_c_compiler, "{gnuc, undefined}"} | Vars]}
end.
find_ld({Arch, _Target_host}, Vars) ->
Linker = "ld" ++ gnu_suffix(Arch),
case os:find_executable(Linker) of
false ->
{no, Vars};
Path when is_list(Path) ->
{Path, [{'LD', Linker},
{'CROSSLDFLAGS', ldflags(Arch)},
{'SHLIB_EXTRACT_ALL', ""},
{'SHLIB_LD', Linker},
{'SHLIB_LDFLAGS', ""},
{'SHLIB_LDLIBS', ""} | Vars]}
end.
find_obj({Arch, _Target_host}, Vars) ->
Obj = obj_ext(Arch),
{Obj, [{obj, Obj}|Vars]}.
find_dll({Arch, _Target_host}, Vars) ->
Dll = dll_ext(Arch),
{Dll, [{'SHLIB_SUFFIX', Dll}|Vars]}.
find_exe({Arch, _Target_host}, Vars) ->
Exe = exe_ext(Arch),
{Exe, [{exe, Exe}|Vars]}.
find_make(_, Vars) ->
{"make", [{make_command, "make"} | Vars]}.
%%% some utility functions
gnu_suffix(Arch) ->
{_, _, _, _, Suffix, _Cpu, _Cflags, _} = cross_data(Arch),
Suffix.
processor(Arch) ->
{_, _, _, _, _Suffix, Cpu, _Cflags, _} = cross_data(Arch),
Cpu.
cflags(Arch) ->
{_, _, _, _, _Suffix, _Cpu, Cflags, _} = cross_data(Arch),
Cflags.
ldflags(Arch) ->
{_, _, _, _, _Suffix, _Cpu, _Cflags, Ldflags} = cross_data(Arch),
Ldflags.
os_type(Arch) ->
{Os_type, _, _, _, _, _, _, _} = cross_data(Arch),
Os_type.
obj_ext(Arch) ->
{_, _, Obj, _, _, _, _, _} = cross_data(Arch),
Obj.
dll_ext(Arch) ->
{_, _, _, Dll, _, _, _, _} = cross_data(Arch),
Dll.
exe_ext(Arch) ->
{_, Exe, _, _, _, _, _, _} = cross_data(Arch),
Exe.
cross_data(Arch) ->
case Arch of
"vxworks_cpu32" ->
{"VxWorks", "", ".o", ".eld", "68k", "cpu32",
"-DCPU=CPU32 -DVXWORKS -I$(WIND_BASE)/target/h -mnobitfield -fno-builtin -nostdinc -fvolatile -msoft-float",
"-r -d"};
"vxworks_ppc860" ->
{"VxWorks", "", ".o", ".eld", "ppc", "ppc860",
"-DCPU=PPC860 -DVXWORKS -I$(WIND_BASE)/target/h -mcpu=860 -fno-builtin -fno-for-scope -msoft-float -D_GNU_TOOL -nostdinc",
"-r -d"};
"vxworks_ppc603" ->
{"VxWorks", "", ".o", ".eld", "ppc", "ppc603",
"-DCPU=PPC603 -DVXWORKS -I$(WIND_BASE)/target/h -fno-builtin -fno-for-scope -D_GNU_TOOL -nostdinc",
"-r -d"};
"vxworks_sparc" ->
%%% The Sparc Architecture is included for private use (i.e. not Tornado 1.0.1 compatible).
{"VxWorks", "", ".o", ".eld", "sparc", "sparc",
"-DCPU=SPARC -DVXWORKS -I/home/gandalf/bsproj/BS.2/UOS/vw/5.2/h -fno-builtin -nostdinc",
"-r -d"};
"vxworks_ppc750" ->
{"VxWorks", "", ".o", ".eld", "ppc", "ppc604",
"-DCPU=PPC604 -DVXWORKS -DTOOL_FAMILY=gnu -DTOOL=gnu -I$(WIND_BASE)/target/h -fno-builtin -fno-for-scope -D_GNU_TOOL",
"-r -d"};
"vxworks_simso" ->
{"VxWorks", "", ".o", ".eld", "simso", "simso",
"-DCPU=SIMSPARCSOLARIS -DVXWORKS -DTOOL_FAMILY=gnu -DTOOL=gnu -I$(WIND_BASE)/target/h -I$(WIND_GCC_INCLUDE) -fno-builtin -fno-for-scope -D_GNU_TOOL",
"-r -d"}
end.
|