这篇简单的介绍下了Makefile文件,但是如果你自己独自写一个完整的Makefile,这多少有些不现实。在类unix下,有个automake的工具,这个就可以好好利用.
在我的linux上,使用autoconf –version就可以知道有没有安装这个软件了。
利用同样的测试方法。
先后建立三个文件:hello.c -> configure.in -> Makefile.am 然后依次执行
aclocal && autoconf && automake --add-missing \
&& ./configure && make && ./hello
如果是安装软件的话,在上面的make后面添加 *make imstall *即可。
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("hello,world\n");
return 0;
}
root@yubo-2:/home/yubo/test/makefile# autoscan
root@yubo-2:/home/yubo/test/makefile# ls
autoscan.log configure.scan hello.c
看到上面的命令中生成了一个configure.scan文件,这个就是configure.in的模板(但是,我怎么记得现在推荐为configure.ac)
首先将configure.scan文件命名为configure.in(现在好像推荐使用configure.ac)
然后修改几个内容:
mv configure.scan configure.in
root@yubo-2:/home/yubo/test/makefile# cat configure.in
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT(hello.c) # 修改
#AC_CONFIG_SRCDIR([hello.c]) #修改
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(hello.c, 1.0) # 修改
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT(Makefile) #修改
上面的文件中,以AC开头的宏来自autoconf, 以AM开头的automake,这些宏都是用M4语言写成的。
autoconf是用来生成自动配置软件源代码脚本(configure)的工具,它是非常独立地,不需要用户的干预。
autoconf命令来处理configure.ac/configure.in文件,生成一个configure文件,生成的configure文件是一个可以移植的shell脚本,来决定哪些库是可以用的、所用的平台有哪些特征、哪些头文件和库已经找到等等,然后将收集到的这些信息,编译成标记,生成一个Makefile,同时生成一个包含已定义的预处理符号的config.h。
要生成configure文件, 你必须告诉autoconf如何找到你所用的宏,方式是使用aclocal程序来生成你的aclocal.m4
aclocal文件根据configure.in文件的内容,自动生成aclocal.m4文件, aclocal根据configure.in文件的内容,自动生成aclocal.m4文件。aclocal是一个perl 脚本程序,它的定义是:“aclocal - create aclocal.m4 by scanning configure.ac”。
root@yubo-2:/home/yubo/test/makefile# aclocal
aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in'
root@yubo-2:/home/yubo/test/makefile# ls
aclocal.m4 autom4te.cache autoscan.log configure.in hello.c
root@yubo-2:/home/yubo/test/makefile# autoconf
root@yubo-2:/home/yubo/test/makefile# ls
aclocal.m4 autom4te.cache autoscan.log configure configure.in hello.c
m4是一个宏处理器。将输入拷贝到输出,同时将宏展开。宏可以是内嵌的,也可以是用户定义的。除了可以展开宏,m4还有一些内建的函数,用来引用文件,执行命令,整数运算,文本操作,循环等。m4既可以作为编译器的前端,也可以单独作为一个宏处理器。
接下来就是新建Makefile.am文件了。automake会根据你写的Makefile.am自动生成Makefile.in文件的。
root@yubo-2:/home/yubo/test/makefile# cat Makefile.am
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=hello.c
这个命令的主要功能就是从Makefile.am文件产生Makefile.in文件,
一个典型的automake输入文件只是一系列变量的定义,从而产生Makefile.in文件。
接下来运行命令:
automake --add-missing
下面是我的显示台上的输出:
root@yubo-2:/home/yubo/test/makefile# automake -add-missing
automake: error: unrecognized option '-dd-missing'.
automake: Try '/usr/bin/automake --help' for more information.
root@yubo-2:/home/yubo/test/makefile# automake --add-missing
automake: warning: autoconf input should be named 'configure.ac', not 'configure.in'
configure.in:7: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated. For more info, see:
configure.in:7:
http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
configure.in:10: installing './compile'
configure.in:7: installing './install-sh'
configure.in:7: installing './missing'
configure.in:6: error: required file 'config.h.in' not found
Makefile.am: installing './depcomp'
automake: warning: autoconf input should be named 'configure.ac', not 'configure.in'
再次声明,我在这篇教程里,不止一次提醒我有警告产生,而且意思非常明确,你可以试一试。我这里为了结果一致,暂时没有改正过来,需要大家的注意。
基本上这篇文章就够了。
下载busybox源码,进行安装。最好使用git,这样可以进行最新的跟踪。
https://busybox.net/source.html
配置busybox,你可以使用 make menuconfig
命令。这里,有几点是需要我们注意的。
因为Linux运行环境当中是不带动态库的,所以必须以静态方式来编译BusyBox。修改
Busybox Settings —> Build Options —> [*] Build BusyBox as a static binary(no shared libs)
CONFIG_DESKTOP=n
不需要配置DESKTOP。
make
make install
这样安装完成后,在busybox目录下有个_install目录,这里面就是创造root fs的源代码。
lspci
lspci | grep -i wireless
lspci | egrep -i --color 'wifi|wlan|wireless'
我的输出是
09:00.0 Network controller: Intel Corporation Centrino Wireless-N 105
(rev c4)
请记住 09:00.0利用他你可以找到设备名或者驱动名。
我的机子上的信息是:
iwconfig 命令是一个类似于ifconfig命令的无线命令,顾名思义,就是管理网络的。它维护了基本的无线信息,比如ssid, mode,channel,bit rates, power或者更多其他的东西。下面是展示wlan0接口:
上面的图片展示了这些内容:
MAC 网络协议
ssid
The NWID
频率
接入点
比特率
电源管理 …
yubo@debian:~$ sudo iwconfig wlan0 | grep -i --color quality
Link Quality=64/70 Signal level=-46 dBm
cat /proc/net/wireless
可惜的是,在debian的系统上,这个方法貌似不太好用,倒是在Ubuntu上使用的非常好,你可以直接新建一个(Shared)wifi热点。
算是一个神器了,字符图形界面的,可以试一试。安装完成后就可以直接运行
wavemon
命令即可。
还有几个命令,暂时先写在这里,后来总结的记在这里。
做一次文章的搬运工吧!
configure.ac和configure.in是Autoconf工具(由autoconf命令产生configure 脚本)的两个主要的源文件。区别在于configure.in是一个比较旧的文件名,目前仍可 以使用。configure.ac是适用于新的软件包。.in的后缀文件名现在被推荐仅仅用于运行configure脚本后产生config.status.
Makefile.am是Automake的源文件,Automake处理它产生Makefile.in,这个文件后来被config.status处理,这样才会产生最终的Makefile.
当运行完毕./configure命令后,会产生以下文件
«穷爸爸,富爸爸»这本书很早就看过,现在结合视频重新回味一下。
不要让债务的增长速度超过收入
不要让收入的增长速度超过生产率
尽一切努力提高生产力
首先在github上创造一个fork,就是在你想要贡献的项目上的右上角,会有一个fork按钮。单击,就将这个项目fork到你的账户上了(fork俗称复制)
然后,你在本地git clone你刚刚fork的项目,记住,是git clone你github上的项目。
git clone https://github.com/yuzibo/neomutt.git
比如,我想fork neomutt项目,frok后我的账户下面就会多了这个:here.
当然,你的commit不应该落后于upstream,否则你就会制造conflict.此时你就需要添加上游分支。
git remote add upstream https://github.com/neomutt/neomutt.git
然后你就可以证实是否添加了上游分支。
git remote -v
无论什么时候做开发工作,你需要将主分支上commit更新过来。
git fetch upstream
#then view all branch
git branch -av
现在,切换到你的master分支and合并上游的主分支。
git checkout master
git merge upstream/master
这个工作有很多的益处,你自己所做的修改在自己的分支上,这样,很容易分离、独自管理,不会出现混乱。master是广播中的北京时间,自己的分支是你我自己手表上的时间,我们调整自己的时间,仅仅而且必须依靠北京时间。
首先,确保你是从master分支创建其他分支,这还是类似于标准北京时间。
git checkout master
#创建一个新分支,名字要自己的
# 或者使用git checkout -b new-fix 命令
git branch new-fix
#切换到你的新分支
git checkout new-fix
在你想要提交自己的pull 请求时,或许做一些清理工作以便使上游维护者更容易测试、接受和合并你的工作。
这里,首先,你的更新主分支上的commit。
# first, fetch master(for your master && upstream/master)
git fetch upstream
git checkout master
git merge upstream/master
# Rebase all commits on your branch
git checkout new-fix
git rebase master
这里假设你了解commit和push的流程,可以参考这里
然后,返回你的github项目,选择你的开发branch。
初次使用,难免会出现各种问题,下面是解决方法汇总。