Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 axiom (20140801-1) unstable; urgency=medium
 .
   * New upstream release
Author: Camm Maguire <camm@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- axiom-20140801.orig/lsp/Makefile.pamphlet
+++ axiom-20140801/lsp/Makefile.pamphlet
@@ -1734,13 +1734,30 @@ OUT=${OBJ}/${SYS}/bin
 all:
 	@echo 1 building ${LSP} ${GCLVERSION}
 
-gcldir: 
+${BOOKS}/tangle1.lisp: ${BOOKS}/tangle.lisp
+	cp $< $@		       
+
+GCL?=$(GCLVERSION)/bin/gcl
+
+$(GCLVERSION)/bin/gcl:
 	@echo 2 building ${GCLVERSION}
 	@tar -zxf ${ZIPS}/${GCLVERSION}.tgz
-	(cd ${GCLVERSION} ; \
-	./configure ${GCLOPTS} ; \
-	${ENV} ${MAKE} ; \
-	echo '(compiler::link (list (compile-file "${BOOKS}/tangle.lisp")) "${OUT}/lisp" (format nil "(progn (let ((*load-path* (cons ~S *load-path*)) (si::*load-types* ~S)) (compiler::emit-fn t)) (makunbound (quote *system-banner*)) (when (fboundp (quote si::sgc-on)) (si::sgc-on t)) #-native-reloc (setq compiler::*default-system-p* t))" si::*system-directory* (quote (list #+native-reloc".o" ".lsp"))) "${OBJ}/${SYS}/lib/cfuns-c.o ${OBJ}/${SYS}/lib/sockio-c.o ${OBJ}/${SYS}/lib/libspad.a")' | bin/gcl )
+	cd ${GCLVERSION} && ./configure ${GCLOPTS} && ${ENV} DESTDIR= ${MAKE}
+
+${OUT}/lisp: ${GCL} ${BOOKS}/tangle1.lisp
+	echo "(progn \
+		     (load (compile-file \"${BOOKS}/tangle1.lisp\"))\
+		     (compiler::emit-fn t)\
+		     (when (fboundp 'si::sgc-on)(si::sgc-on t))\
+		     (si::save-system \"${OUT}/lisp\"))" | ${GCL}
+
+gcldir: ${OUT}/lisp
+#	@echo 2 building ${GCLVERSION}
+#	@tar -zxf ${ZIPS}/${GCLVERSION}.tgz
+#	(cd ${GCLVERSION} ; \
+#	./configure ${GCLOPTS} ; \
+#	${ENV} ${MAKE} ; \
+#	echo '(compiler::link (list (compile-file "${BOOKS}/tangle.lisp")) "${OUT}/lisp" (format nil "(progn (let ((*load-path* (cons ~S *load-path*)) (si::*load-types* ~S)) (compiler::emit-fn t)) (makunbound (quote *system-banner*)) (when (fboundp (quote si::sgc-on)) (si::sgc-on t)) #-native-reloc (setq compiler::*default-system-p* t))" si::*system-directory* (quote (list #+native-reloc".o" ".lsp"))) "${OBJ}/${SYS}/lib/cfuns-c.o ${OBJ}/${SYS}/lib/sockio-c.o ${OBJ}/${SYS}/lib/libspad.a")' | bin/gcl )
 	@echo 13 finished system build on `date` | tee >gcldir
 
 ccldir: ${LSP}/ccl/Makefile
