source: rtems-libbsd/freebsd-userspace/from-freebsd.sh @ 0f2ea18

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since 0f2ea18 was 0f2ea18, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 11, 2012 at 12:03:41 AM

lib/libc/net/name6.c: New file

netshell01 needed the following symbols:

  • getipnodebyaddr
  • getipnodebyaddr
  • getipnodebyname
  • Property mode set to 100755
File size: 6.8 KB
Line 
1#! /bin/bash
2#
3#  Temporary hack of a script to get FreeBSD user space header
4#  files and network libc source code into this tree.
5#
6#  NOTE: libc and include are NOT in the FreeBSD checkout used for the
7#        USB and TCP/IP stacks. This has to be addressed.
8#
9#  This probably could be integrated into the main Python script.
10#  But so far, there are no real transformations needed and the
11#  script just performs two tasks:
12#
13#  + copies source files from FreeBSD libc and include files into this tree
14#  + generates "wrapper" header files for the public network .h files
15#
16src=/home/joel/newbsd/git/freebsd-8.2
17dest=/home/joel/newbsd/git/rtems-libbsd/freebsd-userspace
18
19progname=${0##*/}        # fast basename hack for ksh, bash
20
21USAGE=\
22"usage: $progname [ -opts ]
23        -v         -- verbose
24        -f DIR     -- FreeBSD directory
25        -r DIR     -- rtems-libbsd top directory
26"
27
28check_status()
29{
30  if [ $1 -ne 0 ] ; then
31    shift 
32    echo "$USAGE" >&2
33    echo >&2
34    echo "FAILED: " "$*" >&2
35    exit 1
36  fi
37}
38
39usage()
40{
41  echo "$USAGE" >&2
42  exit 1
43}
44
45#
46# process the options
47#
48# defaults for getopt vars
49#
50
51src=NOTSET
52dest=NOTSET
53verbose="no"
54
55while getopts "vf:r:" OPT
56do
57 case "$OPT" in
58   v) verbose="yes";;
59   f) src="$OPTARG";;
60   r) dest="$OPTARG";;
61   *) usage;;
62  esac
63done
64
65# Check arguments specified
66test ${src} != "NOTSET" 
67check_status $? "FreeBSD source directory not specified"
68
69test ${dest} != "NOTSET" 
70check_status $? "rtems-libbsd source directory not specified"
71
72# Check that they are directories
73test -d ${src}
74check_status $? "FreeBSD source directory is not a directory"
75
76test -d ${dest}
77check_status $? "rtems-libbsd source directory is not a directory"
78
79# Check that they appear to be the right directories
80test -d ${src}/include
81check_status $? "FreeBSD source directory does not have include directory"
82
83test -d ${src}/lib/libc
84check_status $? "FreeBSD source directory does not have libc directory"
85
86test -d ${dest}/freebsd-userspace
87check_status $? "rtems-libbsd source directory does not have freebsd-userspace directory"
88
89dest=${dest}/freebsd-userspace
90
91# source files to simply copy
92while read f
93do
94  d=`dirname $f`
95  test -d ${dest}/${d} || mkdir -p ${dest}/${d}
96  test -r ${src}/${f}
97  check_status $? "${src}/${f} is not present"
98
99  test ${verbose} = "yes" && echo "Simple copy $f"
100  cp ${src}/${f} ${dest}/${d}
101done <<EOF
102include/db.h
103include/err.h
104include/ifaddrs.h
105include/netconfig.h
106include/nsswitch.h
107include/resolv.h
108include/sysexit.h
109include/res_update.h
110include/rpc/auth.h
111include/rpc/auth_unix.h
112include/rpc/auth_des.h
113include/rpc/clnt.h
114include/rpc/clnt_soc.h
115include/rpc/clnt_stat.h
116include/rpc/pmap_clnt.h
117include/rpc/pmap_prot.h
118include/rpc/rpcent.h
119include/rpc/rpc_msg.h
120include/rpc/rpcb_clnt.h
121include/rpc/rpcb_prot.x
122include/rpc/svc.h
123include/rpc/svc_auth.h
124include/rpc/svc_soc.h
125include/rpc/xdr.h
126include/arpa/ftp.h
127include/arpa/inet.h
128include/arpa/nameser.h
129sys/net/ethernet.h
130sys/rpc/types.h
131sys/sys/_null.h
132sys/sys/un.h
133lib/libc/include/libc_private.h
134lib/libc/include/namespace.h
135lib/libc/include/nss_tls.h
136lib/libc/include/reentrant.h
137lib/libc/include/resolv_mt.h
138lib/libc/include/un-namespace.h
139lib/libc/inet/inet_addr.c
140lib/libc/inet/inet_cidr_ntop.c
141lib/libc/inet/inet_cidr_pton.c
142lib/libc/inet/inet_lnaof.c
143lib/libc/inet/inet_makeaddr.c
144lib/libc/inet/inet_neta.c
145lib/libc/inet/inet_net_ntop.c
146lib/libc/inet/inet_netof.c
147lib/libc/inet/inet_net_pton.c
148lib/libc/inet/inet_network.c
149lib/libc/inet/inet_ntoa.c
150lib/libc/inet/inet_ntop.c
151lib/libc/inet/inet_pton.c
152lib/libc/inet/nsap_addr.c
153lib/libc/net/netdb_private.h
154lib/libc/net/res_config.h
155EOF
156# processed by hand
157# include/arpa/nameser_compat.h
158
159# disable BIND_4_COMPAT since it trips a weird endian issue in nameser_compat.h
160#sed -e 's/#define BIND_4_COMPAT/\/* #define BIND_4_COMPAT *\//' \
161#  >${dest}/include/arpa/nameser.h
162#  <${src}/include/arpa/nameser.h \
163
164# fix include so it sees FreeBSD endian definitions
165sed -e 's/<machine\/endian.h>/<freebsd\/machine\/endian.h>/' \
166  <${src}/include/arpa/nameser_compat.h \
167  >${dest}/include/arpa/nameser_compat.h
168
169
170# source files to prepend "include of local/port_before.h"
171while read f
172do
173  d=`dirname $f`
174  test -d ${dest}/${d} || mkdir -p ${dest}/${d}
175  test -r ${src}/${f}
176  check_status $? "${src}/${f} is not present"
177
178  test ${verbose} = "yes" && echo "Copy with prepend $f"
179   
180  ( echo "#include \"port_before.h\""; echo ; cat ${src}/${f} ) >${dest}/${f}
181done <<EOF
182lib/libc/net/base64.c
183lib/libc/net/ether_addr.c
184lib/libc/net/getaddrinfo.c
185lib/libc/net/gethostbydns.c
186lib/libc/net/gethostbyht.c
187lib/libc/net/gethostbynis.c
188lib/libc/net/gethostnamadr.c
189lib/libc/net/getifaddrs.c
190lib/libc/net/getifmaddrs.c
191lib/libc/net/getnameinfo.c
192lib/libc/net/getnetbydns.c
193lib/libc/net/getnetbyht.c
194lib/libc/net/getnetbynis.c
195lib/libc/net/getnetnamadr.c
196lib/libc/net/getproto.c
197lib/libc/net/getprotoent.c
198lib/libc/net/getprotoname.c
199lib/libc/net/getservent.c
200lib/libc/gen/gethostname.c
201lib/libc/nameser/ns_name.c
202lib/libc/nameser/ns_netint.c
203lib/libc/nameser/ns_parse.c
204lib/libc/nameser/ns_print.c
205lib/libc/nameser/ns_ttl.c
206lib/libc/net/if_indextoname.c
207lib/libc/net/if_nameindex.c
208lib/libc/net/linkaddr.c
209lib/libc/net/map_v4v6.c
210lib/libc/net/name6.c
211lib/libc/net/rcmd.c
212lib/libc/net/recv.c
213lib/libc/net/send.c
214lib/libc/resolv/res_private.h
215lib/libc/resolv/herror.c
216lib/libc/resolv/res_comp.c
217lib/libc/resolv/res_data.c
218lib/libc/resolv/res_debug.c
219lib/libc/resolv/res_init.c
220lib/libc/resolv/res_mkquery.c
221lib/libc/resolv/res_mkupdate.c
222lib/libc/resolv/res_query.c
223lib/libc/resolv/res_send.c
224lib/libc/resolv/res_update.c
225lib/libc/string/strsep.c
226EOF
227
228# This file includes a private "dprintf" which conflicts with stdio.h
229sed -e 's/dprintf/DPRINTF/g' <${dest}/lib/libc/net/gethostbydns.c  >XXX
230mv XXX ${dest}/lib/libc/net/gethostbydns.c
231
232
233# files to "include with freebsd"
234while read f
235do
236  d=`dirname $f`
237  test -d include/${d}/${d} || mkdir -p include/${d}/${d}
238
239  test ${verbose} = "yes" && echo "Generate wrapper $f"
240  ( echo "#include <freebsd/bsd.h>" ; 
241    echo "#include <freebsd/${f}>" ) > include/${f}
242done <<EOF
243poll.h
244net/ethernet.h
245net/if.h
246net/if_arp.h
247net/if_dl.h
248net/if_types.h
249net/in.h
250net/route.h
251netatalk/at.h
252netinet/if_ether.h
253netinet/in.h
254netinet/icmp6.h
255netinet/igmp.h
256netinet/in_systm.h
257netinet/ip.h
258netinet/ip_icmp.h
259netinet/tcp.h
260netinet/udp.h
261sys/socket.h
262sys/socketvar.h
263sys/sysctl.h
264sys/mman.h
265EOF
266
267
268# empty files
269while read f
270do
271  test ${verbose} = "yes" && echo "Generate empty file $f"
272  echo "/* empty file */" > ${f}
273done <<EOF
274local/pthread_np.h
275local/sys/_pthreadtypes.h
276EOF
277
278
279# Fix syslog.h issues...
280echo "#include <sys/syslog.h>" > local/syslog.h
281# Should be able to copy this except for printflike issue
282# sys/sys/syslog.h
283
284# netdb.h has an issue with __socklen_t which needs to be run down
285# for now, a manually edited copy is in rtems/include
286# include/rpc/rpc.h has issue with internal methods changing from
287#   old implementation to current day. We need to update our RPC
Note: See TracBrowser for help on using the repository browser.