2010年11月15日 星期一

Ubuntu software installation

telnet package:
sudo apt-get install telnetd

install emacs
sudo apt-get install emacs22

install ftp
sudo apt-get install vsftpd (default port# 23)

SSH vs WinSCP
sudo apt-get install openssh-server (default port# 22)

mySQL
sudo apt-get install libmysqlclient-dev

(check to see where mySql installed: mysql_config --cflags)
(after installed mySQL, to compile the code which uses mysql.h will be proceed)

install compiler related
sudo apt-get install build-essential

check for gcc version:
gcc -v

ubuntu 改用 gcin 方法 :

sudo apt-get update
sudo apt-get upgrade

sudo apt-get install gcin
切換成 gcin
sudo im-switch -s gcin


Redhat RHEL V5U4
To install apt:
# wget http://dag.wieers.com/packages/apt/apt-0.5.15lorg3.94a-5.el5.rf.i386.rpm
# rpm -ivh apt-0.5.15lorg3.94a-5.el5.rf.i386.rpm

# wget http://dag.wieers.com/packages/apt/apt-devel-0.5.15lorg3.94a-5.el5.rf.i386.rpm
# rpm -ivh apt-devel-0.5.15lorg3.94a-5.el5.rf.i386.rpm

# wget http://dag.wieers.com/packages/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
# rpm -ivh rpmforge-release-0.5.2-2.el5.rf.i386.rpm

RedHat Linux RPM packages:
http://dag.wieers.com/rpm/FAQ.php

http://apt.sw.be/redhat/el5/en/i386/dag/RPMS/
# rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/dag/RPMS/xxxxxxxxx.rpm

2010年11月12日 星期五

Makefile - Unix Programming Automake reference links

 http://netlab.cse.yzu.edu.tw/~armor/columns/automake/automake.htm

http://blog.xuite.net/jackie.xie/bluelove/3442480

例解 autoconf 和 automake 生成 Makefile 文件

http://www.ibm.com/developerworks/cn/linux/l-makefile/

简介: 本文介绍了在 linux 系统中,通过 Gnu autoconf 和 automake 生成 Makefile 的方法。主要探讨了生成 Makefile 的来龙去脉及其机理,接着详细介绍了配置 Configure.in 的方法及其规则。


假设src是我们源文件目录,include目录存放其他库的头文件,lib目录存放用到的库文件,然后开始按模块存放,每个模块都有一个对应的目录,模块下再分子模块,如apple、orange。每个子目录下又分core,include,shell三个目录,其中core和shell目录存放.c文件,include的存放.h文件,其他类似。

工具简介
所必须的软件:autoconf/automake/m4/perl/libtool(其中libtool非必须)。
autoconf是一个用于生成可以自动地配置软件源码包,用以适应多种UNIX类系统的shell脚本工具,其中autoconf需要用到 m4,便于生成脚本。automake是一个从Makefile.am文件自动生成Makefile.in的工具。为了生成Makefile.in,automake还需用到perl,由于automake创建的发布完全遵循GNU标准,所以在创建中不需要perl。libtool是一款方便生成各种程序库的工具。
目前automake支持三种目录层次:flat、shallow和deep。
1) flat指的是所有文件都位于同一个目录中。
就是所有源文件、头文件以及其他库文件都位于当前目录中,且没有子目录。Termutils就是这一类。
2) shallow指的是主要的源代码都储存在顶层目录,其他各个部分则储存在子目录中。
就是主要源文件在当前目录中,而其它一些实现各部分功能的源文件位于各自不同的目录。automake本身就是这一类。
3) deep指的是所有源代码都被储存在子目录中;顶层目录主要包含配置信息。
就是所有源文件及自己写的头文件位于当前目录的一个子目录中,而当前目录里没有任何源文件。 GNU cpio和GNU tar就是这一类。
flat类型是最简单的,deep类型是最复杂的。不难看出,我们的模拟需求正是基于第三类deep型,也就是说我们要做挑战性的事情:)。注:我们的测试程序是基于多线程的简单程序
生成 Makefile 的来龙去脉
首先进入 project 目录,在该目录下运行一系列命令,创建和修改几个文件,就可以生成符合该平台的Makefile文件,操作过程如下:
1) 运行autoscan命令
2) 将configure.scan 文件重命名为configure.in,并修改configure.in文件
3) 在project目录下新建Makefile.am文件,并在core和shell目录下也新建makefile.am文件
4) 在project目录下新建NEWS、 README、 ChangeLog 、AUTHORS文件
5) 将/usr/share/automake-1.X/目录下的depcomp和complie文件拷贝到本目录下
6) 运行aclocal命令
7) 运行autoconf命令
8) 运行automake -a命令
9) 运行./confiugre脚本

Configure.in的八股文
当我们利用autoscan工具生成confiugre.scan文件时,我们需要将confiugre.scan重命名为confiugre.in文件。confiugre.in调用一系列autoconf宏来测试程序需要的或用到的特性是否存在,以及这些特性的功能。
每个configure.scan文件都是以AC_INIT开头,以AC_OUTPUT结束。我们不难从文件中看出confiugre.in文件的一般布局:


实战Makefile.am
Makefile.am是一种比Makefile更高层次的规则。只需指定要生成什么目标,它由什么源文件生成,要安装到什么目录等构成。

Linux下 Makefile 的 automake 生成

Linux下Makefile的automake生成全攻略



http://blog.chinaunix.net/u2/79779/showart_1211492.html

1、建目录
$ mkdir helloword
$ cd helloworld

2、 helloworld.c

int main(int argc, char** argv)
{
printf("Hello, Linux World! ");
return 0;
}

3、生成configure

$ autoscan
$ ls
configure.scan helloworld.c

将configure.scan改名为configure.in,并且编辑它,按下面的内容修改,去掉无关的语句
$ aclocal
$ls
aclocal.m4 configure.in helloworld.c
$ autoconf
$ ls
aclocal.m4 autom4te.cache configure configure.in helloworld.c

4、新建Makefile.am

$ vi Makefile.am
内容如下:
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=helloworld
helloworld_SOURCES=helloworld.c

automake会根据你写的Makefile.am来自动生成Makefile.in

5、运行automake
$autoheader

$ automake --add-missing
configure.in: installing `./install-sh'
configure.in: installing `./mkinstalldirs'
configure.in: installing `./missing'
Makefile.am: installing `./depcomp'

automake会根据Makefile.am文件产生一些文件,包含最重要的Makefile.in。


6、执行configure生成Makefile
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output... 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 ANSI C... 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

$ ls -l Makefile
-rw-rw-r-- 1 yutao yutao 15035 Oct 15 10:40 Makefile

你可以看到,此时Makefile已经产生出来了。
7、使用Makefile编译代码
$ make
if gcc -DPACKAGE_NAME="" -DPACKAGE_TARNAME="" -DPACKAGE_VERSION="" -
DPACKAGE_STRING="" -DPACKAGE_BUGREPORT="" -DPACKAGE="helloworld" -DVERSION="1.0"

-I. -I. -g -O2 -MT helloworld.o -MD -MP -MF ".deps/helloworld.Tpo"
-c -o helloworld.o `test -f 'helloworld.c'
echo './'`helloworld.c;
then mv -f ".deps/helloworld.Tpo" ".deps/helloworld.Po";
else rm -f ".deps/helloworld.Tpo"; exit 1;
fi
gcc -g -O2 -o helloworld helloworld.o

运行helloworld
$ ./helloworld
Hello, Linux World!