[1b13f69] | 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 | # |
---|
| 16 | src=/home/joel/newbsd/git/freebsd-8.2 |
---|
| 17 | dest=/home/joel/newbsd/git/rtems-libbsd/freebsd-userspace |
---|
| 18 | |
---|
| 19 | progname=${0##*/} # fast basename hack for ksh, bash |
---|
| 20 | |
---|
| 21 | USAGE=\ |
---|
| 22 | "usage: $progname [ -opts ] |
---|
| 23 | -v -- verbose |
---|
| 24 | -f DIR -- FreeBSD directory |
---|
| 25 | -r DIR -- rtems-libbsd top directory |
---|
| 26 | " |
---|
| 27 | |
---|
| 28 | check_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 | |
---|
| 39 | usage() |
---|
| 40 | { |
---|
| 41 | echo "$USAGE" >&2 |
---|
| 42 | exit 1 |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | # |
---|
| 46 | # process the options |
---|
| 47 | # |
---|
| 48 | # defaults for getopt vars |
---|
| 49 | # |
---|
| 50 | |
---|
| 51 | src=NOTSET |
---|
| 52 | dest=NOTSET |
---|
| 53 | verbose="no" |
---|
| 54 | |
---|
| 55 | while getopts "vf:r:" OPT |
---|
| 56 | do |
---|
| 57 | case "$OPT" in |
---|
| 58 | v) verbose="yes";; |
---|
| 59 | f) src="$OPTARG";; |
---|
| 60 | r) dest="$OPTARG";; |
---|
| 61 | *) usage;; |
---|
| 62 | esac |
---|
| 63 | done |
---|
| 64 | |
---|
| 65 | # Check arguments specified |
---|
| 66 | test ${src} != "NOTSET" |
---|
| 67 | check_status $? "FreeBSD source directory not specified" |
---|
| 68 | |
---|
| 69 | test ${dest} != "NOTSET" |
---|
| 70 | check_status $? "rtems-libbsd source directory not specified" |
---|
| 71 | |
---|
| 72 | # Check that they are directories |
---|
| 73 | test -d ${src} |
---|
| 74 | check_status $? "FreeBSD source directory is not a directory" |
---|
| 75 | |
---|
| 76 | test -d ${dest} |
---|
| 77 | check_status $? "rtems-libbsd source directory is not a directory" |
---|
| 78 | |
---|
| 79 | # Check that they appear to be the right directories |
---|
| 80 | test -d ${src}/include |
---|
| 81 | check_status $? "FreeBSD source directory does not have include directory" |
---|
| 82 | |
---|
| 83 | test -d ${src}/lib/libc |
---|
| 84 | check_status $? "FreeBSD source directory does not have libc directory" |
---|
| 85 | |
---|
| 86 | test -d ${dest}/freebsd-userspace |
---|
| 87 | check_status $? "rtems-libbsd source directory does not have freebsd-userspace directory" |
---|
| 88 | |
---|
| 89 | dest=${dest}/freebsd-userspace |
---|
| 90 | |
---|
| 91 | # source files to simply copy |
---|
| 92 | while read f |
---|
| 93 | do |
---|
| 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} |
---|
| 101 | done <<EOF |
---|
| 102 | include/db.h |
---|
| 103 | include/ifaddrs.h |
---|
[028aaaf] | 104 | include/netconfig.h |
---|
[1b13f69] | 105 | include/netdb.h |
---|
| 106 | include/nsswitch.h |
---|
| 107 | include/resolv.h |
---|
[028aaaf] | 108 | include/res_update.h |
---|
| 109 | include/rpc/auth.h |
---|
| 110 | include/rpc/auth_unix.h |
---|
| 111 | include/rpc/auth_des.h |
---|
| 112 | include/rpc/clnt.h |
---|
| 113 | include/rpc/clnt_soc.h |
---|
| 114 | include/rpc/clnt_stat.h |
---|
| 115 | include/rpc/pmap_clnt.h |
---|
| 116 | include/rpc/pmap_prot.h |
---|
| 117 | include/rpc/rpc.h |
---|
| 118 | include/rpc/rpcent.h |
---|
| 119 | include/rpc/rpc_msg.h |
---|
| 120 | include/rpc/rpcb_clnt.h |
---|
| 121 | include/rpc/rpcb_prot.x |
---|
| 122 | include/rpc/svc.h |
---|
| 123 | include/rpc/svc_auth.h |
---|
| 124 | include/rpc/svc_soc.h |
---|
| 125 | include/rpc/xdr.h |
---|
[1912d73] | 126 | include/arpa/ftp.h |
---|
[1b13f69] | 127 | include/arpa/inet.h |
---|
[939b12b] | 128 | include/arpa/nameser.h |
---|
[1b13f69] | 129 | sys/net/ethernet.h |
---|
[028aaaf] | 130 | sys/rpc/types.h |
---|
| 131 | sys/sys/_null.h |
---|
| 132 | sys/sys/un.h |
---|
[1b13f69] | 133 | lib/libc/include/libc_private.h |
---|
| 134 | lib/libc/include/namespace.h |
---|
| 135 | lib/libc/include/nss_tls.h |
---|
| 136 | lib/libc/include/reentrant.h |
---|
| 137 | lib/libc/include/resolv_mt.h |
---|
| 138 | lib/libc/include/un-namespace.h |
---|
| 139 | lib/libc/inet/inet_addr.c |
---|
| 140 | lib/libc/inet/inet_cidr_ntop.c |
---|
| 141 | lib/libc/inet/inet_cidr_pton.c |
---|
| 142 | lib/libc/inet/inet_lnaof.c |
---|
| 143 | lib/libc/inet/inet_makeaddr.c |
---|
| 144 | lib/libc/inet/inet_neta.c |
---|
| 145 | lib/libc/inet/inet_net_ntop.c |
---|
| 146 | lib/libc/inet/inet_netof.c |
---|
| 147 | lib/libc/inet/inet_net_pton.c |
---|
| 148 | lib/libc/inet/inet_network.c |
---|
| 149 | lib/libc/inet/inet_ntoa.c |
---|
| 150 | lib/libc/inet/inet_ntop.c |
---|
| 151 | lib/libc/inet/inet_pton.c |
---|
| 152 | lib/libc/inet/nsap_addr.c |
---|
| 153 | lib/libc/net/netdb_private.h |
---|
| 154 | lib/libc/net/res_config.h |
---|
| 155 | EOF |
---|
[939b12b] | 156 | # processed by hand |
---|
| 157 | # include/arpa/nameser_compat.h |
---|
[1b13f69] | 158 | |
---|
| 159 | # disable BIND_4_COMPAT since it trips a weird endian issue in nameser_compat.h |
---|
[939b12b] | 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 |
---|
| 165 | sed -e 's/<machine\/endian.h>/<freebsd\/machine\/endian.h>/' \ |
---|
| 166 | <${src}/include/arpa/nameser_compat.h \ |
---|
| 167 | >${dest}/include/arpa/nameser_compat.h |
---|
| 168 | |
---|
[1b13f69] | 169 | |
---|
| 170 | # source files to prepend "include of local/port_before.h" |
---|
| 171 | while read f |
---|
| 172 | do |
---|
| 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} |
---|
| 181 | done <<EOF |
---|
| 182 | lib/libc/net/base64.c |
---|
| 183 | lib/libc/net/ether_addr.c |
---|
| 184 | lib/libc/net/gethostbydns.c |
---|
| 185 | lib/libc/net/gethostbyht.c |
---|
| 186 | lib/libc/net/gethostbynis.c |
---|
| 187 | lib/libc/net/gethostnamadr.c |
---|
| 188 | lib/libc/net/getifaddrs.c |
---|
| 189 | lib/libc/net/getifmaddrs.c |
---|
| 190 | lib/libc/net/getnameinfo.c |
---|
| 191 | lib/libc/net/getnetbydns.c |
---|
| 192 | lib/libc/net/getnetbyht.c |
---|
| 193 | lib/libc/net/getnetbynis.c |
---|
| 194 | lib/libc/net/getnetnamadr.c |
---|
| 195 | lib/libc/net/getproto.c |
---|
| 196 | lib/libc/net/getprotoent.c |
---|
| 197 | lib/libc/net/getprotoname.c |
---|
| 198 | lib/libc/net/getservent.c |
---|
[028aaaf] | 199 | lib/libc/gen/gethostname.c |
---|
| 200 | lib/libc/nameser/ns_name.c |
---|
| 201 | lib/libc/nameser/ns_netint.c |
---|
| 202 | lib/libc/nameser/ns_parse.c |
---|
| 203 | lib/libc/nameser/ns_print.c |
---|
| 204 | lib/libc/nameser/ns_ttl.c |
---|
| 205 | lib/libc/net/if_indextoname.c |
---|
| 206 | lib/libc/net/if_nameindex.c |
---|
| 207 | lib/libc/net/linkaddr.c |
---|
| 208 | lib/libc/net/map_v4v6.c |
---|
| 209 | lib/libc/net/rcmd.c |
---|
| 210 | lib/libc/net/recv.c |
---|
| 211 | lib/libc/net/send.c |
---|
| 212 | lib/libc/resolv/res_private.h |
---|
| 213 | lib/libc/resolv/herror.c |
---|
| 214 | lib/libc/resolv/res_comp.c |
---|
| 215 | lib/libc/resolv/res_data.c |
---|
| 216 | lib/libc/resolv/res_debug.c |
---|
| 217 | lib/libc/resolv/res_init.c |
---|
| 218 | lib/libc/resolv/res_mkquery.c |
---|
| 219 | lib/libc/resolv/res_mkupdate.c |
---|
| 220 | lib/libc/resolv/res_query.c |
---|
| 221 | lib/libc/resolv/res_send.c |
---|
| 222 | lib/libc/resolv/res_update.c |
---|
| 223 | lib/libc/string/strsep.c |
---|
[1b13f69] | 224 | EOF |
---|
| 225 | |
---|
[939b12b] | 226 | # This file includes a private "dprintf" which conflicts with stdio.h |
---|
| 227 | sed -e 's/dprintf/DPRINTF/g' <${dest}/lib/libc/net/gethostbydns.c >XXX |
---|
| 228 | mv XXX ${dest}/lib/libc/net/gethostbydns.c |
---|
| 229 | |
---|
[1b13f69] | 230 | |
---|
| 231 | # files to "include with freebsd" |
---|
| 232 | while read f |
---|
| 233 | do |
---|
| 234 | d=`dirname $f` |
---|
| 235 | test -d include/${d}/${d} || mkdir -p include/${d}/${d} |
---|
| 236 | |
---|
| 237 | test ${verbose} = "yes" && echo "Generate wrapper $f" |
---|
[1912d73] | 238 | ( echo "#include <freebsd/bsd.h>" ; |
---|
| 239 | echo "#include <freebsd/${f}>" ) > include/${f} |
---|
[1b13f69] | 240 | done <<EOF |
---|
| 241 | net/if.h |
---|
| 242 | net/if_dl.h |
---|
| 243 | net/if_types.h |
---|
| 244 | net/in.h |
---|
| 245 | net/route.h |
---|
| 246 | netinet/in.h |
---|
| 247 | sys/socket.h |
---|
| 248 | sys/sysctl.h |
---|
| 249 | EOF |
---|
| 250 | |
---|
| 251 | |
---|
| 252 | # empty files |
---|
| 253 | while read f |
---|
| 254 | do |
---|
| 255 | test ${verbose} = "yes" && echo "Generate empty file $f" |
---|
| 256 | echo "/* empty file */" > ${f} |
---|
| 257 | done <<EOF |
---|
| 258 | local/pthread_np.h |
---|
| 259 | local/sys/_pthreadtypes.h |
---|
| 260 | EOF |
---|
| 261 | |
---|
| 262 | |
---|
| 263 | # Fix syslog.h issues... |
---|
| 264 | echo "#include <sys/syslog.h>" > local/syslog.h |
---|
[1912d73] | 265 | # Should be able to copy this except for printflike issue |
---|
| 266 | # sys/sys/syslog.h |
---|