--- axiom-20140801.orig/src/include/com.h
+++ axiom-20140801/src/include/com.h
@@ -92,11 +92,16 @@ typedef struct {
 
 /* table of dedicated socket types */
 
+#ifndef GCL_SOURCE
+#define STATIC
 extern Sock *purpose_table[];
 extern Sock server[];
 extern Sock clients[];
 extern fd_set socket_mask;
 extern fd_set server_mask;
+#else
+#define STATIC static
+#endif
 
 /* Commands sent over the AXIOM session manager or menu socket */
 
--- axiom-20140801.orig/src/interp/cfuns.lisp.pamphlet
+++ axiom-20140801/src/interp/cfuns.lisp.pamphlet
@@ -45,6 +45,10 @@
 \end{verbatim}
 \begin{chunk}{*}
 
+(clines "
+#define GCL_SOURCE
+#include \"cfuns-c.c\"
+")
 
 (in-package "BOOT")
 
--- axiom-20140801.orig/src/interp/sockio.lisp.pamphlet
+++ axiom-20140801/src/interp/sockio.lisp.pamphlet
@@ -48,6 +48,12 @@
 
 ;; load C socket functions
 
+(clines "
+#define GCL_SOURCE
+#include \"sockio-c.c\"
+#include \"bsdsignal.c\"
+")
+
 (in-package "BOOT")
 
 #+(and :Lucid (not :ibm/370))
@@ -90,24 +96,24 @@ string with data read from connection, t
 actual string buffer. We use [[sock_get_string_buf_wrapper]] to
 resolve the problem
 \begin{chunk}{*}
-  (clines "int sock_get_string_buf_wrapper(int i, object x, int j)"
+  (clines "fixnum sock_get_string_buf_wrapper(int i, object x, int j)"
           "{ if (type_of(x)!=t_string) FEwrong_type_argument(sLstring,x);"
           "  if (x->st.st_fillp<j)"
           "    FEerror(\"string too small in sock_get_string_buf_wrapper\",0);"
-          "  return sock_get_string_buf(i, x->st.st_self, j); }")
+          "  return (fixnum)sock_get_string_buf(i, x->st.st_self, j); }")
   (defentry open_server (string) (int "open_server"))
   (defentry sock_get_int (int) (int "sock_get_int"))
   (defentry sock_send_int (int int) (int "sock_send_int"))
   (defentry sock_get_string_buf (int object int) 
-     (int "sock_get_string_buf_wrapper"))
+     (fixnum "sock_get_string_buf_wrapper"))
   (defentry sock_send_string_len (int string int) (int "sock_send_string_len"))
   (defentry sock_get_float (int) (double "sock_get_float"))
   (defentry sock_send_float (int double) (int "sock_send_float"))
-  (defentry sock_send_wakeup (int int) (int "sock_send_wakeup"))
+  (defentry sock_send_wakeup (int) (int "sock_send_wakeup"))
   (defentry server_switch () (int "server_switch"))
-  (defentry flush_stdout () (int "flush_stdout"))
+  (defentry flush_stdout () (void "flush_stdout"))
   (defentry sock_send_signal (int int) (int "sock_send_signal"))
-  (defentry print_line (string) (int "print_line"))
+  (defentry print_line (string) (void "print_line"))
   (defentry plus_infinity () (double "plus_infinity"))
   (defentry minus_infinity () (double "minus_infinity"))
   (defentry NANQ () (double "NANQ"))
--- axiom-20140801.orig/src/lib/sockio-c.c.pamphlet
+++ axiom-20140801/src/lib/sockio-c.c.pamphlet
@@ -89,17 +89,17 @@ of files are badly broken with respect t
   ( purpose_table[purpose] == NULL ? sock_accept_connection(purpose) : 1 )
 
 
-Sock clients[MaxClients];       /* socket description of spad clients */
-Sock server[2];                 /* AF_UNIX and AF_INET sockets for server */
-Sock *purpose_table[TotalMaxPurposes]; /* table of dedicated socket types */
-fd_set socket_mask;             /* bit mask of active sockets */
-fd_set server_mask;             /* bit mask of server sockets */
-int socket_closed;              /* used to identify closed socket on SIGPIPE */
-int spad_server_number = -1;    /* spad server number used in sman */
-int str_len = 0;
-int still_reading  = 0;
-
-
+STATIC Sock clients[MaxClients];       /* socket description of spad clients */
+STATIC Sock server[2];                 /* AF_UNIX and AF_INET sockets for server */
+STATIC Sock *purpose_table[TotalMaxPurposes]; /* table of dedicated socket types */
+STATIC fd_set socket_mask;             /* bit mask of active sockets */
+STATIC fd_set server_mask;             /* bit mask of server sockets */
+STATIC int socket_closed;              /* used to identify closed socket on SIGPIPE */
+STATIC int spad_server_number = -1;    /* spad server number used in sman */
+STATIC int str_len = 0;
+#ifndef GCL_SOURCE
+STATIC int still_reading  = 0;
+#endif
 
 #include "bsdsignal.h1"
 #include "sockio-c.h1"
@@ -729,7 +729,11 @@ remote_stdio(Sock *sock)
       return;
     }
     if (FD_ISSET(0, &rd)) {
+#ifdef GCL_SOURCE
+      gcl_gets(buf,1024);
+#else
       fgets(buf,1024,stdin);
+#endif
       len = strlen(buf);
       /*
           gets(buf);
@@ -745,8 +749,12 @@ remote_stdio(Sock *sock)
         return;
       else {
         *(buf + len) = '\0';
+#ifdef GCL_SOURCE
+       gcl_puts(buf);
+#else
         fputs(buf, stdout);
         fflush(stdout);
+#endif
       }
     }
   }
@@ -937,15 +945,15 @@ redirect_stdio(Sock *sock)
 /*  setbuf(stdout, NULL);  */
   fd = dup2(sock->socket, 1);
   if (fd != 1) {
-    fprintf(stderr, "Error connecting stdout to socket\n");
+    perror("Error connecting stdout to socket\n");
     return;
   }
   fd = dup2(sock->socket, 0);
   if (fd != 0) {
-    fprintf(stderr, "Error connecting stdin to socket\n");
+    perror("Error connecting stdin to socket\n");
     return;
   }
-  fprintf(stderr, "Redirected standard IO\n");
+  perror("Redirected standard IO\n");
   FD_CLR(sock->socket, &socket_mask);
 }
 
