Although there are still some open issues on AIX platform, I would like
to summarize the necessary steps for compiling newLISP on AIX.
1) Depending on your C compiler you should use one of the following make files:
Code: Select all
--------------------
GNU C Compiler (gcc)
--------------------
#============================ makefile_aix_utf8 (gcc) ==================================
#
# makefile for newLISP v. 10.x.x on AIX with UTF-8 support on PowerPC CPU
#
OBJS = newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o \
nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o
# use following for UTF-8 support and add nl-utf8.o to the OBJS line
CFLAGS = -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX
CC = gcc
default: $(OBJS)
$(CC) $(OBJS) -lm -ldl -lrt -lnsl -o newlisp
.c.o:
$(CC) $(CFLAGS) $<
$(OBJS): primes.h protos.h makefile_aix_utf8
#=====================================================================================
Code: Select all
----------------------
IBM C Compiler (xlc_r)
----------------------
#========================= makefile_aix_utf8 (xlc_r) =================================
#
# makefile for newLISP v. 10.x.x on AIX with UTF-8 support on PowerPC CPU
#
#
OBJS = newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o \
nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o
# use following for UTF-8 support and add nl-utf8.o to the OBJS line
CFLAGS = -c -g -O2 -DSUPPORT_UTF8 -DAIX
CC = xlc_r
default: $(OBJS)
$(CC) $(OBJS) -lm -ldl -lrt -lnsl -o newlisp
.c.o:
$(CC) $(CFLAGS) $<
$(OBJS): primes.h protos.h makefile_aix_utf8
#=====================================================================================
and for 64bit version of newLISP
Code: Select all
#======================= makefile_aix_utf8 (xlc_r 64bit) =============================
#
# makefile for newLISP v. 10.x.x on AIX with UTF-8 support on PowerPC CPU
#
#
OBJS = newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o \
nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o
# use following for UTF-8 support and add nl-utf8.o to the OBJS line
CFLAGS = -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX
CC = xlc_r
default: $(OBJS)
OBJECT_MODE=64 $(CC) $(OBJS) -lm -ldl -lrt -lnsl -o newlisp
.c.o:
$(CC) $(CFLAGS) $<
$(OBJS): primes.h protos.h makefile_aix_utf8
#=====================================================================================
2) In "newlisp.h" insert the following lines after the line 122.
befor insert:
Code: Select all
+121 #include <sys/timeb.h>
+122 #include <sys/types.h>
+123
+124 #ifndef SOLARIS
+125 #ifndef _BSD
+126 #ifndef MAC_OSX
+127 #include <malloc.h>
+128 #endif
+129 #endif
+130 #else
+131 #include <alloca.h>
+132 #endif
after insert:
Code: Select all
+121 #include <sys/timeb.h>
+122 #include <sys/types.h>
+123
+124 #ifdef AIX
+125 #define vasprintf my_vasprintf
+126 #endif
+127
+128 #ifndef SOLARIS
+129 #ifndef _BSD
+130 #ifndef MAC_OSX
+131 #include <malloc.h>
+132 #endif
+133 #endif
+134 #else
+135 #include <alloca.h>
+136 #endif
3) In "newlisp.c" replace
Code: Select all
+69 #ifdef SOLARIS
+70 int opsys 4
+71 #endif
+72
+73 #ifdef TRU64
+74 int opsys += 5;
+75 #endif
+76
+77 #ifdef AIX
+78 int opsys += 6;
+79 #endif
with
Code: Select all
+69 #ifdef SOLARIS
+70 #ifdef TRU64
+71 int opsys = 9;
+72 #endif
+73 #ifdef AIX
+74 int opsys = 10;
+75 #else
+76 int opsys = 4;
+77 #endif
+78 #endif
4) In "nl-filesystem.c" replace
Code: Select all
+25 #ifdef SOLARIS
+26 #include <stropts.h>
+27 #ifndef TRU64
+28 #define FIONREAD I_NREAD
+29 #endif
+30 #endif
with
Code: Select all
+25 #ifdef SOLARIS
+26 #include <stropts.h>
+27 #ifndef TRU64
+28 #ifndef AIX
+29 #define FIONREAD I_NREAD
+30 #endif
+31 #endif
+32 #endif
5) In "nl-sock.c" replace
Code: Select all
+60 #ifdef SOLARIS
+61 #include <stropts.h>
+62 #include <sys/conf.h>
+63 #include <netinet/in_systm.h>
+64 #define gethostbyname2(A, B) gethostbyname(A)
+65 #ifndef TRU64
+66 #define FIONREAD I_NREAD
+67 #endif
+68 #endif
with
Code: Select all
+60 #ifdef SOLARIS
+61 #include <stropts.h>
+62 #include <sys/conf.h>
+63 #include <netinet/in_systm.h>
+64 #define gethostbyname2(A, B) gethostbyname(A)
+65 #ifndef TRU64
+66 #ifndef AIX
+67 #define FIONREAD I_NREAD
+68 #endif
+69 #endif
+70 #endif
6) In "Makefile" change all occurrences of make to gmake and insert an entry for AIX make file
after e.g. opensolaris entry:
Code: Select all
+142 opensolaris:
+143 gmake -f makefile_opensolaris
+144
+145 aix:
+146 gmake -f makefile_aix_utf8
+147
+148 mingw:
+149 gmake -f makefile_mingw
7) in "build" change all occurrences of make to gmake and insert an entry for AIX
Code: Select all
+42 SunOS)
+43 echo Discovered SunOS, making for Sparc CPU:
+44 gmake solaris
+45 exit
+46 ;;
+47 AIX)
+48 echo Discovered AIX:
+49 gmake aix
+50 exit
+51 ;;
+52 OSF1)
+53 echo Discovered Tru64 Unix, please read doc/TRU64BUILD
+54 gmake -f gmakefile_tru64
+55 exit
+56 ;;
And you see here the output of compilation runs on my machine
(AIX 5.3 CPU type:PowerPC_POWER5 1.9 GHz):
Code: Select all
----------------------------
IBM C Compiler (xlc_r 64bit)
----------------------------
# gmake
./build
Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.2'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.2'
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX newlisp.c
728 1500-010: (W) WARNING in main: Infinite loop. Program may not stop.
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-symbol.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-math.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-list.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-liststr.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-string.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-filesys.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-sock.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-import.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-xml.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-web.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-matrix.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-debug.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-utf8.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX pcre.c
OBJECT_MODE=64 xlc_r newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm -ldl -lrt -lnsl -o newlisp
gmake[2]: Leaving directory `/tmp/newlisp-10.0.2'
gmake[1]: Leaving directory `/tmp/newlisp-10.0.2'
The environment variable OBJECT_MODE=64 is necessary for 64bit version, otherwise you get the following linking error:
Code: Select all
ld: 0711-736 ERROR: Input file newlisp.o:
XCOFF64 object files are not allowed in 32-bit mode.
Code: Select all
# ./newlisp qa-dot
Testing built-in functions ...
Testing contexts as objects and scoping rules ...
total time: 8458
>>>>> TESTING: ./newlisp FINISHED WITH ERRORS:
>>>> net-lookup failed nil
UTF-8 upper-case: failed
UTF-8 lower-case: failed
Code: Select all
--------------------
GNU C Compiler (gcc)
--------------------
# gmake
./build
Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.2'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.2'
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX newlisp.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-symbol.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-math.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-list.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-liststr.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-string.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-filesys.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-sock.c
nl-sock.c: In function 'ping':
nl-sock.c:2060: warning: passing argument 6 of 'nrecvfrom' from incompatible pointer type
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-import.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-xml.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-web.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-matrix.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-debug.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-utf8.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX pcre.c
gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm -ldl -lrt -lnsl -o newlisp
gmake[2]: Leaving directory `/tmp/newlisp-10.0.2'
gmake[1]: Leaving directory `/tmp/newlisp-10.0.2'
# ./newlisp qa-dot
Testing built-in functions ...
Testing contexts as objects and scoping rules ...
total time: 5477
>>>>> TESTING: ./newlisp FINISHED WITH ERRORS:
>>>> net-lookup failed nil
>>>> share failed ERR: not enough memory in function share
called from user defined function QA:unix-test-share
called from user defined function QA:qa
UTF-8 upper-case: failed
UTF-8 lower-case: failed
Testing contexts as objects and scoping rules ...
total time: 7364
>>>>> TESTING: ./newlisp FINISHED WITH ERRORS:
>>>> net-lookup failed nil
>>>> share failed ERR: not enough memory in function share
called from user defined function QA:unix-test-share
called from user defined function QA:qa
UTF-8 upper-case: failed
UTF-8 lower-case: failed
As you see there are still some failing tests and a compilation warning.
By the way just for your information gcc doesn't accept -m64 on AIX!
Code: Select all
# gmake
./build
Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.2'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.2'
gcc -m64 -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX newlisp.c
cc1: error: invalid option '64'
gmake[2]: *** [newlisp.o] Error 1
gmake[2]: Leaving directory `/tmp/newlisp-10.0.2'
gmake[1]: *** [aix] Error 2
gmake[1]: Leaving directory `/tmp/newlisp-10.0.2'
gmake: *** [default] Error 2