Created
October 7, 2020 20:43
-
-
Save SpotlightKid/5fcf20783738692994ab5d4b09218527 to your computer and use it in GitHub Desktop.
Makefile for creating a standalone program via Cython from a *.py / *.pyx file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Makefile for creating a standalone program via Cython from a *.py / *.pyx file | |
PYX ?= main.pyx | |
PROG ?= $(basename $(PYX)) | |
PYTHON ?= python | |
PYVERSION = $(shell $(PYTHON) -c 'import sys;print("%d.%d" % sys.version_info[:2])') | |
PYMAJOR = $(shell $(PYTHON) -c 'import sys;print(sys.version_info[0])') | |
PYPREFIX = /usr | |
INCLUDES = -I$(PYPREFIX)/include/python$(PYVERSION) | |
$(PROG): $(PROG).o | |
@echo "Linking $(PROG) ..." | |
gcc -o $@ -lpython$(PYVERSION) $(LDFLAGS) $^ | |
$(PROG).o: $(PROG).c | |
@echo "Compiling $(PROG).o ..." | |
gcc $(CFLAGS) -c $^ $(INCLUDES) | |
$(PROG).c: $(PYX) | |
@echo "Cythonizing $(PYX) ..." | |
@cython -$(PYMAJOR) --embed $(PYX) | |
all: $(PROG) | |
clean: | |
@echo Cleaning $(PROG)... | |
@rm -f *~ *.o *.so core core.* *.c $(PROG) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment