diff options
author | Joel Sherrill <joel.sherrill@oarcorp.com> | 2012-07-11 13:23:45 -0500 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@oarcorp.com> | 2012-07-11 13:23:45 -0500 |
commit | 1b13f6981a8c459d3f6b91cebf1f359cdabbb129 (patch) | |
tree | e10151b7165f26195c23a67c810a77ee718d7973 /freebsd-userspace/from-freebsd.sh | |
parent | Clarified information in libbsd.txt. (diff) | |
download | rtems-libbsd-1b13f6981a8c459d3f6b91cebf1f359cdabbb129.tar.bz2 |
FreeBSD user space support - First additions
This requires a full checkout of the FreeBSD 8.2 source code.
The checkout we have been using is missing at least the libc,
include, and sys directories. The script to copy files in is
crude.
This eventually needs to separate the manually written .h files
out and add the RTEMS specific network initialization support
with functionality to program the IP addresses and gateways as
the old stack did.
Diffstat (limited to 'freebsd-userspace/from-freebsd.sh')
-rwxr-xr-x | freebsd-userspace/from-freebsd.sh | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/freebsd-userspace/from-freebsd.sh b/freebsd-userspace/from-freebsd.sh new file mode 100755 index 00000000..c8373b41 --- /dev/null +++ b/freebsd-userspace/from-freebsd.sh @@ -0,0 +1,205 @@ +#! /bin/bash +# +# Temporary hack of a script to get FreeBSD user space header +# files and network libc source code into this tree. +# +# NOTE: libc and include are NOT in the FreeBSD checkout used for the +# USB and TCP/IP stacks. This has to be addressed. +# +# This probably could be integrated into the main Python script. +# But so far, there are no real transformations needed and the +# script just performs two tasks: +# +# + copies source files from FreeBSD libc and include files into this tree +# + generates "wrapper" header files for the public network .h files +# +src=/home/joel/newbsd/git/freebsd-8.2 +dest=/home/joel/newbsd/git/rtems-libbsd/freebsd-userspace + +progname=${0##*/} # fast basename hack for ksh, bash + +USAGE=\ +"usage: $progname [ -opts ] + -v -- verbose + -f DIR -- FreeBSD directory + -r DIR -- rtems-libbsd top directory +" + +check_status() +{ + if [ $1 -ne 0 ] ; then + shift + echo "$USAGE" >&2 + echo >&2 + echo "FAILED: " "$*" >&2 + exit 1 + fi +} + +usage() +{ + echo "$USAGE" >&2 + exit 1 +} + +# +# process the options +# +# defaults for getopt vars +# + +src=NOTSET +dest=NOTSET +verbose="no" + +while getopts "vf:r:" OPT +do + case "$OPT" in + v) verbose="yes";; + f) src="$OPTARG";; + r) dest="$OPTARG";; + *) usage;; + esac +done + +# Check arguments specified +test ${src} != "NOTSET" +check_status $? "FreeBSD source directory not specified" + +test ${dest} != "NOTSET" +check_status $? "rtems-libbsd source directory not specified" + +# Check that they are directories +test -d ${src} +check_status $? "FreeBSD source directory is not a directory" + +test -d ${dest} +check_status $? "rtems-libbsd source directory is not a directory" + +# Check that they appear to be the right directories +test -d ${src}/include +check_status $? "FreeBSD source directory does not have include directory" + +test -d ${src}/lib/libc +check_status $? "FreeBSD source directory does not have libc directory" + +test -d ${dest}/freebsd-userspace +check_status $? "rtems-libbsd source directory does not have freebsd-userspace directory" + +dest=${dest}/freebsd-userspace + +# source files to simply copy +while read f +do + d=`dirname $f` + test -d ${dest}/${d} || mkdir -p ${dest}/${d} + test -r ${src}/${f} + check_status $? "${src}/${f} is not present" + + test ${verbose} = "yes" && echo "Simple copy $f" + cp ${src}/${f} ${dest}/${d} +done <<EOF +include/db.h +include/ifaddrs.h +include/netdb.h +include/nsswitch.h +include/resolv.h +include/arpa/nameser_compat.h +include/arpa/inet.h +sys/net/ethernet.h +sys/sys/syslog.h +lib/libc/include/libc_private.h +lib/libc/include/namespace.h +lib/libc/include/nss_tls.h +lib/libc/include/reentrant.h +lib/libc/include/resolv_mt.h +lib/libc/include/un-namespace.h +lib/libc/inet/inet_addr.c +lib/libc/inet/inet_cidr_ntop.c +lib/libc/inet/inet_cidr_pton.c +lib/libc/inet/inet_lnaof.c +lib/libc/inet/inet_makeaddr.c +lib/libc/inet/inet_neta.c +lib/libc/inet/inet_net_ntop.c +lib/libc/inet/inet_netof.c +lib/libc/inet/inet_net_pton.c +lib/libc/inet/inet_network.c +lib/libc/inet/inet_ntoa.c +lib/libc/inet/inet_ntop.c +lib/libc/inet/inet_pton.c +lib/libc/inet/nsap_addr.c +lib/libc/net/netdb_private.h +lib/libc/net/res_config.h +EOF + +# disable BIND_4_COMPAT since it trips a weird endian issue in nameser_compat.h +sed -e 's/#define BIND_4_COMPAT/\/* #define BIND_4_COMPAT *\//' \ + <${src}/include/arpa/nameser.h \ + >${dest}/include/arpa/nameser.h + +# source files to prepend "include of local/port_before.h" +while read f +do + d=`dirname $f` + test -d ${dest}/${d} || mkdir -p ${dest}/${d} + test -r ${src}/${f} + check_status $? "${src}/${f} is not present" + + test ${verbose} = "yes" && echo "Copy with prepend $f" + + ( echo "#include \"port_before.h\""; echo ; cat ${src}/${f} ) >${dest}/${f} +done <<EOF +lib/libc/net/base64.c +lib/libc/net/ether_addr.c +lib/libc/net/gethostbydns.c +lib/libc/net/gethostbyht.c +lib/libc/net/gethostbynis.c +lib/libc/net/gethostnamadr.c +lib/libc/net/getifaddrs.c +lib/libc/net/getifmaddrs.c +lib/libc/net/getnameinfo.c +lib/libc/net/getnetbydns.c +lib/libc/net/getnetbyht.c +lib/libc/net/getnetbynis.c +lib/libc/net/getnetnamadr.c +lib/libc/net/getproto.c +lib/libc/net/getprotoent.c +lib/libc/net/getprotoname.c +lib/libc/net/getservent.c +EOF + + +# files to "include with freebsd" +while read f +do + d=`dirname $f` + test -d include/${d}/${d} || mkdir -p include/${d}/${d} + + test ${verbose} = "yes" && echo "Generate wrapper $f" + echo "#include <freebsd/${f}>" > include/${f} +done <<EOF +net/if.h +net/if_dl.h +net/if_types.h +net/in.h +net/route.h +netinet/in.h +sys/socket.h +sys/sysctl.h +EOF + + +# empty files +while read f +do + test ${verbose} = "yes" && echo "Generate empty file $f" + echo "/* empty file */" > ${f} +done <<EOF +local/pthread_np.h +local/sys/_pthreadtypes.h +EOF + + +# Fix syslog.h issues... +echo "#include <sys/syslog.h>" > local/syslog.h + |