#! /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 <${dest}/include/arpa/nameser.h # <${src}/include/arpa/nameser.h \ # fix include so it sees FreeBSD endian definitions sed -e 's///' \ <${src}/include/arpa/nameser_compat.h \ >${dest}/include/arpa/nameser_compat.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 <XXX mv XXX ${dest}/lib/libc/net/gethostbydns.c # 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 " ; echo "#include " ) > include/${f} done < ${f} done <" > local/syslog.h # Should be able to copy this except for printflike issue # sys/sys/syslog.h # netdb.h has an issue with __socklen_t which needs to be run down # for now, a manually edited copy is in rtems/include # include/rpc/rpc.h has issue with internal methods changing from # old implementation to current day. We need to update our RPC