当前位置:首页 > linux下软件安装配置时几个命令的用法
linux下软件安装配置时几个命令的用法
收藏到手机 转发 评论 2010-09-15 21:57
有时候在linux下面安装软件时,有部分命令是干什么的其实自己也不是很清楚,都是按照网上的资料一步一步安装的,今天来系统的总结一下,加深一些印象。
1.hello.c
debian:/home/server/helloword# vi hello.c int main(int argc, char** argv) { print(\ return 0; }
2.autoscan 执行autoscan前
debian:/home/server/helloword# ls hello.c
debian:/home/server/helloword#autoscan
执行autoscan后
debian:/home/server/helloword# ls autoscan.log configure.scan hello.c
3.编辑文件configure.in cp configure.scan configure.in 文件configure.in的内容如下:
# -*- Autoconf -*- # Process this file with autoconf to produce a configure script.
AC_INIT(hello.c)
AM_INIT_AUTOMAKE(hello, 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)
4.生成aclocal.m4及configure
可以看到configure.in内容是一些宏定义,这些宏经autoconf处理后会变成检查系统特性、环境变量、软件必须的参数的shell脚本。
执行aclocal,根据文件configure.in的内容,生成aclocal.m4文件 debian:/home/server/helloword# ls
autoscan.log configure.in configure.scan hello.c debian:/home/server/helloword# aclocal debian:/home/server/helloword# ls
aclocal.m4 autom4te.cache autoscan.log configure.in configure.scan hello.c
执行autoconf,根据文件configure.in及aclocal.m4的内容,生成configure文件,
configure是一个shell脚本 debian:/home/server/helloword# ls
aclocal.m4 autoscan.log configure.in hello.c autom4te.cache configure configure.scan
5.新建Makefile.am 输入如下的内容:
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=hello.c
automake会根据你写的Makefile.am来自动生成Makefile.in。Makefile.am中定义的宏和目标,会指导automake生成指定的代码。例如,宏bin_PROGRAMS将导致编译和连接的目标被生成。
6.运行automake
debian:/home/server/helloword# automake --add-missing
debian:/home/server/helloword# ls
aclocal.m4 autoscan.log configure.in depcomp install-sh Makefile.in autom4te.cache configure configure.scan hello.c Makefile.am missing
7.执行configure生成Makefile
debian:/home/server/helloword# ./configure
checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no checking for mawk... mawk
checking whether make sets $(MAKE)... yes checking for gcc... gcc
checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed checking for style of include used by make... GNU checking dependency style of gcc... gcc3 configure: creating ./config.status config.status: creating Makefile
config.status: executing depfiles commands
已经生成文件Makefile了
debian:/home/server/helloword# ls
aclocal.m4 config.log configure.in hello.c Makefile.am autom4te.cache config.status configure.scan install-sh Makefile.in autoscan.log configure depcomp Makefile missing
8.使用make命令通过Makefile文件编译代码 debian:/home/server/helloword# make
gcc -DPACKAGE_NAME=\\\DPACKAGE_STRING=\\\DVERSION=\\\
共分享92篇相关文档