如何提取基于GNU Build System的部分项目?

发布于 2024-09-03 10:07:15 字数 114 浏览 7 评论 0原文

当我将某些子目录从“./configure”管理的项目和所有这些东西移开时,它会尝试访问一些“../../configure.ac”和其他东西,并且不容易构建。

如何提取此类项目的一部分并使其独立?

When I move some subdirectory away from project managed by "./configure" and all that things, it tries to get to some "../../configure.ac" and other things and is not easily buildable.

How to extract part of such project and make it independent?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与君绝 2024-09-10 10:07:15

有两种方法可以解决这个问题,创建一个单独的自动工具构建过程,或者取消自动工具和手动代码,或者创建一个新的 Makefile

myprojectfoo
   |
   +-- src
   |
   +-- man
   |
   +-- messages
   |
   +-- lib
   |
   +-- include
   |
   +-- others

看一下上面的插图,一个名为 myprojectfoo 的虚构项目正在使用自动工具构建一个名为 foo 的二进制文件。顶级目录即myprojectfoo将包含configure.acMakefile.amMakefile.in,位于子目录中至少会有 Makefile.amMakefile.in。自动工具将创建并执行 make 命令来构建项目。

现在,根据我对您想要执行的操作的理解:

myprojectfoo
   |   \ /
   +-- sXc
   |   / \
   +-- man
   |
   +-- messages
   |
   +-- lib
   |     \ /
   +-- incXude
   |     / \
   +-- others

您想要取出 src 子目录,它也是 include's 。那么在这种情况下,创建一个单独的 Makefile(读取 - 无自动工具)构建会更容易。在这种情况下,会更容易。

我能想到的最好的方法是,一旦你走了,你最终必须做出决定,你想要提取的项目源的子集有多大在此之前,删除对 Makefile.amMakefile.in...的所有引用,并借用现有的简单 Makefile 模板来构建它并像这样调用它

make -f MyMakefile

或者

如果您想使用自动工具使用该子集构建一个单独的项目:

  1. 创建一个简单的 Makefile.am ,如下所示。
  2. 创建一个简单的 configure.ac ,如下所示...
  3. 在源上运行 autoscan 以挑选依赖项,添加输出文件“configure.scan”的结果' 到 configure.ac
  4. 运行 automake (执行一次!)
  5. 然后运行 ​​autoconf。它可能会抱怨缺少文件,例如 INSTALL、COPYING 等
  6. 然后对 configure.ac 进行任何后续更改,然后运行 ​​autoreconf,这将执行 automakeautoconf 和其他支持自动工具程序。

获取 Linux 的 Makefile.am 样本...

SUBDIRS = src include
ACLOCAL_AMFLAGS = -I m4

获取 Linux 的 configure.ac 样本...

AC_PREREQ(2.63)

AC_INIT([mysubsetprojectfoo], [0.1a], [[email protected]])
AC_CONFIG_AUX_DIR([build-aux])

AM_INIT_AUTOMAKE([-Wall -Werror])
AM_GNU_GETTEXT_VERSION([0.17])
AM_GNU_GETTEXT([external])
AM_CFLAGS=
# Checks for programs.
AC_HEADER_STDC
AC_PROG_CC

AC_ARG_ENABLE([debug],
[  --enable-debug               Turn on debugging],
[case "${enableval}" in
  yes) debug=true ;;
  no)  debug=false ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],[debug=false])
AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
# Checks for libraries.
AC_CHECK_LIB([mylib], [mylib_function], [:])
if test "$mylib" = :; then
        AC_MSG_ERROR([MyLib is missing.\
                                  This can be downloaded from 'http://www.foo.baz'])
fi
AC_CONFIG_HEADERS([config.h])

# Checks for header files. 
# FROM running 'autoscan' on the source directory
AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h locale.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h syslog.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_C_CONST
AC_TYPE_SIGNAL
AC_TYPE_PID_T
AC_TYPE_UID_T
AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_CHECK_FUNCS([atexit inet_ntoa memset regcomp socket strdup strerror])

