Howdy!

As an attachment is a patch to the Neko VM's Makefile revision 1.26 that
makes the build process work in Mac OS X 10.3+.

Just in case you're wondering how does it work, these pages should
provide useful:
http://www.metapkg.org/wiki/12
http://developer.apple.com/documentation/DeveloperTools/Conceptual/DynamicLibraries/index.html

To build Neko VM in OS X after applying the patch, run:
$ make MACOSX=1

I also did some general cleanup to the Makefile. It's far from perfect though.
It would be great to have Neko VM build with GNU Autotools or something similar.

I haven't tested the changes on other platforms and I take no responsibility of
anything, etc. blah, blah, blah.

Big thanks to Nicolas and a happy new year to everybody!

Cheers,
Lauri

Nicolas Cannasse wrote:
> Hi,
>
> There should not be so many problems with compiling Neko on OSX.
> Actually, someone already send me a patch for this, but there was some
> changes in the C sources that I'm not sure if they are not other way of
> doing it.
>
> - first you need to build a shared library (bin/libneko.dylib). the "gcc
> -shared" parameter is not supported on OSX. I read somewhere that you
> need to use "gcc -dynamiclib". One other option is to use "libtool
> -dynamic" at link time, although I would prefer to know how to do with gcc
>
> - it seems that OSX makes a difference between "shared" (.dylib) and
> "dynamicly loadable" (.bundle/.so) libraries. Other .ndll libraries need
> to be compiled as "dynamicly loadable", only libneko.dylib is really
> "shared" in the sense of OSX.
>
> - there was another error at linking time that was due to some C globals
> not being initialized. I would like to avoid initializing all the
> globals and I think this should be possible with some compilation flag.
>
> Anyway thanks for your help, with only a few Makefile changes it should
> be possible to compile Neko on OSX.
>
> Best,
> Nicolas
>
>
> ---
> Neko : One VM to run them all
>
Hi!

I'm trying to build Neko VM 1.1 and the current CVS
revision in Mac OS X.4.3, but I get:

I uncommented the two lines under the "For OSX"
comment in the Makefile. And I tried compiling with
GCC versions 3.3 and 4.0.

I'd love to get this thing working, because I'm very
eager to try to compile haXe into Neko.


HK


--- neko-CVS/Makefile.~1.26.~   2005-12-28 17:00:37.000000000 +0200
+++ neko-CVS/Makefile   2005-12-28 20:52:11.000000000 +0200
@@ -1,21 +1,35 @@
 ### CONFIG
 
+# Set to 1 to build for Mac OS X 10.3+
+#
+MACOSX = 0
+
+SRC_DIR = src
+BIN_DIR = bin
+STD_DIR = ${BIN_DIR}/std
+
 CFLAGS = -Wall -O3 -fPIC -fomit-frame-pointer -I vm -DCOMPACT_TABLE
+
+ifeq (${MACOSX}, 0)
 MAKESO = gcc -shared -WBsymbolic
-LIBNEKO_LIBS = -ldl -lgc -lm
-LIBNEKO = -Lbin -lneko
+NEKOVM_FLAGS = -L${BIN_DIR} -lneko
+LIBNEKO_NAME = libneko.so
+LIBNEKO_FLAGS = -ldl -lgc -lm
+STD_NDLL_FLAGS = ${NEKOVM_FLAGS}
+else
+MAKESO = gcc
+NEKOVM_FLAGS = -L${PWD}/${BIN_DIR} -lneko
+LIBNEKO_NAME = libneko.dylib
+LIBNEKO_FLAGS = -ldl -lgc -lm -dynamiclib -single_module -install_name 
@executable_path/${LIBNEKO_NAME}
+STD_NDLL_FLAGS = -bundle -undefined dynamic_lookup ${NEKOVM_FLAGS}
+endif
 
-NEKO_EXEC = LD_LIBRARY_PATH=../bin:${LD_LIBRARY_PATH} NEKOPATH=../boot 
../bin/nekovm
+NEKO_EXEC = LD_LIBRARY_PATH=../${BIN_DIR}:${LD_LIBRARY_PATH} NEKOPATH=../boot 
../${BIN_DIR}/nekovm
 
 # For 64 bit
 #
 # CFLAGS += -D_64BITS
 
-# For OSX
-#
-# MAKESO = gcc -dynamic
-# LIBNEKO = 
-
 # For profiling VM
 #
 # CFLAGS += -DNEKO_PROF
@@ -31,43 +45,56 @@
 LIBNEKO_OBJECTS = vm/alloc.o vm/builtins.o vm/callback.o vm/context.o 
vm/interp.o vm/load.o vm/objtable.o vm/others.o vm/hash.o vm/module.o
 
 all: libneko nekovm std compiler libs
