CYTHON_SRC=cython_py.pyx
CYTHON_C=$(CYTHON_SRC:%.pyx=%.c)
CYTHON_O=$(CYTHON_SRC:%.pyx=%.o)
CYTHON_SO=$(CYTHON_SRC:%.pyx=%.so)
PYTHON_SRC=python_py.py
SETUP=setup.py

# this compiler option is set for better build
release:
	cp setup_template.py $(SETUP)
	sed -i "s:which:$(CYTHON_SRC):g" $(SETUP)
	python setup.py build_ext --inplace
	make time

# this compiler option is designed for testing purpose and relatively slow
# -fPIC flag for building a shared library in which jumps are absolute
debug:
	cython $(CYTHON_SRC)
	$(CC) -c -fPIC -I/usr/include/python2.7/ $(CYTHON_C)
	$(CC) -shared $(CYTHON_O) -o $(CYTHON_SO)

# this is supposed to be the ideal
ccode:
	$(CC) -o ccode.o -c c_code.c -O2
	$(CXX) ccode.o -o test

clean:
	$(RM) -rf $(CYTHON_C) $(CYTHON_O) $(CYTHON_SO) build *.pyc *.o test

time:
	make ccode
	python time.py
	make clean
