automake中的AC_ARG_WITH和AM_CONDITIONAL使用示例

Autoconf自动化生成Makefile:从configure.ac到跨平台构建实战 在C/C++工程开发中,构建系统是连接源码与可执行文件的桥梁。传统手写Makefile难以应对跨平台差异、依赖探测与参数适配等复杂需求,而GNU Autotools提供了一套成熟解决方案。Autoconf作为configure脚本生成器,将环境探测从构建规则中分离:开发者只需维护configure.ac描述项目需求,configure运行时自动检测编译器、头文件与库依赖,并通过config.status生成适配当前平台的Makefile。这种机制提升了跨平台移植效率,是GNU工具链、嵌入式交叉编译等场景的事 阅读详情

automake中的AC_ARG_WITH和AM_CONDITIONAL使用示例

AC_ARG_WITH

AC_ARG_WITH(common,"--with-common prefix for installed COMMON-LIBRARY",COMMON_LIBRARY_HOME=$withval,COMMON_LIBRARY_HOME=)
AC_SUBST(COMMON_LIBRARY_HOME)
AS_IF([test "x$COMMON_LIBRARY_HOME" = "x"],[AC_MSG_ERROR([*** COMMON-LIBRARY could not be located. Please use the --with-common option ***.])])
经过上面的操作后,在Makefile.am中就可以引用common-library_home了,后面的AS_IF表示如果没有指定,则报错退出(执行configure时)。


最好将AC_ARG_WITH最好修改成:
  1. AC_ARG_WITH(common, AS_HELP_STRING([--with-common], [prefix for installed COMMON-LIBRARY]),COMMON_LIBRARY_HOME=$withval,COMMON_LIBRARY_HOME=)
复制代码


使用AS_HELP_STRING后,./configure --help显示的就会对齐,否则顶格原原本本输出,效果如下:
  1. Optional Packages:
  2.   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  3.   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  4.   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
  5.   --with-pic              try to use only PIC/non-PIC objects [default=use
  6.                           both]
  7.   --with-tags[=TAGS]      include additional configurations [automatic]
  8.   --with-common           prefix for installed COMMON-LIBRARY
复制代码



# Check whether --with-common-library was given.
if test "${with-common-library+set}" = set; then
  withval=$with-common-library; common-library_home=$withval
else
  common-library_home=
fi
从上可以看出,将$withval改成$with-common-library也可以。


AM_CONDITIONAL
AM_CONDITIONAL(LOG4CXX_INSTALLED_ENV, test $LOG4CXX_HOME -a -d $LOG4CXX_HOME)
【BlueZ】如何定制BlueZ编译:开启/关闭BLE/音频模块的编译参数配置 在BlueZ二次开发中,90%的开发者陷入了三个致命误区:①直接全量编译导致体积臃肿(bluetoothd可达3.2MB);②不知道BLE与音频模块的依赖关系,单独关闭某模块引发编译报错;③不清楚哪些参数互斥、哪些必须联动,盲目裁剪导致功能失效。本文基于BlueZ 5.87的configure.ac源码,系统解析所有编译参数的工作原理、依赖关系、裁剪效果,彻底掌握BlueZ编译裁剪体系,实现最小化定制编译。 阅读详情

相关推荐

Clawdbot完 整安装与使⽤指南(保姆级教程)

Clawdbot 是⼀款开源个⼈ AI 智能体(Personal AI Agent),核⼼优势为本地部署+系统级执⾏+全渠道交互,可通过聊天⼯具(Telegram/WhatsApp 等)下达指令,⾃动完成⽂件整理、代码部署、⽇程同步等任务,所有数据本地存储,隐私零泄露。截⾄2026年 1 ⽉,GitHub 星标突破 4 万+,⽀持 Windows/Mac/Linux/云服务器多平台。

A1609926242的博客 1607

autoconf AC_ARG_WITH, AC_CACHE_CHECK, AC_TRY_LINK宏学习

