autotools - 如何安装到两个已安装的可执行文件之一的符号链接(symbolic link)?

标签 autotools

编辑:我最初可能没有说清楚。

At "make install" I want the installing user to be able to set a symbolic link, "hello", that links to either a prog that's statically linked, "helloStatic," or a prog that's dynamically linked, "helloShared." See my answer.

我当前构建并安装:

  • HelloShared,这是链接到我的共享库 libsay.la 的 main.o
  • HelloStatic,这是链接到静态库 libsay.a 的 main.o

我还想安装 Hello,它将是 HelloShared 或 HelloStatic 的符号链接(symbolic link)。

我猜测可以通过提供配置或制作选项来做出选择?

我主要关心 *nix 或 cygwin,尽管如何在 Windows 安装中做到这一点也很好。

回顾一下,我想要安装两个内置的可执行文件,此外还有一个指向安装人员希望成为“正常”版本的可执行文件的符号链接(symbolic link)。如果没有选择,最好也是默认链接。

从一些源文件开始,我使用自动扫描创建了一个configure.ac,然后根据需要进行构建。

我的工作流程是:

  • autoconf -i
  • ./配置
  • 制作

制作后我得到:

$ file hello*
helloShared: Bourne-Again shell script, ASCII text executable, with very long lines
helloStatic: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=f56d94fbc40359aced749759231d3e7ae39587a0, not stripped

我的文件:

$ tree -a
├── configure.ac
├── lib
│   ├── say.c
│   └── say.h
├── m4
├── Makefile.am
└── src
    └── main.c

3 directories, 5 files

##########

$ cat configure.ac
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_INIT([Hello], [0.1])
AC_CONFIG_SRCDIR([lib/say.h])
AC_CONFIG_HEADERS([config.h])

AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Werror])
AC_CONFIG_FILES([Makefile])

AC_CONFIG_MACRO_DIRS([m4])

# Checks for programs.
AC_PROG_CC
AM_PROG_AR

LT_INIT

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT

##########

$ cat Makefile.am
ACLOCAL_AMFLAGS = -I m4

pkglib_LTLIBRARIES = libsay.la
libsay_la_SOURCES = \
    lib/say.c

libsay_la_CFLAGS = -I lib

pkglib_LIBRARIES = libsay.a
libsay_a_SOURCES = \
    lib/say.c

libsay_a_CFLAGS = -I lib

include_HEADERS = \
    lib/say.h

bin_PROGRAMS = helloShared helloStatic

helloShared_SOURCES = \
    src/main.c
helloShared_CFLAGS = -I lib
helloShared_LDADD = libsay.la

helloStatic_SOURCES = \
    src/main.c
helloStatic_CFLAGS = -I lib
helloStatic_LDADD = libsay.a

最佳答案

编写目标

install-exec-hook:
       ln whatever

文档中的示例: https://www.gnu.org/software/automake/manual/automake.html#Extending

关于autotools - 如何安装到两个已安装的可执行文件之一的符号链接(symbolic link)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42284901/

相关文章:

cross-compiling - 使用 autotools 交叉编译时使用 ccache

c++ - MakeFile.am : Mixing c and c++, 新错误

c - 如何使用 autotools 正确设置 GLib 测试框架

autotools - AC_SUBST 不扩展变量

c++ - 无法运行 Makefile.am,我该怎么办?

clang - 为什么 clang -dumpversion 报告 4.2.1

c - autotools:一个项目有一个可执行文件、一个共享对象和一个 "shared"内部库

c++ - 重新排序 gnu autotools 链接器标志

unit-testing - Autotools:如何使用 make check 运行单个测试?

makefile - autogen.sh 不(重新)生成 po/Makefile.in.in