468e7f4776d207a20197b8b447482095239aa396
[platform/upstream/python-gobject.git] / gi / _glib / Makefile.am
1 AUTOMAKE_OPTIONS = 1.7
2
3 extension_cppflags = \
4         $(PYTHON_INCLUDES) \
5         -DPY_SSIZE_T_CLEAN
6
7 extension_ldflags = \
8         -module \
9         -avoid-version
10
11 if OS_WIN32
12 # Windows requires Python modules to be explicitly linked to libpython.
13 # Extension modules are shared libaries (.dll), but need to be
14 # called .pyd for Python to load it as an extension module.
15 extension_libadd = \
16         $(PYTHON_LIBS)
17
18 extension_ldflags += \
19         -no-undefined \
20         -shrext ".pyd"
21 endif
22
23
24 pyglibdir = $(pyexecdir)/gi/_glib
25
26 pyglib_PYTHON = \
27         __init__.py \
28         option.py
29
30 lib_LTLIBRARIES = libpyglib-gi-2.0-@PYTHON_BASENAME@.la
31
32 libpyglib_gi_2_0_@PYTHON_BASENAME@_la_SOURCES = \
33         pyglib.c \
34         pyglib.h \
35         pyglib-private.h \
36         pyglib-python-compat.h
37 libpyglib_gi_2_0_@PYTHON_BASENAME@_la_CPPFLAGS = \
38         $(extension_cppflags)
39 libpyglib_gi_2_0_@PYTHON_BASENAME@_la_CFLAGS = \
40         $(GLIB_CFLAGS)
41 libpyglib_gi_2_0_@PYTHON_BASENAME@_la_LIBADD = \
42         $(extension_libadd) \
43         $(FFI_LIBS) \
44         $(GLIB_LIBS)
45
46 if OS_WIN32
47 libpyglib_gi_2_0_@PYTHON_BASENAME@_la_LDFLAGS = \
48         -no-undefined
49 endif
50
51 pyglib_LTLIBRARIES = _glib.la
52
53 _glib_la_SOURCES = \
54         glibmodule.c \
55         pygiochannel.c \
56         pygiochannel.h \
57         pygoptioncontext.c \
58         pygoptioncontext.h \
59         pygoptiongroup.c \
60         pygoptiongroup.h \
61         pygmaincontext.c \
62         pygmaincontext.h \
63         pygmainloop.c \
64         pygmainloop.h \
65         pygsource.c \
66         pygsource.h \
67         pygspawn.c \
68         pygspawn.h
69 _glib_la_CFLAGS = \
70         $(GLIB_CFLAGS)
71 _glib_la_CPPFLAGS = \
72         $(extension_cppflags)
73 _glib_la_LIBADD = \
74         $(extension_libadd) \
75         $(GLIB_LIBS) \
76         libpyglib-gi-2.0-@PYTHON_BASENAME@.la
77 _glib_la_LDFLAGS = \
78         $(extension_ldflags) \
79         -export-symbols-regex "_glib|PyInit__glib"
80
81 if PLATFORM_WIN32
82 _glib_la_CFLAGS += -DPLATFORM_WIN32
83 endif
84
85 # if we build in a separate tree, we need to symlink the *.py files from the
86 # source tree; Python does not accept the extensions and modules in different
87 # paths
88 build_pylinks:
89         for f in $(pyglib_PYTHON); do \
90             [ -e $(builddir)/$$f ] || $(LN_S) $(srcdir)/$$f $(builddir)/$$f; \
91         done
92
93
94 all: $(pyglib_LTLIBRARIES:.la=.so) build_pylinks
95 check-local: $(pyglib_LTLIBRARIES:.la=.so) build_pylinks
96 clean-local:
97         rm -f $(pyglib_LTLIBRARIES:.la=.so)
98 .la.so:
99         $(LN_S) .libs/$@ $@ || true