AC_ARG_WITH, AC_CACHE_CHECK, AC_TRY_LINK是autoconf中非常有用的三个宏,configure.ac文件中一大部分就是在用这三个宏。这三个宏的定义如下所示。AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])AC_CACHE_CHECK (message, c

青箫的博客 977

【分享】ArcGIS实现分子分母等标注实用技巧

前言 标注是显示在地图上的文字信息,是出图中不可或缺的重要元素,为了标注的样式丰富,摆放的位置灵活,因此给制图出图带来不少难度,以下分享几种本人在ArcGIS中的标注方法,实现上下标注、换行标注或分式标注的实用技巧。 普通模式与高级模式 默认为普通模式,勾选高级开启高级模式。 普通二分式标注(普通模式) [DLBM] & vbnewline & [DLMC] 标注效果展示 分行二分式标注(普通模式) [DLBM]& vbnewline & "——————" &

杨港 3万+

configure 添加--enable-xxx --with-xxx 参数选项

如果要给configure生成像--enable-XXXX,--disable-XXXX,--with-XXXX,--without-XXXX这样的参数,就需在configure.ac里用到AC_ARG_ENABLE和AC_ARG_WITH这两个宏,AC_ARG_ENABLE和AC_ARG_WITH语法如下: AC_ARG_ENABLE(option-name, help-string, action-if-present, action-if-not-present) AC_ARG_WITH (pac

z1026544682的专栏 3816

手把手教学|用飞书+扣子工作流实现自动化批量图片生成,效率提升99%!体验完整操作流程

在先前的文章中,我们已经深入探讨了扣子智能体的多种应用场景,以及如何创建和使用工作流进行高效管理。本文将引领大家通过一个具体案例,将扣子的工作流功能嵌入飞书应用中,实现操作的自动化与高效化。

weixin_66485800的博客 6028

从零开始用QP框架开发STM32:事件驱动编程实战指南(附状态机设计技巧)

本文详细介绍了如何使用QP框架在STM32上实现事件驱动编程,包括状态机设计技巧和嵌入式开发实践。通过对比传统前后台系统和RTOS,展示了QP框架在资源占用、实时性和代码可维护性方面的优势,并提供了从环境搭建到高级状态机设计的完整指南。

h6i7j8的博客 1173

变量在configure.ac,makefile.am,makefile,config.h中的传递

1、AM_CONDITIONAL (conditional, condition) 首先开头不是AC而是AM所以它是一个automake宏。在configure.ac中使用,如果条件满足就定义变量。 例如: AM_CONDITIONAL(BUILD_TIPC, test "x$libzmq_tipc_support" = "xyes") 这条在configure.ac中的语句表示,如果条件...

书香水墨 1883

TCS34725颜色识别模块实战调校:从“一坨”例程到精准RGB

本文针对TCS34725颜色识别模块初始数据不准的问题,提供了从基础例程到精准调校的实战指南。核心在于通过白光校正与黑白光校正两种方法,补偿传感器偏差与环境光影响,将原始数据准确映射为标准RGB值。文章详细阐述了校准原理、操作步骤与代码实现,并分享了进阶调试技巧与避坑指南,帮助开发者显著提升颜色识别的准确性与项目可靠性。

weixin_29188043的博客 288

20.条件语句

这些条件语句和Make的条件语句不一样。Automake的条件语句的检查是在运行configure脚本的期间,影响的是Makefile.in -> Makefile。 条件语句的使用 AM_CONDITIONAL (name, condition) 在使用条件语句之前,必须在configure.ac的此宏中定义。 该宏的作用就是执行condition,将真假结果返回给name。 name必须...

ignorantshr的博客 2171

IEC61850 通信协议测试验证实战指南:从理论到实践

本文提供了一份IEC61850通信协议从理论到实践的完整测试验证实战指南。针对MMS、GOOSE、SV三大核心协议,详细阐述了测试环境搭建、自动化脚本编写、性能与异常测试方法,并分享了常见避坑经验,旨在帮助工程师通过系统化的测试验证,确保电力自动化设备在现场的互联互通与稳定可靠运行。

neovim7hacker的博客 155

告别License烦恼:手把手教你用VS Code+Cppcheck搭建免费的MISRA-C代码检查环境

本文详细介绍了如何使用VS Code和开源工具Cppcheck搭建免费的MISRA-C代码检查环境,帮助开发者规避商业工具的高额License费用。通过四步环境搭建和实战技巧,实现高效的代码静态检查,提升嵌入式开发的安全性和可靠性。

weixin_42523326的博客 247

aotomake

================================automake中的AC_ARG_WITH和AM_CONDITIONAL使用示例=========================================automake中的AC_ARG_WITH和AM_CONDITIONAL使用示例AC_ARG_WITHAC_ARG_WITH(common,"--with-common pr...

lusic01的专栏 274

GEE:连续变化检测 CCD 第一步(导出ee.Algorithms.TemporalSegmentation.Ccdc函数的结果)

连续变化检测与分类(Continuous Change Detection and Classification, CCDC)主要有两个组件,一个连续变化检测 CCD,另外一个分类。在 Google Earth Engine (GEE)平台上进行 CCD 时间序列变化检测的时候,为了防止内存超限问题,将代码分为2阶段执行。第一阶段是运行 `ee.Algorithms.TemporalSegmentation.Ccdc` 函数,本文将详细介绍 CCD 的第一阶段的代码。

养乐多的博客 2492

大型项目使用Automake/Autoconf完成编译配置

使用过开源C/C++项目的同学们都知道,标准的编译过程已经变成了简单的三部曲:configure/make/make install, 使用起来很方便,不像平时自己写代码,要手写一堆复杂的Makefile,而且换个编译环境,Makefile还需要修改(Eclipse也是这样)。   这么好的东东当然要拿来用了,但GNU的Autotool系列博大精深,工具数量又多,涉及的语言也多,要是自

-= 大 明 =- 的专栏 923

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

autoconfig实现条件编译

  在使用开源框架的时候,可以发现大部分的源码都是使用自动生成Makefile工具生成Makefile,而这一过程大多数的又是通过configure.ac配置生成Makefile。在这里,我们不讨论它是如何进行该操作的,而是想记录一下,当我们需要给源码打patch的时候,如何实现与外部一些库的链接以及源码的宏定义区分。   相信很多人在Makefile以及源码中做过以下的操作: #incl...

chengwei_peng 2533

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Automake使用说明

说明 从零开始编写automake工程非常复杂也没有必要,我们只要能看懂开源项目的automake即可,然后根据自己实际情况进行修改即可,下面给出两个比较好的参考项目,其中spice-gtk涵盖了使用libtool生成动态库的方法,后面所有的教程都是根据这两个模板进行改编 spice-gtk virt-viewer configure.ac宏定义说明 宏 作用 示例 AC_...

dcldz5007的博客 186

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Autoconf 2.73 实战:从零构建 Hello World 项目,5步生成可分发源码包

本文详细介绍了如何使用Autoconf 2.73从零构建跨平台Hello World项目,涵盖环境准备、项目结构搭建、configure.ac配置、Makefile.am编写以及生成可分发源码包的全过程。通过5个关键步骤,开发者可以快速掌握Linux环境下Autoconf的实战应用,提升软件构建效率。

weixin_30301449的博客 274

项目中碰到的比较有意思的systemd Unit File

个人在这些方面完全是一个很老的小白,和container里面进程启动的方式不一样,当前项目需要支持在非container环境下启动独立进程。Unit file学习上比较喜欢的网址当前项目比较有意思的是 your_ownd.service.in文件由于是初学,有意思的点觉得有31 Environment 可以指定多个2 sh命令的执行3 当前为service.in文件,@bindir@ 最终提供给集成方时需要替换为定制后的路径。

weixin_44193239的博客 215

git指令如何葱master转到dev_configure.ac

## Copyright 2008-2016 Red Hat, Inc.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Fou...

weixin_36173545的博客 229

从 Git 源码树构建 curl:解读 GIT-INFO.md 与 autoreconf 构建全流程

curl 的官方发布归档(release tarball)与 Git 源码树在构建方式上存在关键差异:**Git 仓库中不包含预先生成的 `configure` 脚本**。仓库根目录的 [GIT-INFO.md](https://link.gitcode.com/i/ed657c600624cd5f67c1ecedbc5698ca) 正是为解决这一问题而存在的说明文件——它仅在 Git 仓库中维护

gitblog_00417的博客 192

Universal Ctags 构建指南:从 Autotools 到 Windows/macOS 的完整编译与配置

Universal Ctags(仓库路径 `gh_mirrors/ct/ctags`)是一个持续维护的 ctags 实现。本文以项目官方构建文档 `docs/building.rst` 为主线,系统讲解从源码构建该项目的三种主流途径:基于 Autotools 的 \*nix/GNU/Linux 构建流程(含依赖安装、LTO、交叉编译、PEG 优化等进阶配置)、Windows 下 MSVC/MinG

gitblog_00233的博客 427

iperf3 FAQ 深度解读:历史脉络、静态构建与 UDP/TCP 疑难排查实战

iperf3 是 ESnet / Lawrence Berkeley National Laboratory 开发的 TCP、UDP、SCTP 网络带宽测量工具,本项目镜像即其完整源码仓库。本文以仓库内 [docs/faq.rst](https://link.gitcode.com/i/1a76ac4765d10ba7d54e63b9d31dd37e) 为骨架,逐条解读官方 FAQ 中关于 ipe

gitblog_00508的博客 234
上一篇: uboot移植之uboot和kernel的参数传递
下一篇: 从ramdisk根文件系统启动Linux成功,及使用initramfs启动linux
音乐伴我远行
博客等级 码龄20年 19粉丝 9原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值