doc/api/libbabeltrace2/DoxygenLayout.xml: use `topics` tab
[babeltrace.git] / src / bindings / python / bt2 / Makefile.am
index a0eb73a93c92c52cc69285fc31068e4767bb8440..77b3bec5d48af470a452216194ed07229db31b5d 100644 (file)
@@ -1,7 +1,10 @@
+# SPDX-FileCopyrightText: 2019-2023 EfficiOS, Inc.
+# SPDX-License-Identifier: MIT
+
 # Since the shared object used by the python bindings is not built with
 # libtool, we need to add the directory containing libbabeltrace2 to the
 # linker path.
-AM_LDFLAGS=-L$(top_builddir)/src/lib/.libs
+AM_LDFLAGS += -L$(top_builddir)/src/lib/.libs
 
 INSTALLED_FILES=$(builddir)/installed_files.txt
 
@@ -17,6 +20,7 @@ SWIG_INTERFACE_FILES =                                        \
        bt2/native_bt_component_class.i.h               \
        bt2/native_bt_connection.i                      \
        bt2/native_bt_error.i                           \
+       bt2/native_bt_error.i.h                         \
        bt2/native_bt_event.i                           \
        bt2/native_bt_event_class.i                     \
        bt2/native_bt_field.i                           \
@@ -31,6 +35,8 @@ SWIG_INTERFACE_FILES =                                        \
        bt2/native_bt_message.i                         \
        bt2/native_bt_message_iterator.i                \
        bt2/native_bt_message_iterator.i.h              \
+       bt2/native_bt_mip.i                             \
+       bt2/native_bt_mip.i.h                           \
        bt2/native_bt_packet.i                          \
        bt2/native_bt_plugin.i                          \
        bt2/native_bt_plugin.i.h                        \
@@ -57,6 +63,7 @@ STATIC_BINDINGS_DEPS =                                        \
        bt2/clock_class.py                              \
        bt2/clock_snapshot.py                           \
        bt2/component.py                                \
+       bt2/component_descriptor.py                     \
        bt2/connection.py                               \
        bt2/error.py                                    \
        bt2/event.py                                    \
@@ -70,6 +77,7 @@ STATIC_BINDINGS_DEPS =                                        \
        bt2/logging.py                                  \
        bt2/message.py                                  \
        bt2/message_iterator.py                         \
+       bt2/mip.py                                      \
        bt2/object.py                                   \
        bt2/packet.py                                   \
        bt2/plugin.py                                   \
@@ -87,20 +95,50 @@ STATIC_BINDINGS_DEPS =                                      \
 # Convenience static libraries on which the Python bindings library depends.
 # These are listed in the setup.py(.in) file.
 STATIC_LIBRARIES_DEPS = \
-       $(top_builddir)/src/autodisc/libbabeltrace2-autodisc.la \
-       $(top_builddir)/src/logging/libbabeltrace2-logging.la \
-       $(top_builddir)/src/common/libbabeltrace2-common.la \
-       $(top_builddir)/src/py-common/libbabeltrace2-py-common.la
+       $(top_builddir)/src/autodisc/libautodisc.la \
+       $(top_builddir)/src/logging/liblogging.la \
+       $(top_builddir)/src/common/libcommon.la \
+       $(top_builddir)/src/py-common/libpy-common.la \
+       $(top_builddir)/src/string-format/libstring-format.la
 
 GENERATED_BINDINGS_DEPS =      \
        bt2/native_bt.c         \
        bt2/version.py          \
        setup.py
 
