/
Rules.mk
42 lines (32 loc) · 1.25 KB
/
Rules.mk
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
# Standard things
sp := $(sp).x
dirstack_$(sp) := $(d)
d := $(dir)
# Local variables
OBJS_$(d):=$(d)/vm.o $(d)/generated_simulator.o $(d)/interrupt_handler.o
PROFILE_OBJECTS=$(OBJS_$(d)) $(d)/runtest.o
CFLAGS += -g -Wall -Wno-unused-variable -lm -fPIC
# Set interrupt handler
INTERRUPT_HANDLER=$(d)/interrupt_handler.c
# Use bundled cython
VPATH = $(realpath $(dir))/cython/bin
PYTHON_DEBUG=`cython 2>&1 | grep -q '\--debug' && echo --pyrex-debug`
PYTHON=`which python-dbg 2>/dev/null || which python`
PYTHONPATH := $(realpath $(dir))/cython:${PYTHONPATH}
# make sure CFLAGS are also passed to python
export PATH
export PYTHONPATH
# problem if the user has a 64-bit OS but a 32-bit Python
# We could have distutils do everything, if we care
$(d)/cli.so: $(OBJS_$(d))
cd $(dir) && CFLAGS="$(CFLAGS)" $(PYTHON) setup.py build_ext \
--inplace $(PYTHON_DEBUG)
# Local rules
$(d)/vm.o: $(d)/vm.c $(d)/vm.h $(d)/simulator.h $(d)/readelf.c $(d)/vmerrno.h $(d)/generated_simulator.h
$(d)/generated_simulator.o: $(d)/generated_simulator.c $(d)/generated_simulator.h
$(d)/runtest: $(PROFILE_OBJECTS)
$(CC) $(CFLAGS) $(PROFILE_OBJECTS) -o $@
# Standard things
-include $(DEPS_$(d))
d := $(dirstack_$(sp))
sp := $(basename $(sp))