summaryrefslogtreecommitdiff
path: root/tools/python-yasm/Makefile.inc
blob: b4275586cf5f0d8254a8afd4808d5a31122b08ce (plain)
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
72
73
74
75
76
77
78
79
80
81
# $Id$

PYBINDING_DEPS  = tools/python-yasm/bytecode.pxi
PYBINDING_DEPS += tools/python-yasm/errwarn.pxi
PYBINDING_DEPS += tools/python-yasm/expr.pxi
PYBINDING_DEPS += tools/python-yasm/floatnum.pxi
PYBINDING_DEPS += tools/python-yasm/intnum.pxi
PYBINDING_DEPS += tools/python-yasm/symrec.pxi
PYBINDING_DEPS += tools/python-yasm/value.pxi

EXTRA_DIST += tools/python-yasm/pyxelator/cparse.py
EXTRA_DIST += tools/python-yasm/pyxelator/genpyx.py
EXTRA_DIST += tools/python-yasm/pyxelator/ir.py
EXTRA_DIST += tools/python-yasm/pyxelator/lexer.py
EXTRA_DIST += tools/python-yasm/pyxelator/node.py
EXTRA_DIST += tools/python-yasm/pyxelator/parse_core.py
EXTRA_DIST += tools/python-yasm/pyxelator/work_unit.py
EXTRA_DIST += tools/python-yasm/pyxelator/wrap_yasm.py
EXTRA_DIST += tools/python-yasm/setup.py
EXTRA_DIST += tools/python-yasm/yasm.pyx
EXTRA_DIST += $(PYBINDING_DEPS)

if HAVE_PYTHON_BINDINGS

# Use Pyxelator to generate Pyrex function headers.
_yasm.pxi: ${HEADERS}
	@rm -rf .tmp
	@mkdir .tmp
	$(PYTHON) $(srcdir)/tools/python-yasm/pyxelator/wrap_yasm.py \
		"YASM_DIR=${srcdir}" "CPP=${CPP}" "CPPFLAGS=${CPPFLAGS}"
	@rm -rf .tmp

CLEANFILES += _yasm.pxi

# Need to build a local copy of the main Pyrex input file to include _yasm.pxi
# from the build directory.  Also need to fixup the other .pxi include paths.
yasm.pyx: $(srcdir)/tools/python-yasm/yasm.pyx
	sed -e 's,^include "\([^_]\),include "${srcdir}/tools/python-yasm/\1,' \
		$(srcdir)/tools/python-yasm/yasm.pyx > $@

CLEANFILES += yasm.pyx

# Actually run Pyrex
yasm_python.c: yasm.pyx _yasm.pxi $(PYBINDING_DEPS)
	$(PYTHON) -c "from Pyrex.Compiler.Main import main; main(command_line=1)" \
		-o $@ yasm.pyx

CLEANFILES += yasm_python.c

# Now the Python build magic...
python-setup.txt: Makefile
	echo "includes=${DEFS} ${DEFAULT_INCLUDES} ${INCLUDES} ${AM_CPPFLAGS} ${CPPFLAGS}" > python-setup.txt
	echo "sources=${libyasm_a_SOURCES}" >> python-setup.txt
	echo "srcdir=${srcdir}" >> python-setup.txt
	echo "gcc=${GCC}" >> python-setup.txt

CLEANFILES += python-setup.txt

.python-build: python-setup.txt yasm_python.c ${libyasm_a_SOURCES}
	$(PYTHON) `test -f tools/python-yasm/setup.py || echo '$(srcdir)/'`tools/python-yasm/setup.py build
	touch .python-build
python-build: .python-build

CLEANFILES += .python-build

python-install: .python-build
	$(PYTHON) `test -f tools/python-yasm/setup.py || echo '$(srcdir)/'`tools/python-yasm/setup.py install "--install-lib=$(DESTDIR)$(pythondir)"

python-uninstall:
	rm -f `$(PYTHON) -c "import sys;sys.path.insert(0, '${DESTDIR}${pythondir}'); import yasm; print yasm.__file__"`

else

python-build:
python-install:
python-uninstall:

endif

EXTRA_DIST += tools/python-yasm/tests/Makefile.inc
include tools/python-yasm/tests/Makefile.inc