~vaifrax/inkscape/bugfix170049

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
82
83
84
85
86
87
88
89
#############################################
# Makefile for testing embedding
#
# This temporary makefile is for designing
# and testing a generic structure for embedding
# interpreters in Inkscape, and binding back
# from them into the Inkscape internals.  This
# would allow users to automate some Inkscape
# functionality.
#############################################

CXX = g++

WRAPS = \
inkscape_py_wrap.o \
inkscape_perl_wrap.o

OBJ = \
InkscapeScript.o \
InkscapeInterpreter.o \
InkscapeBinding.o \
InkscapePython.o  \
InkscapePerl.o \
$(WRAPS)

#########################################################
# NOTE that we are using the interpreters themselves, to
# discover the settings for compiling and linking
#########################################################

PERL_CFLAGS  := $(shell perl -MExtUtils::Embed -e ccopts )
PERL_LDFLAGS := $(shell perl -MExtUtils::Embed -e ldopts )

#INCLUDEPY, LIBPL, LIBRARY
PYTHON_CFLAGS := -I$(shell python -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var('INCLUDEPY')" )
PYTHON_LDPATH := $(shell python -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var('LIBPL')" )
PYTHON_LIB    := $(shell python -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var('LIBRARY')" )
PYTHON_LDFLAGS = $(PYTHON_LDPATH)/$(PYTHON_LIB)
#PYTHON_LDFLAGS = $(PYTHON_LDPATH)

GLIB_INC := $(shell pkg-config --cflags glib-2.0)
GLIB_LIB := $(shell pkg-config --libs glib-2.0)

INC = -I. -I../.. $(GLIB_INC)

CFLAGS = -g $(PYTHON_CFLAGS) $(PERL_CFLAGS)
CXXFLAGS = $(CFLAGS)

LIBS = $(PYTHON_LDFLAGS) $(PERL_LDFLAGS) $(GLIB_LIB)

all: bindtest cpptest

wraps: $(WRAPS)

bindtest: bindtest.o  $(OBJ)
	$(CXX) -o $@ bindtest.o $(OBJ) $(LIBS)

cpptest: cpptest.o $(OBJ)
	$(CXX) -o $@ cpptest.o $(OBJ) $(LIBS)


#_inkscape_py.so : inkscape_py_wrap.o $(OBJ)
#	$(CXX) -shared -o _inkscape_py.so $(OBJ)
	
inkscape_py_wrap.cpp: InkscapeBinding.h inkscape_py.i
	swig -c++ -python -o inkscape_py_wrap.cpp inkscape_py.i
	perl quotefile.pl inkscape_py.py inkscape_py.py.h
	
InkscapePython.o: InkscapePython.cpp InkscapePython.h inkscape_py_wrap.o
	$(CXX) $(CXXFLAGS) $(INC) $(PYINC) -o $@ -c InkscapePython.cpp

inkscape_perl_wrap.cpp: InkscapeBinding.h inkscape_perl.i
	swig -c++ -perl5 -static -o inkscape_perl_wrap.cpp inkscape_perl.i 
	perl quotefile.pl inkscape_perl.pm inkscape_perl.pm.h
	
InkscapePerl.o: InkscapePerl.cpp InkscapePerl.h inkscape_perl_wrap.o
	$(CXX) $(CXXFLAGS) $(INC) $(PERLINC) -o $@ -c InkscapePerl.cpp

.cpp.o:
	$(CXX) $(CXXFLAGS) $(INC) -o $@ -c $<

clean:
	-$(RM) bindtest
	-$(RM) cpptest
	-$(RM) *.o
	-$(RM) *.so
	-$(RM) *.pyc