AC_CONFIG_FILES([Makefile src/Makefile include/Makefile])
AC_OUTPUT

自动工具的命令位于顶部我的头脑,我可能错过了一些东西......请随时通过在这篇文章的底部对此发表评论来指出,它将进行相应的修改。

There is two ways to deal with this, create a separate auto-tools build process or do away with the auto-tools and hand code or make a new Makefile.

myprojectfoo
   |
   +-- src
   |
   +-- man
   |
   +-- messages
   |
   +-- lib
   |
   +-- include
   |
   +-- others

Have a look at the illustration above, for a fictitious project called myprojectfoo and is using auto-tools to build a binary called foo. The top-level directory i.e. myprojectfoo will have configure.ac, Makefile.am and Makefile.in, in the subdirectories there would be at least Makefile.am and Makefile.in. The auto-tools will create and execute the make commands to build the project.

Now, from what I'm understanding in what you are trying to do:

myprojectfoo
   |   \ /
   +-- sXc
   |   / \
   +-- man
   |
   +-- messages
   |
   +-- lib
   |     \ /
   +-- incXude
   |     / \
   +-- others

You want to take out the src subdirectory and it's include's also. Then in that case, it would be easier to create a separate Makefile (read - no auto-tools) build.. in that case, it would be easier.

The best way I can think of it is, you will have to make that decision ultimately, how big is the subset of the project's sources you want to extract, once you go ahead with that, remove all references to Makefile.am, Makefile.in... and borrow an existing simple Makefile template to build it and invoke it like this

make -f MyMakefile

OR

If you want to build a separate project using that subset using auto-tools:

  1. Create a bare-bones Makefile.am as shown below.
  2. Create a bare-bones configure.ac as shown below...
  3. Run autoscan on the source to pick out the dependencies, add the results of the output file 'configure.scan' to the configure.ac
  4. Run automake (Do this once!)
  5. Run autoconf then. It may complain about missing files such as INSTALL, COPYING etc
  6. Then any subsequent changes to configure.ac, run autoreconf after that, which will execute automake, autoconf, and other supporting auto-tools programs.

Taking a sample of the Makefile.am for Linux...

SUBDIRS = src include
ACLOCAL_AMFLAGS = -I m4

Taking a sample of the configure.ac for Linux...

AC_PREREQ(2.63)

AC_INIT([mysubsetprojectfoo], [0.1a], [[email protected]])
AC_CONFIG_AUX_DIR([build-aux])

AM_INIT_AUTOMAKE([-Wall -Werror])
AM_GNU_GETTEXT_VERSION([0.17])
AM_GNU_GETTEXT([external])
AM_CFLAGS=
# Checks for programs.
AC_HEADER_STDC
AC_PROG_CC

AC_ARG_ENABLE([debug],
[  --enable-debug               Turn on debugging],
[case "${enableval}" in
  yes) debug=true ;;
  no)  debug=false ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],[debug=false])
AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
# Checks for libraries.
AC_CHECK_LIB([mylib], [mylib_function], [:])
if test "$mylib" = :; then
        AC_MSG_ERROR([MyLib is missing.\
                                  This can be downloaded from 'http://www.foo.baz'])
fi
AC_CONFIG_HEADERS([config.h])

# Checks for header files. 
# FROM running 'autoscan' on the source directory
AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h locale.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h syslog.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_C_CONST
AC_TYPE_SIGNAL
AC_TYPE_PID_T
AC_TYPE_UID_T
AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_CHECK_FUNCS([atexit inet_ntoa memset regcomp socket strdup strerror])

AC_CONFIG_FILES([Makefile src/Makefile include/Makefile])
AC_OUTPUT

The commands for the auto-tools, is top of my head and I may have missed something..feel free to point out by placing a comment on this at the bottom of this post and it will be amended accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文