-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (54 loc) · 1.4 KB
/
Copy pathMakefile
File metadata and controls
71 lines (54 loc) · 1.4 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
PROJ_NAME := YInit
SRC_DIR := ./src
BLD_DIR := ./build
OUTPUT := yinit-bin
CFLAGS := -fno-strict-overflow -Wsign-compare -O2 -Wall
PY_INC = $(shell python3-config --cflags)
PY_LIB = $(shell python3-config --ldflags)
#PYX_SRC := ${wildcard $(SRC_DIR)/*.pyx}
PYX_SRC := $(shell find ${SRC_DIR} -name '*.py')
C_SRC := $(patsubst $(SRC_DIR)%.py, $(BLD_DIR)%.c, $(PYX_SRC))
ifdef DEBUG
$(info ---=== DEBUG mode is ON: Compiling with debug flags. ===---)
ifeq ("${DEBUG}","y")
CFLAGS += -g1
else ifeq ("${DEBUG}","Y")
CFLAGS += -g3
endif
# TODO: if ${DEBUG}: 0-3 add appropriate level
else
CFLAGS += -DNDEBUG -g
endif
all: ${OUTPUT}
cythonize:
mkdir -p ${BLD_DIR}/yinit
cython --embed -3 -w ${SRC_DIR} \
launcher.py \
-o ../${BLD_DIR}/launcher.c
cython -3 -w ${SRC_DIR} \
yinit/main.py \
-o ../${BLD_DIR}/yinit/main.c
cython -3 -w ${SRC_DIR} \
yinit/runenv.py \
-o ../${BLD_DIR}/yinit
echo ${PYX_SRC}
echo ${C_SRC}
# Final compilation
compile:
gcc ${CFLAGS} \
$(shell python3-config --includes) \
${BLD_DIR}/launcher.c \
${BLD_DIR}/yinit/main.c \
${BLD_DIR}/yinit/runenv.c \
$(shell python3-config --ldflags --embed) \
-o ${BLD_DIR}/${OUTPUT}
# gcc ${CFLAGS} ${PY_INC} \
# ${BLD_DIR}/yinit/main.c \
# ${PY_LIB} \
# -o ${BLD_DIR}/${OUTPUT}
${OUTPUT}: cythonize compile
runinpython:
cd src && python -m yinit ${ARGS}
clean:
rm -f ${C_SRC} \
${BLD_DIR}/${OUTPUT}