使用 Autotools 编译并安装一个 python 模块到 python 库路径

Using Autotools to compile and install a python module to the python library path

我开始在我的项目中使用 Autotool,我有一个 python 模块,我想将其编译成 pyc 并复制到 python 库的默认路径,以便在安装后无需定义额外的环境变量即可导入。 我可以找到许多 python 库的 Makefile.am 配置示例,但它们都使用 SWIG,这不是我的情况。 到现在为止,我在pythonlib子文件夹下的Makefile.am文件只有一行

python_PYTHON = mymodule.py

在configure.ac我有:

AM_PATH_PYTHON([2.4])

并且在 topdir Makefile.am :

ACLOCAL_AMFLAGS = -I m4
SUBDIRS=src pythonlib
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@

但是在配置后我 运行 make 命令我得到:

Making all in pythonlib
make[2]: Entering directory '/home/golosio/myproject/pythonlib'
make[2]: *** No rule to make target 'all'.  Stop.
make[2]: Leaving directory '/home/golosio/myproject/pythonlib'
make[1]: *** [Makefile:426: all-recursive] Error 1
make[1]: Leaving directory '/home/golosio/myproject'
make: *** [Makefile:358: all] Error 2

我也尝试定义pyexec_LTLIBRARIES,但没有成功。 Makefile.am文件应该写什么来编译安装模块?

抱歉,这是我的一个小错误,问题不在 Makefile.am 文件中,而是在 configure.ac 文件中,我只需要添加路径 "pythonlib" 到 AC_CONFIG_FILES:

AC_CONFIG_FILES([Makefile
src/Makefile
pythonlib/Makefile])

有了这个一切正常。