build-lua 1.32 KB
Newer Older
Jakob Weiss's avatar
Jakob Weiss committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
IL_INCLUDE_PATH="/usr/include"
IL_LIB_PATH="/usr/lib"
LUA_INCLUDE_PATH="/usr/include/lua5.1"
LUA_LIB_PATH="/usr/lib"
OSX=no

echo "Building the lua binding!"

export SWIG_FEATURES="-I$IL_INCLUDE_PATH"
swig -lua DevIL.i
if [ $? -ne 0 ] ; then
	echo "swig Failed to build the lua interface"
	exit 1
fi

compile() {
	gcc luadevil.c "$1" -o luadevil "-L$LUA_LIB_PATH" "-I$LUA_INCLUDE_PATH" "-I$IL_LIB_PATH" -lIL -lILU -lILUT -llua5.1 &>/dev/null
	err=$?
	if [ "$OSX" = "no" ] ; then
		gcc -shared "$1" -o DevIL.so "-L$LUA_LIB_PATH" "-I$LUA_INCLUDE_PATH" "-I$IL_LIB_PATH" -lIL -lILU -lILUT &>/dev/null
	else
	    gcc -bundle -undefined dynamic_lookup "$1" -o DevIL.so "-L$LUA_LIB_PATH" "-I$LUA_INCLUDE_PATH" "-I$IL_LIB_PATH" -lIL -lILU -lILUT &>/dev/null
	fi
	return $err
}

compile DevIL_wrap.c
if [ $? -ne 0 ] ; then
	echo 'Failed compilation'
	echo 'On some platform the file malloc.h is not present and produces a compilation error'
	echo -n 'it can be removed safely, try [y/n] ? '
	while read i ; do 
		if [ "$i" = "y" ] ; then
			sed 's/\#include\ \<malloc\.h\>//' < DevIL_wrap.c > DevIL_wrap.mod.c
			compile "DevIL_wrap.mod.c"
			if [ $? -ne 0 ] ; then
				echo 'still failing...'
				exit 2
			fi
			exit 0
		elif [ "$i" = "n" ] ; then
			echo 'ok, failing...'
			exit 3
		else
			echo 'Unknown command [y/n] ? '
		fi
	done
fi

echo "ok!"
exit 0