1#!/bin/sh
2#
3# %CopyrightBegin%
4#
5# Copyright Ericsson AB 1997-2018. All Rights Reserved.
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11#     http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19# %CopyrightEnd%
20#
21# Author:
22#         Patrik Winroth
23#
24
25
26# vxworks_ppc860 vxworks_ppc603 vxworks_ppc603_longcall vxworks_cpu32 vxworks_sparc
27# vxworks_ppc750 vxworks_simso
28
29case $# in
301) host=$1 ;;
31*) echo "usage: configure.vxworks host-configuration"; exit 1 ;;
32esac
33
34case $1 in
35vxworks_cpu32) ;;
36vxworks_ppc750) ;;
37vxworks_ppc860) ;;
38vxworks_ppc603) ;;
39vxworks_ppc603_nolongcall) ;;
40vxworks_sparc) ;;
41vxworks_simso) ;;
42vxworks_simlinux) ;;
43vxworks_ppc32) ;;
44*) echo "usage: configure.vxworks TARGET";
45   echo "where TARGET is one of vxworks_cpu32, vxworks_ppc750, vxworks_ppc860, vxworks_ppc603, vxworks_ppc603_nolongcall, vxworks_sparc, vxworks_simso, vxworks_simlinux, vxworks_ppc32"; exit 1;;
46esac
47
48if [ "x$ERL_TOP" = x ]; then
49    echo "You need to set ERL_TOP!"
50    exit 1
51fi
52
53
54target=$host
55
56# Find out the HOST and WIND_BASE environment
57HOST_TYPE=${HOST_TYPE:=sun4-solaris2}
58case $1 in
59vxworks_ppc750) VXTOP=Tornado2.2 ;;
60vxworks_simso)  VXTOP=WindRiver ;;
61vxworks_simlinux)  VXTOP=WindRiver ;;
62vxworks_ppc32)  VXTOP=WindRiver ;;
63*)              VXTOP=wind ;;
64esac
65
66WIND_BASE=${WIND_BASE:=`ypmatch tornado passwd | awk -F: '{print $6}'`/$VXTOP}
67
68# These are created by autoconf.
69MKDIRS="${ERL_TOP}/lib/os_mon/priv/bin/$target
70        ${ERL_TOP}/lib/os_mon/priv/obj/$target
71        ${ERL_TOP}/lib/asn1/priv/lib/$target
72        ${ERL_TOP}/lib/asn1/priv/obj/$target
73        ${ERL_TOP}/lib/erl_interface/obj/$target
74        ${ERL_TOP}/lib/erl_interface/obj.debug/$target
75        ${ERL_TOP}/lib/erl_interface/bin/$target
76        ${ERL_TOP}/lib/runtime_tools/priv/lib/$target
77        ${ERL_TOP}/lib/runtime_tools/priv/obj/$target
78	${ERL_TOP}/erts/obj/$target
79	${ERL_TOP}/erts/obj.debug/$target
80	${ERL_TOP}/bin/$target"
81
82for dir in $MKDIRS; do
83  test ! -d "$dir" && mkdir -p "$dir"
84done
85
86#
87# Create Makefiles for vxWorks.
88#
89my_root=${ERL_TOP}/erts/emulator
90emu_test=$my_root/test
91beam=$my_root/beam
92erts_lib_src=${ERL_TOP}/erts/lib_src
93erts_incl=${ERL_TOP}/erts/include
94erts_incl_intrnl=${ERL_TOP}/erts/include/internal
95etcdir=${ERL_TOP}/erts/etc/common
96erlint_dir=${ERL_TOP}/lib/erl_interface/src
97epmd_dir=${ERL_TOP}/erts/epmd/src
98os_mon_dir=${ERL_TOP}/lib/os_mon/c_src
99internal_tools_dir=${ERL_TOP}
100libdir=${ERL_TOP}/lib
101tsdir=$libdir/test_server/src
102zlibdir=${ERL_TOP}/erts/emulator/zlib
103runtime_tools_dir=${ERL_TOP}/lib/runtime_tools/c_src
104tools_dir=${ERL_TOP}/lib/tools/c_src
105
106CONFIG_FILES="${ERL_TOP}/erts/emulator/$host/Makefile
107	    $erts_lib_src/$host/Makefile
108	    $erts_incl/$host/erl_int_sizes_config.h
109	    $erts_incl_intrnl/$host/ethread.mk
110	    $erts_incl_intrnl/$host/ethread_header_config.h
111	    $etcdir/$host/Makefile
112	    $erlint_dir/$host/Makefile
113	    $erlint_dir/$host/eidefs.mk
114	    $epmd_dir/$host/Makefile
115	    $internal_tools_dir/make/$host/otp.mk
116	    $internal_tools_dir/make/$host/otp_ded.mk
117	    $os_mon_dir/$host/Makefile
118	    $zlibdir/$host/Makefile
119	    $runtime_tools_dir/$host/Makefile
120	    $tools_dir/$host/Makefile"
121
122for file in $CONFIG_FILES; do
123    new_name=`echo $file|sed "s%/$host/%/$target/%"`
124    dir=`echo $new_name|sed 's%/[^/][^/]*$%%'`
125    if test "$dir" != "$new_name" && test "$dir" != .; then
126	test ! -d "$dir" && mkdir "$dir"
127    fi
128
129    sole_name=`echo $file|sed "s%.*$target/%%"`
130    in_file=`echo $dir|sed "s%/[^/][^/]*$%/$sole_name.in%"`
131    echo "creating $new_name"
132    sed -f vxworks/sed.$target -f vxworks/sed.general \
133	-e "s,@HOST_TYPE@,$HOST_TYPE,g" \
134	-e "s,@WIND_BASE@,$WIND_BASE,g" \
135	-e "s,@TARGET@,$target,g" \
136	$in_file > $new_name
137done
138
139
140