autotools文档格式.docx
《autotools文档格式.docx》由会员分享,可在线阅读,更多相关《autotools文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
STRING----\n\"
%s\"
\n"
string);
return
0;
}
//interface
of
this
program
main(int
argc
char
**argv){
str_read[1024];
Please
INPUT
something
end
by
[ENTER]\n"
);
scanf("
%s"
str_read);
str(str_read
3、生成configure.ac
configure.ac是automake的输入文件,所以必须先生成该文件。
执行命令:
[root@localhost
str]#
ls
src
autoscan
autom4te:
configure.ac:
no
such
file
or
directory
autoscan:
/usr/bin/autom4te
failed
with
exit
status:
1
autoscan.log
configure.scan
cp
configure.ac
修改
#
-*-
Autoconf
-*-
Process
to
produce
a
configure
script.
AC_PREREQ(2.59)
AC_INIT(FULL-PACKAGE-NAME,
VERSION,
BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([include/str.h])
AC_CONFIG_HEADER([config.h])
Checks
for
programs.
AC_PROG_CC
libraries.
header
files.
typedefs,
structures,
and
compiler
characteristics.
library
functions.
AC_OUTPUT
修改
为
AC_INIT(str,0.0.1,
[bug@sounos.org])
FULL-PACKAGE-NAME
为程序名称,VERSION为当前版本,
BUG-REPORT-ADDRESS为bug汇报地址
添加[color=red]AM_INIT_AUTOMAKE[/color]
添加[color=red]AC_CONFIG_FILES([Makefile])[/color]
#AC_INIT(FULL-PACKAGE-NAME,
AC_INIT(str,
0.0.1,
AM_INIT_AUTOMAKE
AC_CONFIG_FILES([Makefile])
4、执行aclocal
aclocal
/usr/share/aclocal/libfame.m4:
6:
warning:
underquoted
definition
AM_PATH_LIBFAME
run
info
'
(automake)Extending
aclocal'
see
5、制作Makefile.am
cat
Makefile.am
#Makefile.am
bin_PROGRAMS
=
str
str_SOURCES
include/str.h
src/str.c
str_CPPFLAGS
-I
include/
6、autoheader
autoheader
7、automake必须文件:
*
install-sh
missing
INSTALL
NEWS
README
AUTHORS
ChangeLog
COPYING
depcomp
其中
可以通过automake
-a选项自动生成,所以这里只需要建立如下文件
touch
NEWS
README
AUTHORS
8、执行automake
-a
installing
`./install-sh'
`./missing'
Makefile.am:
`./INSTALL'
`./COPYING'
`./compile'
`./depcomp'
9、autoconf
autoconf
aclocal.m4
config.h.in
Makefile.am
ChangeLog
COPYING
INSTALL
Makefile.in
autom4te.cache
compile
install-sh
missing
10、执行测试:
执行./configure
./configure
--prefix=/u
checking
BSD-compatible
install...
/usr/bin/install
-c
whether
build
environment
is
sane...
yes
gawk...
gawk
sets
$(MAKE)...
gcc...
gcc
C
default
output
name...
a.out
the
works...
we
are
cross
compiling...
no
suffix
executables...
object
files...
o
using
GNU
compiler...
gcc
accepts
-g...
option
accept
ANSI
C...
none
needed
style
used
make...
GNU
dependency
gcc3
configure:
creating
./config.status
config.status:
Makefile
config.h
config.h
unchanged
executing
depfiles
commands
执行
make
make
all-am
make[1]:
Entering
directory
`/data/devel/c/str'
if
-DHAVE_CONFIG_H
-I.
include/
-g
-O2
-MT
str-str.o
-MD
-MP
-MF
.deps/str-str.Tpo"
-c
-o
`test
-f
src/str.c'
||
echo
./'
`src/str.c;
\
then
mv
.deps/str-str.Po"
;
else
rm
1;
fi
str
str-str.o
Leaving
install
install
test
-z
/u/bin"
-p
--
str'
/u/bin/str'
Nothing
be
done
`install-data-am'
.
11、测试程序:
/u/bin/str
[ENTER]
abcksdhfklsdklfdjlkfd
----PRINT
STRING----
abcksdhfklsdklfdjlkfd"
结束语:
这只是一个小例子,如果要把这个用得很好需要不断的磨练。
。
呵呵,见笑了。
-----
添加测试包:
dist-gzip
{
!
-d
str-0.0.1
find
-type
d
-perm
-200
-exec
chmod
u+w
{}
&
-fr
str-0.0.1;
};
str-0.0.1
-777
a+rwx
\;
-444
-links
1
a+r
-400
/bin/sh
/data/devel/c/str/install-sh
-m
-R
tardir=str-0.0.1
/data/devel/c/str/missing
--run
tar
chof
-
$tardir"
|
GZIP=--best
gzip
>
str-0.0.1.tar.gz
添加一个支持子目录、静态库、自定义configure选项的包
支持子目录Makefile.am
选项
SUBDIR
#Automake
interface
SUBDIRS
支持静态库Makefile.am
EXTRA_DIST
用于添加除源码外的文件到dist包
interface
hello
hello_SOURCES
hello.c
lib/sbase.h
hello_CPPFLAGS
lib
hello_LDFLAGS
-static
lib/libsbase.a
configure.ac
AC_INIT(hello,
[SounOS@])
#AM
声明
AC_CONFIG_SRCDIR([src/hello.c])
AC_HEADER_STDC
AC_CHECK_HEADERS([stdint.h
stdlib.h
sys/socket.h])
AC_C_CONST
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
#用于自定义configure
选项,见acinclude.am
AC_CHECK_EXTRA_OPTIONS
AC_CONFIG_FILES([Makefile
src/Makefile])