#Lua settings

LUA_BASE = /home/User/LuaI
LUA_INCLUDE = $(LUA_BASE)/include
LUA_LIB = $(LUA_BASE)/lib

#Compiler settings

CC =gcc #g++ for c++
BUILD_FLAGS = -shared -s
COMPILE_FLAGS = -c -Wall -O3 -fpic

#Environment settings

RM = rm -f 

#MAKE


OBJECTS = main.o mul.o div.o ret.o

#top level targets

plugin: $(OBJECTS)
	$(CC) $(BUILD_FLAGS) -o plugin.dll $(OBJECTS) -L$(LUA_LIB) -llua

clean: 
	$(RM) $(OBJECTS) plugin.dll
build:
	make
	mkdir -p bin
	cp plugin.dll bin/
	make clean

#low level targets

main.o: main.c mul.h div.h ret.h
	$(CC) -c main.c $(COMPILE_FLAGS) -I$(LUA_INCLUDE)
mul.o: mul.c
	$(CC) -c mul.c $(COMPILE_FLAGS) -I$(LUA_INCLUDE)
div.o: div.c
	$(CC) -c div.c $(COMPILE_FLAGS) -I$(LUA_INCLUDE)
ret.o: ret.c
	$(CC) -c ret.c $(COMPILE_FLAGS) -I$(LUA_INCLUDE)




