如何在libdir的子目录中使用autotools安装lua模块
2015-7-13 17:36:41
收藏:0
阅读:103
评论:1
我编写了一个小 lua 模块,使用 autotools 编译,并且我希望修改它的组织结构:
现在在主目录中有这个:
autogen.sh
configure.ac
Makefile.am
src
file1.c
file2.c
file3.c
其中 autogen.sh
#!/bin/sh
echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS || exit 1
echo "Running libtoolize..."; libtoolize --copy --automake || exit 1;
echo "Running autoheader..." ; autoheader || exit 1
echo "Running autoconf..." ; autoconf || exit 1
echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
./configure "$@"
其中 configure.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([lua-clangc], [0.0.1], [cedlemo@gmx.com])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC(clang gcc)
# Checks for libraries.
PKG_CHECK_MODULES([DEPS], [lua])
#LUA_VERSION = $(pkg-config --version)
#AC_SUBST([LUA_VERSION])
# Checks for header files.
AC_CHECK_HEADERS([string.h stdlib.h clang-c/Index.h])
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AM_INIT_AUTOMAKE(1.13 dist-bzip2 foreign subdir-objects)
LT_PREREQ(2.4)
LT_INIT
AC_CONFIG_FILES([
Makefile
])
AC_OUTPUT
其中 Makefile.am
MAINTAINERCLEANFILES = \
Makefile.in aclocal.m4 config.h.in configure \
depcomp install-sh missing compile config.sub \
config.guess ltmain.sh compile
lib_LTLIBRARIES = src/clangc.la
src_clangc_la_SOURCES = src/clangc.c src/indexlib.c src/translationunitlib.c src/constants.c src/clangc_module_functions.c
src_clangc_la_LDFLAGS = -module -avoid-version -shared -llua -lm -lclang -fPIC
我使用以下命令编译和安装 lua 模块:
./autogen.sh --libdir=/usr/lib/lua/5.3
make
sudo make install
我的文件安装在 /usr/lib/lua/5.3 中
/usr/lib/lua/5.3/clangc.so
/usr/lib/lua/5.3/clangc.la
我想只使用以下命令:
./autogen.sh --prefix=/usr
并且 configure.ac 脚本像这样构建 libdir:
libdir=prefix + /lib/lua/ + LUA_VERSION + /clangc/
(我已经有一个方法在 configure.ac 中获取 LUA_VERSION)
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法
如常我回答自己:
我只需要修改我的 configure.ac:
AC_PREREQ([2.69]) AC_INIT([lua-clangc], [0.0.1], [cedlemo@gmx.com]) AC_CONFIG_SRCDIR([configure.ac]) AC_CONFIG_HEADERS([config.h]) # 检查程序。 AC_PROG_CC(clang gcc) # 检查库。 PKG_CHECK_MODULES([DEPS], [lua]) LUA_VERSION=$(pkg-config --modversion lua | awk -F "." '{print $1"."$2}') AC_SUBST([LUA_VERSION]) libdir=$prefix/lib/lua/$LUA_VERSION/clangc # 检查头文件。 AC_CHECK_HEADERS([string.h stdlib.h clang-c/Index.h]) # 检查 typedefs、structures 和编译器特性。 # 检查库函数。 AM_INIT_AUTOMAKE(1.13 dist-bzip2 foreign subdir-objects) LT_PREREQ(2.4) LT_INIT AC_CONFIG_FILES([ Makefile ]) AC_OUTPUT首先我需要找到当前的 lua 版本:
LUA_VERSION=$(pkg-config --modversion lua | awk -F "." '{print $1"."$2}')在我的系统上:
接着这行代码:
libdir=$prefix/lib/lua/$LUA_VERSION/clangc做了所有的魔术。
当我使用:
./autogen.sh --prefix=/usr我的库被安装在: