summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-02-26 22:55:54 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-02-26 22:55:54 -0800
commit4496c575892fa34ae9aabf4e1c0f7da87f10c4c2 (patch)
tree5e662b6f6bc1bcc42aa834a7703deaa43f92cec5 /configure
parent4f14d3a2ded6137c5dd6449f4ec2d566947c4157 (diff)
downloadtxr-4496c575892fa34ae9aabf4e1c0f7da87f10c4c2.tar.gz
txr-4496c575892fa34ae9aabf4e1c0f7da87f10c4c2.tar.bz2
txr-4496c575892fa34ae9aabf4e1c0f7da87f10c4c2.zip
Adding socket support: unix, ipv4, ipv6.
* socket.c, socket.h: New files. * Makefile: include new socket.o among objects if have_objects variable is defined to 'y'. * configure (have_sockets): New variable. New configure test for socket-related functionality. (HAVE_SOCKETS, HAVE_GETADDRINFO): New configuration preprocessor symbols. Also, reordering the shell probing so that /usr/xpg4/bin/sh is the last fallback. On Solaris, it chokes on some code that is needed for Solaris. * lisplib.c (sock_set_entries, sock_instantiate): New static functions. (lisplib_init): Register new functions as autoload hooks. * share/txr/stdlib/socket.tl: New file. * stream.c (socket_error_s): New symbol variable. (struct stdio_handle): New members, family and type, helping stdio streams represent sockets too. (stdio_stream_mark): Mark new members of struct stdio_handle. (make_stdio_stream_common): Initialize new members. (make_sock_stream, stream_fd, sock_family, sock_type, open_socket, open_sockfd): New functions. (stream_init): Initialize socket_error_s variable. Register sock-family, sock-type and open-socket intrinsic functions. Register socket-error subtype. * stream.h (socket_error_s, make_sock_stream, stream_fd, sock_family, sock_type, open_socket, open_sockfd): Declared.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure80
1 files changed, 79 insertions, 1 deletions
diff --git a/configure b/configure
index 5c6c44b9..b4158aa2 100755
--- a/configure
+++ b/configure
@@ -33,7 +33,7 @@
#
if test x$txr_shell = x ; then
- for shell in /usr/xpg4/bin/sh /bin/bash /usr/bin/bash ; do
+ for shell in /bin/bash /usr/bin/bash /usr/xpg4/bin/sh ; do
if test -x $shell ; then
txr_shell=$shell
break
@@ -128,6 +128,7 @@ have_glob=
have_windows_h=
have_windres=
have_posix_sigs=
+have_sockets=
need_darwin_c_source=
have_git=
have_pwuid=
@@ -662,6 +663,7 @@ have_glob := $have_glob
# do we modern posix signal handling?
have_posix_sigs := $have_posix_sigs
+have_sockets := $have_sockets
have_termios := $have_termios
termios_define := $termios_define
@@ -2443,6 +2445,82 @@ elif [ -n "$file_offset_define" ] ; then
lang_flags="$lang_flags -D$file_offset_define"
fi
+printf "Checking for socket API ... "
+
+cat > conftest.c <<!
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/un.h>
+
+int main(int argc, char **argv)
+{
+ static struct sockaddr_in in_addr;
+ static struct sockaddr_un un_addr;
+ static char buf[256];
+ socklen_t len;
+
+ int s = socket(AF_INET, SOCK_STREAM, 0);
+ int e0 = bind(s, (struct sockaddr *) &in_addr, sizeof in_addr);
+ int e1 = listen(s, 42);
+ int e3 = connect(s, (struct sockaddr *) &un_addr, sizeof un_addr);
+ int e4 = send(s, buf, sizeof buf, 0);
+ int e5 = sendto(s, buf, sizeof buf, 0,
+ (struct sockaddr *) &un_addr, sizeof un_addr);
+ int e6 = recv(s, buf, sizeof buf, 0);
+ int e7 = (len = sizeof in_addr,
+ recvfrom(s, buf, sizeof buf, 0,
+ (struct sockaddr *) &in_addr, &len));
+ int e8 = shutdown(s, 0);
+ in_addr_t ia = inet_addr("10.0.0.1");
+
+ return 0;
+}
+!
+
+if conftest ; then
+ printf "yes\n"
+ printf "#define HAVE_SOCKETS 1\n" >> $config_h
+ have_sockets=y
+elif conftest EXTRA_LDFLAGS="-lsocket -lnsl" ; then
+ printf "yes\n"
+ printf "#define HAVE_SOCKETS 1\n" >> $config_h
+ have_sockets=y
+ conf_ldflags="${conf_ldflags:+"$conf_ldflags "}-lsocket -lnsl"
+ printf "Need libs for sockets: regenerating %s ..." $config_make
+ gen_config_make
+ printf "done\n"
+else
+ printf "no\n"
+fi
+
+printf "Checking for getaddrinfo ... "
+
+cat > conftest.c <<!
+#include <sys/types.h>
+#include <netdb.h>
+#include <stdio.h>
+
+int main(void)
+{
+ struct addrinfo hints;
+ struct addrinfo *ptr;
+ int res = getaddrinfo("node", "serv", &hints, &ptr);
+ freeaddrinfo(ptr);
+ puts(gai_strerror(res));
+ return 0;
+}
+!
+
+if conftest ; then
+ printf "yes\n"
+ printf "#define HAVE_GETADDRINFO 1\n" >> $config_h
+else
+ printf "no\n"
+fi
+
+
#
# Dependent variables
#