I just compiled Lua-5.1.3 on Solaris 10/Sparc. It's not that difficult because Lua has been written entirely in ANSI C. The first problem I encountered was the compiler being used, /usr/sfw/bin/gcc. The machine didn't have another one. The compliation process failed while trying to build the lua executable and complained about something wrong in the systems header files:
ranlib liblua.a
gcc -O2 -Wall -DLUA_USE_POSIX -DLUA_USE_DLOPEN -c -o lua.o lua.c
In file included from /usr/include/sys/signal.h:34,
from /usr/include/signal.h:26,
from lua.c:8:
/usr/include/sys/siginfo.h:259: error: parse error before "ctid_t"
/usr/include/sys/siginfo.h:292: error: parse error before '}' token
/usr/include/sys/siginfo.h:294: error: parse error before '}' token
/usr/include/sys/siginfo.h:390: error: parse error before "ctid_t"
/usr/include/sys/siginfo.h:392: error: conflicting types for `__proc'
/usr/include/sys/siginfo.h:261: error: previous declaration of `__proc'
/usr/include/sys/siginfo.h:398: error: conflicting types for `__fault'
/usr/include/sys/siginfo.h:267: error: previous declaration of `__fault'
/usr/include/sys/siginfo.h:404: error: conflicting types for `__file'
/usr/include/sys/siginfo.h:273: error: previous declaration of `__file'
/usr/include/sys/siginfo.h:420: error: conflicting types for `__prof'
/usr/include/sys/siginfo.h:287: error: previous declaration of `__prof'
/usr/include/sys/siginfo.h:424: error: conflicting types for `__rctl'
/usr/include/sys/siginfo.h:291: error: previous declaration of `__rctl'
/usr/include/sys/siginfo.h:426: error: parse error before '}' token
/usr/include/sys/siginfo.h:428: error: parse error before '}' token
/usr/include/sys/siginfo.h:432: error: parse error before "k_siginfo_t"
/usr/include/sys/siginfo.h:437: error: parse error before '}' token
In file included from /usr/include/signal.h:26,
from lua.c:8:
/usr/include/sys/signal.h:85: error: parse error before "siginfo_t"
In file included from lua.c:8:
/usr/include/signal.h:111: error: parse error before "siginfo_t"
/usr/include/signal.h:113: error: parse error before "siginfo_t"
make[2]: *** [lua.o] Error 1
make[2]: Leaving directory `/opt/gad/sources/lua-5.1.3/src'
make[1]: *** [solaris] Error 2
make[1]: Leaving directory `/opt/gad/sources/lua-5.1.3/src'
make: *** [solaris] Error 2
I changed the Makefile in
./src/Makefile to use Suns own compiler located in
/opt/SUNWspro/bin/cc.
BTW: If you never tried Sun Studio just give it a try, I can really recommend it! (Unless you have some crappy OSS package that relies on gcc.)
After this the compile itself was fine, but I had trouble installing the files. According to the error message Solaris' install can't handle several files at once:
cd src && install -p -m 0755 lua luac /usr/ucb/bin
usage: install [options] file [dir1 ...]
make: *** [install] Error 2
Well, there's an easy solution here, too: There are two installs available, one in /usr/sbin, and the other one being the BSD compatible in /usr/ucb. The last one nearly works, all you have to do is to remove the -p flag given in the install:-section of the top level Makefile.
Here are the changes I made to both Makefiles contained in the package. I used
diff -c to create them. The first block is the original package, the second block lists my changes, given in the context they appear:
# diff -c lua-5.1.3/Makefile lua-5.1.3-solaris/Makefile
*** lua-5.1.3/Makefile Thu Jan 17 18:53:37 2008
--- lua-5.1.3-solaris/Makefile Thu Apr 10 09:14:31 2008
***************
*** 23,33 ****
# How to install. If you don't have "install" (unlikely) then get install-sh at
# http : / / dev.w3.org/cvsweb/libwww/config/install-sh
# or use cp instead.
! INSTALL_EXEC= $(INSTALL) -p -m 0755
! INSTALL_DATA= $(INSTALL) -p -m 0644
# Utilities.
! INSTALL= install
MKDIR= mkdir
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
--- 23,33 ----
# How to install. If you don't have "install" (unlikely) then get install-sh at
# http : / / dev.w3.org/cvsweb/libwww/config/install-sh
# or use cp instead.
! INSTALL_EXEC= $(INSTALL) -m 0755
! INSTALL_DATA= $(INSTALL) -m 0644
# Utilities.
! INSTALL= /usr/ucb/install
MKDIR= mkdir
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
And this is for ./src/Makefile:
# diff -c lua-5.1.3/src/Makefile lua-5.1.3-solaris/src/Makefile
*** lua-5.1.3/src/Makefile Sat Jan 19 20:37:58 2008
--- lua-5.1.3-solaris/src/Makefile Thu Apr 10 09:08:11 2008
***************
*** 7,14 ****
# Your platform. See PLATS for possible values.
PLAT= none
! CC= gcc
! CFLAGS= -O2 -Wall $(MYCFLAGS)
AR= ar rcu
RANLIB= ranlib
RM= rm -f
--- 7,14 ----
# Your platform. See PLATS for possible values.
PLAT= none
! CC= /opt/SUNWspro/bin/cc
! CFLAGS= -xtarget=ultra3 -xarch=v8 -xO3 $(MYCFLAGS)
AR= ar rcu
RANLIB= ranlib
RM= rm -f
Please note that you might be interested in changing CFLAGS to something specific for your environment, especially if you're compiling for amd64/x86 (-xtarget=opteron). The settings I used should work on most modern Sun HW, e.g. everything with a UltraSparcIII CPU or newer. -xarch=v8 creates a 32 Bit binary without much optimization in regard of the CPUs chipset.
Edit: And here's the standard diff, for those of you how don't like the format used above:
# diff lua-5.1.3/Makefile lua-5.1.3-solaris/Makefile
26,27c26,27
< INSTALL_EXEC= $(INSTALL) -p -m 0755
< INSTALL_DATA= $(INSTALL) -p -m 0644
---
> INSTALL_EXEC= $(INSTALL) -m 0755
> INSTALL_DATA= $(INSTALL) -m 0644
30c30
< INSTALL= install
---
> INSTALL= /usr/ucb/install
# diff lua-5.1.3/src/Makefile lua-5.1.3-solaris/src/Makefile
10,11c10,11
< CC= gcc
< CFLAGS= -O2 -Wall $(MYCFLAGS)
---
> CC= cc
> CFLAGS= -xtarget=ultra3 -xarch=v8 -xO3 $(MYCFLAGS)
Please note that again, lua-5.1.3-solaris is the directory containing the source tree with my changes.
Errata: I accidentaly removed the $MYCFLAGS statement from CFLAGS in the original ./src/Makefile. This disables several features which are required for Lua to work. Make sure you leave ${MYCFLAGS} intact!
cptsalek - 10. Apr, 09:15