Subject: [clisp-list] compilation issues on NetBSD-1.6 macppc

From: Russell McManus <[email-masked]>
Date: Fri Dec 20 11:00:06 2002

I am running clisp-2.27 on a NetBSD-1.6 macppc machine.  I would like
to upgrade to clisp-2.30, but I am having trouble getting 2.30 to
compile.

clisp-2.27 also does not compile on this platform without some
patches.  I don't think that these patches have been merged back into
the clisp source tree, because the changes don't show up in the 2.30
sources.  I have attached the patch files to this email message in the
hopes that they may be applied and checked into CVS.

After applying the patches needed to get 2.27 to compile to a 2.30
source tree, I am still having trouble with the compilation.  I will
send another email to the list describing the problems in more detail.

-russ

$NetBSD: patch-aa,v 1.9 2002/02/21 04:13:21 dillo Exp $

--- ../configure.orig	Tue May  8 16:09:59 2001
+++ ../configure
@@ -512,13 +512,6 @@
     makemake_args="$makemake_args --with-nogettext"
   fi
 fi
-if test -d $ABS_DIRNAME/avcall -a -d $ABS_DIRNAME/callback; then
-  (cd $ABS_DIRNAME/avcall && make) &&
-  (cd $ABS_DIRNAME/callback && make) &&
-  (cd $ABS_DIRNAME/avcall && make check) &&
-  (cd $ABS_DIRNAME/callback && make check) &&
-  makemake_args="$makemake_args --with-dynamic-ffi"
-fi
 
 if test -z "$do_build"; then
 
$NetBSD: patch-ab,v 1.4 2002/03/14 07:44:23 jmc Exp $

--- .././ffcall/avcall/Makefile.in.orig	Tue Jun 12 07:31:01 2001
+++ .././ffcall/avcall/Makefile.in	Wed Mar  6 05:38:16 2002
@@ -117,12 +117,12 @@
 	case "$(OS)" in \
 	  aix3*) syntax=aix.old;; \
 	  aix*) syntax=aix.new;; \
-	  linux*) syntax=linux;; \
+	  linux* | netbsd*) syntax=linux;; \
 	  *) syntax=sysv4;; \
 	esac; \
 	$(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c $(srcdir)/avcall-rs6000-$${syntax}.s ; \
-	cp avcall-rs6000-$${syntax}.lo avcall-rs6000.lo ; rm -f avcall-rs6000-$${syntax}.lo ; \
-	if test -f avcall-rs6000-$${syntax}.o; then mv avcall-rs6000-$${syntax}.o avcall-rs6000.o; fi
+	cp avcall-rs6000-$${syntax}.lo avcall-rs6000.lo ; \
+	if test -f avcall-rs6000-$${syntax}.o; then cp avcall-rs6000-$${syntax}.o avcall-rs6000.o; fi
 
 avcall-m88k.lo : $(srcdir)/avcall-m88k.s
 	$(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c $(srcdir)/avcall-m88k.s
$NetBSD: patch-ac,v 1.4 2002/03/14 07:44:23 jmc Exp $

--- .././ffcall/vacall/Makefile.in.orig	Tue Mar  5 09:50:39 2002
+++ .././ffcall/vacall/Makefile.in	Wed Mar  6 05:38:50 2002
@@ -108,11 +108,11 @@
 	case "$(OS)" in \
 	  aix3*) syntax=aix.old;; \
 	  aix*) syntax=aix.new;; \
-	  linux*) syntax=linux;; \
+	  linux* | netbsd*) syntax=linux;; \
 	  *) syntax=sysv4;; \
 	esac; \
 	$(CC) @GCC_X_NONE@ -c $(srcdir)/vacall-rs6000-$${syntax}.s ; \
-	mv vacall-rs6000-$${syntax}.o vacall-rs6000.o
+	cp vacall-rs6000-$${syntax}.o vacall-rs6000.o
 
 vacall-m88k.o : $(srcdir)/vacall-m88k.s
 	$(CC) @GCC_X_NONE@ -c $(srcdir)/vacall-m88k.s
$NetBSD: patch-ad,v 1.4 2002/03/14 07:44:23 jmc Exp $

--- ../ffcall/callback/vacall_r/Makefile.in.orig	Tue Jun 12 07:31:01 2001
+++ ../ffcall/callback/vacall_r/Makefile.in	Thu Mar 14 07:13:43 2002
@@ -118,11 +118,12 @@
 	  aix3*) syntax=aix.old;; \
 	  aix*) syntax=aix.new;; \
 	  linux*) syntax=linux;; \