+       mkdir -p ${STD_DIR}/neko
+       mkdir -p ${STD_DIR}/nekoml
+       cp -R ${SRC_DIR}/*n ${STD_DIR}
+       cp -R ${SRC_DIR}/neko/*n ${STD_DIR}/neko
+       cp -R ${SRC_DIR}/nekoml/*n ${STD_DIR}/nekoml
+       cp -R ${SRC_DIR}/tools/test.n ${STD_DIR}
+       @echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+       @echo Before running nekovm from ${PWD}/${BIN_DIR},
+       @echo set the following environment variables:
+       @echo LD_LIBRARY_PATH=${PWD}/${BIN_DIR}
+       @echo NEKOPATH=${PWD}/${STD_DIR}
+       @echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
 
-libneko: bin/libneko.so
+libneko: ${BIN_DIR}/${LIBNEKO_NAME}
 
 libs:
-       (cd src; ${NEKO_EXEC} neko tools/install.neko)
-       (cd src; ${NEKO_EXEC} tools/install)
+       (cd ${SRC_DIR}; ${NEKO_EXEC} neko tools/install.neko)
+       (cd ${SRC_DIR}; ${NEKO_EXEC} tools/install)
 
 doc:
-       (cd src; ${NEKO_EXEC} neko tools/makedoc.neko)
-       (cd src; ${NEKO_EXEC} tools/makedoc)
-       
+       (cd ${SRC_DIR}; ${NEKO_EXEC} neko tools/makedoc.neko)
+       (cd ${SRC_DIR}; ${NEKO_EXEC} tools/makedoc)
+
 test:
-       (cd src; ${NEKO_EXEC} neko tools/test.neko)
-       (cd src; ${NEKO_EXEC} tools/test)
+       (cd ${SRC_DIR}; ${NEKO_EXEC} neko tools/test.neko)
+       (cd ${SRC_DIR}; ${NEKO_EXEC} tools/test)
 
-nekovm: bin/nekovm
+nekovm: ${BIN_DIR}/nekovm
 
-std: bin/std.ndll
+std: ${BIN_DIR}/std.ndll
 
 compiler:
-       (cd src; ${NEKO_EXEC} nekoml -v neko/Main.nml nekoml/Main.nml)
-       (cd src; ${NEKO_EXEC} neko -link ../bin/neko.n neko/Main)
-       (cd src; ${NEKO_EXEC} neko -link ../bin/nekoml.n nekoml/Main)
+       (cd ${SRC_DIR}; ${NEKO_EXEC} nekoml -v neko/Main.nml nekoml/Main.nml)
+       (cd ${SRC_DIR}; ${NEKO_EXEC} neko -link ../${BIN_DIR}/neko.n neko/Main)
+       (cd ${SRC_DIR}; ${NEKO_EXEC} neko -link ../${BIN_DIR}/nekoml.n 
nekoml/Main)
+       (cd ${SRC_DIR}; ${NEKO_EXEC} neko -v tools/test.neko)
 
-bin/libneko.so: ${LIBNEKO_OBJECTS}
-       ${MAKESO} -o $@ ${LIBNEKO_OBJECTS} ${LIBNEKO_LIBS}
+${BIN_DIR}/${LIBNEKO_NAME}: ${LIBNEKO_OBJECTS}
+       ${MAKESO} -o $@ ${LIBNEKO_OBJECTS} ${LIBNEKO_FLAGS}
 
-bin/nekovm: $(VM_OBJECTS)
-       ${CC} ${CFLAGS} -o $@ ${VM_OBJECTS} ${LIBNEKO}
+${BIN_DIR}/nekovm: $(VM_OBJECTS)
+       ${CC} ${CFLAGS} -o $@ ${VM_OBJECTS} ${NEKOVM_FLAGS}
 
-bin/std.ndll: ${STD_OBJECTS}
-       ${MAKESO} -o $@ ${STD_OBJECTS} ${LIBNEKO}
+${BIN_DIR}/std.ndll: ${STD_OBJECTS}
+       ${MAKESO} -o $@ ${STD_OBJECTS} ${STD_NDLL_FLAGS}
 
 clean:
-       rm -rf bin/libneko.so bin/nekovm ${LIBNEKO_OBJECTS} ${VM_OBJECTS}
-       rm -rf bin/std bin/*.ndll libs/*/*.o
-       rm -rf src/*.n src/neko/*.n src/nekoml/*.n src/tools/*.n
+       rm -rf ${BIN_DIR}/${LIBNEKO_NAME} ${BIN_DIR}/nekovm ${LIBNEKO_OBJECTS} 
${VM_OBJECTS}
+       rm -rf ${BIN_DIR}/std ${BIN_DIR}/*.ndll ${BIN_DIR}/*.n libs/*/*.o
+       rm -rf ${SRC_DIR}/*.n ${SRC_DIR}/neko/*.n ${SRC_DIR}/nekoml/*.n 
${SRC_DIR}/tools/*.n
 
 .SUFFIXES : .c .o
 


---
Neko : One VM to run them all

Reply via email to