+# Some versions of SWIG (like 3.0.12) generate code where a parameter called
+# `swig_this` shadows a global of the same name.  Later versions (like 4.0.1)
+# have renamed this global to `Swig_This_global`.
+#
+# Disable -Wshadow for that file.
+WARN_CFLAGS = -Wno-shadow
+
+WARN_CFLAGS += -Wno-null-dereference
+
+# Python 3.8 with SWIG 4.0.2 generates a deprecated warning for 'tp_print'
+# and in general there is not much we can do about deprecations in generated
+# code.
+WARN_CFLAGS += -Wno-deprecated-declarations
+
+# Python 3.11 + gcc 12.2.0 gave warnings of this kind in Python.h.
+WARN_CFLAGS += -Wno-redundant-decls
+
+# For SWIG generated code
+WARN_CFLAGS += -Wno-missing-field-initializers
+WARN_CFLAGS += -Wno-unused-parameter
+
+# SWIG 4.2.0 generates:
+#
+#   #if __cplusplus >=201103L
+#
+# ... leading to some `-Wundef` warnings when building the extension as C, where
+# `__cplusplus` is not defined.
+WARN_CFLAGS += -Wno-undef
+
 BUILD_FLAGS=CC="$(CC)" \
-               CFLAGS="$(GLIB_CFLAGS) $(AM_CFLAGS) $(CFLAGS)" \
+               CFLAGS="$(GLIB_CFLAGS) $(AM_CFLAGS) $(CFLAGS) $(WARN_CFLAGS)" \
                CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS) -I$(srcdir)/bt2" \
-               LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS) $(GLIB_LIBS) $(LIBS)"
+               LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS) $(GLIB_LIBS) $(PYTHON_LDFLAGS) $(LIBS)"
 
 all-local: build-python-bindings.stamp
 
@@ -122,14 +160,29 @@ swig_verbose_ = $(swig_verbose_@AM_DEFAULT_V@)
 swig_verbose_0 = @echo "  SWIG     " $@;
 
 $(builddir)/bt2/native_bt.c: $(SWIG_INTERFACE_FILES)
-       $(swig_verbose)$(SWIG) -python -I"$(top_srcdir)/include" -o "$@" "$<"
+       $(swig_verbose)$(SWIG) -MD -python -I"$(top_srcdir)/include" -o "$@" "$<"
+
+-include bt2/native_bt.d
+
+pyinstall_verbose = $(pyinstall_verbose_@AM_V@)
+pyinstall_verbose_ = $(pyinstall_verbose_@AM_DEFAULT_V@)
+pyinstall_verbose_0 = @
+
+# For Python < 3.12, force the use of distutils even if setuptools is
+# installed. For Python >= 3.12, set the externally managed option to allow
+# installation in a directory which isn't in the current PYTHONPATH.
+if HAVE_PYTHON_312_OR_GREATER
+PY_INSTALL_OPTS = --single-version-externally-managed
+else
+export SETUPTOOLS_USE_DISTUTILS=stdlib
+endif
 
 install-exec-local: build-python-bindings.stamp
-       @opts="--prefix=$(prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \
+       $(pyinstall_verbose)opts="--prefix=$(prefix) --exec-prefix=$(exec_prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \
        if [ "$(DESTDIR)" != "" ]; then \
                opts="$$opts --root=$(DESTDIR)"; \
        fi; \
-       $(PYTHON) $(builddir)/setup.py install $$opts;
+       $(PYTHON) $(builddir)/setup.py install $(PY_INSTALL_OPTS) $$opts;
 
 clean-local:
        rm -rf $(builddir)/build
@@ -154,4 +207,9 @@ uninstall-local:
 EXTRA_DIST = $(STATIC_BINDINGS_DEPS) $(SWIG_INTERFACE_FILES) $(STATIC_NATIVE_LIB_SRCS)
 
 # clean: generated C and Python files (by SWIG)
-CLEANFILES = bt2/native_bt.py bt2/native_bt.c build-python-bindings.stamp copy-static-deps.stamp
+CLEANFILES = \
+       build-python-bindings.stamp \
+       bt2/native_bt.c \
+       bt2/native_bt.d \
+       bt2/native_bt.py \
+       copy-static-deps.stamp
This page took 0.025656 seconds and 4 git commands to generate.