+	  netbsd*) syntax=netbsd;; \
 	  *) syntax=sysv4;; \
 	esac; \
 	$(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c $(srcdir)/vacall-rs6000-$${syntax}.s ; \
-	cp vacall-rs6000-$${syntax}.lo vacall-rs6000.lo ; rm -f vacall-rs6000-$${syntax}.lo ; \
-	if test -f vacall-rs6000-$${syntax}.o; then mv vacall-rs6000-$${syntax}.o vacall-rs6000.o; fi
+	cp vacall-rs6000-$${syntax}.lo vacall-rs6000.lo ; \
+	if test -f vacall-rs6000-$${syntax}.o; then cp vacall-rs6000-$${syntax}.o vacall-rs6000.o; fi
 
 vacall-m88k.lo : $(srcdir)/vacall-m88k.s
 	$(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c $(srcdir)/vacall-m88k.s
$NetBSD: patch-ae,v 1.4 2002/03/14 07:44:23 jmc Exp $

--- ../ffcall/callback/trampoline_r/Makefile.in.orig	Tue Mar  5 09:57:45 2002
+++ ../ffcall/callback/trampoline_r/Makefile.in	Tue Mar  5 09:57:54 2002
@@ -90,7 +90,7 @@
 	$(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c $(srcdir)/cache-hppa.s
 
 cache-rs6000.lo : $(srcdir)/cache-rs6000-sysv4.s
-	$(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c $(srcdir)/cache-rs6000-sysv4.s ; mv -f cache-rs6000-sysv4.o cache-rs6000.o ; mv -f cache-rs6000-sysv4.lo cache-rs6000.lo
+	$(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c $(srcdir)/cache-rs6000-sysv4.s ; cp cache-rs6000-sysv4.o cache-rs6000.o ; mv cache-rs6000-sysv4.lo cache-rs6000.lo
 
 cache-convex.lo : $(srcdir)/cache-convex.s
 	$(LIBTOOL_COMPILE) $(CC) @GCC_X_NONE@ -c $(srcdir)/cache-convex.s
$NetBSD: patch-af,v 1.3 2002/03/14 07:44:23 jmc Exp $

--- lispbibl.d.orig	Tue Mar  5 20:53:41 2002
+++ lispbibl.d	Tue Mar  5 20:55:32 2002
@@ -1400,7 +1400,7 @@
     #define intBWsize intBsize
     #define intWLsize intWsize
     #define intBWLsize intBsize
-  #elif (defined(MC680X0) && defined(HPUX_ASSEMBLER)) || defined(SPARC) || defined(HPPA) || defined(MIPS) || defined(M88000) || defined(RS6000) || defined(CONVEX) || defined(S390)
+  #elif (defined(MC680X0) && defined(HPUX_ASSEMBLER)) || defined(SPARC) || defined(HPPA) || defined(MIPS) || defined(M88000) || defined(RS6000) || defined(CONVEX) || defined(S390) || defined(__powerpc__)
     # Der Sparc-Prozessor kann mit uintB und uintW schlecht rechnen.
     # Anderen 32-Bit-Prozessoren geht es genauso.
     #define intBWsize intWsize
@@ -1593,7 +1593,7 @@
     #define intDsize 16
     #define intDDsize 32  # = 2*intDsize
     #define log2_intDsize  4  # = log2(intDsize)
-  #elif defined(MC680Y0) || defined(I80386) || defined(SPARC) || defined(HPPA) || defined(MIPS) || defined(M88000) || defined(RS6000) || defined(VAX) || defined(CONVEX) || defined(ARM) || defined(DECALPHA) || defined(IA64) || defined(S390)
+  #elif defined(MC680Y0) || defined(I80386) || defined(SPARC) || defined(HPPA) || defined(MIPS) || defined(M88000) || defined(RS6000) || defined(VAX) || defined(CONVEX) || defined(ARM) || defined(DECALPHA) || defined(IA64) || defined(S390) || defined(__powerpc__)
     #define intDsize 32
     #define intDDsize 64  # = 2*intDsize
     #define log2_intDsize  5  # = log2(intDsize)
$NetBSD: patch-ag,v 1.1 2002/03/14 07:44:23 jmc Exp $

--- ../ffcall/callback/trampoline_r/test1.c.orig	Thu Mar 14 07:22:04 2002
+++ ../ffcall/callback/trampoline_r/test1.c	Thu Mar 14 07:22:07 2002
@@ -69,7 +69,11 @@
 register void* env __asm__("r12");
 #endif
 #ifdef __rs6000__
+#ifdef __NetBSD__
+register void* env __asm__("r13");
+#else
 register void* env __asm__("r11");
+#endif
 #endif
 #ifdef __m88k__
 register void* env __asm__("r11");
$NetBSD: patch-ah,v 1.1 2002/03/14 07:44:23 jmc Exp $

--- ../ffcall/callback/trampoline_r/trampoline.c.orig	Thu Mar 14 07:23:32 2002
+++ ../ffcall/callback/trampoline_r/trampoline.c	Thu Mar 14 07:23:35 2002
@@ -21,12 +21,16 @@
 #endif
 #endif
 #if defined(__rs6000__)
+#if defined(__NetBSD__)
+#define __powerpcnetbsd__
+#else
 #if !defined(_AIX)
 #define __rs6000sysv4__  /* SysV.4 ABI, real machine code. */
 #else
 #define __rs6000aix__  /* AIX ABI, just a closure. */
 #endif
 #endif
+#endif
 #if defined(__hppanew__)
 /*
  * A function pointer is a biased pointer to a data area whose first word
@@ -259,7 +263,7 @@
 #include <sys/syslocal.h>
 #endif
 /* Inline assembly function for instruction cache flush. */
-#if defined(__sparc__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppaold__) || defined(__rs6000sysv4__) || defined(__convex__)
+#if defined(__sparc__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppaold__) || defined(__rs6000sysv4__) || defined(__convex__) || defined(__powerpcnetbsd__)
 #ifdef __GNUC__
 extern inline
 #if defined(__sparc__) || defined(__sparc64__)
@@ -336,7 +340,7 @@
 #define TRAMP_LENGTH 32
 #define TRAMP_ALIGN 4
 #endif
-#ifdef __rs6000sysv4__
+#if defined(__rs6000sysv4__) || defined(__powerpcnetbsd__)
 #define TRAMP_LENGTH 24
 #define TRAMP_ALIGN 4
 #endif
@@ -872,6 +876,39 @@
 #define is_tramp(function)  \
   *(unsigned short *) (function + 0) == 0x3D60 && \
   *(unsigned short *) (function + 4) == 0x616B && \
+  *(unsigned short *) (function + 8) == 0x3C00 && \
+  *(unsigned short *) (function +12) == 0x6000 && \
+  *(unsigned long *)  (function +16) == 0x7C0903A6 && \
+  *(unsigned long *)  (function +20) == 0x4E800420
+#define hilo(hiword,loword)  \
+  (((unsigned long) (hiword) << 16) | (unsigned long) (loword))
+#define tramp_address(function)  \
+  hilo(*(unsigned short *) (function +10), *(unsigned short *) (function +14))
+#define tramp_data(function)  \
+  hilo(*(unsigned short *) (function + 2), *(unsigned short *) (function + 6))
+#endif
+#ifdef __powerpcnetbsd__
+  /* function:
+   *    {liu|lis} 13,hi16(<data>)		3D A0 hi16(<data>)
+   *    {oril|ori} 13,13,lo16(<data>)		61 AD lo16(<data>)
+   *    {liu|lis} 0,hi16(<address>)		3C 00 hi16(<address>)
+   *    {oril|ori} 0,0,lo16(<address>)		60 00 lo16(<address>)
+   *    mtctr 0					7C 09 03 A6
+   *    bctr					4E 80 04 20
+   */
+  *(short *) (function + 0) = 0x3DA0;
+  *(short *) (function + 2) = (unsigned long) data >> 16;
+  *(short *) (function + 4) = 0x61AD;
+  *(short *) (function + 6) = (unsigned long) data & 0xffff;
+  *(short *) (function + 8) = 0x3C00;
+  *(short *) (function +10) = (unsigned long) address >> 16;
+  *(short *) (function +12) = 0x6000;
+  *(short *) (function +14) = (unsigned long) address & 0xffff;
+  *(long *)  (function +16) = 0x7C0903A6;
+  *(long *)  (function +20) = 0x4E800420;
+#define is_tramp(function)  \
+  *(unsigned short *) (function + 0) == 0x3DA0 && \
+  *(unsigned short *) (function + 4) == 0x61AD && \
   *(unsigned short *) (function + 8) == 0x3C00 && \
   *(unsigned short *) (function +12) == 0x6000 && \
   *(unsigned long *)  (function +16) == 0x7C0903A6 && \

---

From: Russell McManus <[email-masked]>
Date: Fri Dec 20 14:06:04 2002

After applying the 2.27 patches as best as possible, I configured clisp with

  makemake --with-noreadline > Makefile 

I get pretty far along, but stream.c does not compile:

/export/compile/clisp-2.30/with-gcc [74]$ make
make
test -d bindings || mkdir -p bindings
gcc -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type  -fomit-frame-pointer -Wno-sign-compare -O2 -DUNICODE -DNO_GETTEXT -DNO_SIGSEGV -I. -c stream.c
stream.d: In function `lisp_completion':
stream.d:9168: warning: implicit declaration of function `rl_refresh_line'
stream.d:9182: warning: variable `array' might be clobbered by `longjmp' or `vfork'
stream.d:9189: warning: variable `ptr' might be clobbered by `longjmp' or `vfork'
stream.d:9205: warning: variable `ptr1' might be clobbered by `longjmp' or `vfork'
stream.d: In function `rd_ch_terminal3':
stream.d:9734: warning: implicit declaration of function `rl_stuff_char'
stream.d:9749: `rl_basic_quote_characters' undeclared (first use in this function)
stream.d:9749: (Each undeclared identifier is reported only once
stream.d:9749: for each function it appears in.)
stream.d:9753: `rl_already_prompted' undeclared (first use in this function)
stream.d:9807: warning: implicit declaration of function `replace_history_entry'
stream.d:9807: warning: assignment makes pointer from integer without a cast
stream.d:9809: warning: passing arg 1 of `free' discards qualifiers from pointer target type
stream.d: In function `make_terminal_stream_':
stream.d:10070: `rl_gnu_readline_p' undeclared (first use in this function)
stream.d: In function `init_streamvars':
stream.d:15293: warning: implicit declaration of function `rl_named_function'
stream.d:15293: warning: passing arg 2 of `rl_bind_key' makes pointer from integer without a cast
stream.d:15297: warning: implicit declaration of function `rl_variable_bind'
stream.d:15300: warning: implicit declaration of function `rl_add_defun'
stream.d:15300: warning: implicit declaration of function `META'
stream.d: In function `rl_memory_abort':
stream.d:15410: warning: implicit declaration of function `rl_deprep_terminal'
stream.d:15412: `rl_gnu_readline_p' undeclared (first use in this function)
*** Error code 1

Stop.
make: stopped in /export/compile/clisp-2.30/with-gcc

---

From: Sam Steingold <[email-masked]>
Date: Fri Dec 20 14:17:02 2002

> * In message <[email-masked]>
> * On the subject of "Re: [clisp-list] compilation issues on NetBSD-1.6 macppc"
> * Sent on 20 Dec 2002 17:05:43 -0500
> * Honorable Russell McManus <[email-masked]> writes:
>

wrong argument. try
--with-no-readline
--with-readline=no
--with-readline=off
--without-readline

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
I haven't lost my mind -- it's backed up on tape somewhere.

---

From: Russell McManus <[email-masked]>
Date: Fri Dec 20 18:07:02 2002

> >   makemake --with-noreadline > Makefile 

I will try with one of the above.  I see the following line in
makemake, which sent me astray:

       --with-noreadline       do not use readline library (even when present)

This is probably a documentation bug.

-russ

---

From: Russell McManus <[email-masked]>
Date: Fri Dec 20 19:15:11 2002

Thanks for the pointer about --with-readline=no.  After applying the
patches[1], and supplying --with-readline=no, I was able to get
clisp-2.30 to compile.

Thanks for the help.  Let me know if any help is required to apply the
patches.

-russ

[1] The patch to lispbibl.d had to be applied by hand because the file
has change a bit since 2.27.

Russell McManus <[email-masked]> writes:

> -------------------------------------------------------
> This SF.NET email is sponsored by:  The Best Geek Holiday Gifts!
> Time is running out!  Thinkgeek.com has the coolest gifts for
> your favorite geek.   Let your fingers do the typing.   Visit Now.
> T H I N K G E E K . C O M        http://www.thinkgeek.com/sf/
> _______________________________________________
> clisp-list mailing list
> [email-masked]
> https://lists.sourceforge.net/lists/listinfo/clisp-list

---

From: Sam Steingold <[email-masked]>
Date: Sat Dec 21 08:56:01 2002

> * In message <[email-masked]>
> * On the subject of "Re: compilation issues on NetBSD-1.6 macppc"
> * Sent on 20 Dec 2002 21:58:29 -0500
> Thanks for the pointer about --with-readline=no.

--with-noreadline should now work too.
please try the CVS head.

> has change a bit since 2.27.

I made a change to lispbibl.d which made the patch unnecessary

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Who is General Failure and why is he reading my hard disk?