autotools精简二(生成libxml2静态库)
2013-08-27 17:39
471 查看
下面是探讨精简的过程(若不精简,因为AC_PROG_LIBTOOL 会自动生成`--enable-shared'`--enable-static',也可生成静态库)
一、Makefile.am制作过程
1)从原始am文件提取要生成的目标和依赖关系,生成新的Makefile.am
使用awk进行提取:awk ' {if((NR >= 18&& NR <=43)||(NR>=1137&&NR<=1140)||(NR==7))print $0}' Makefile.am.ori > Makefile.am
生成的Makefile.am源码
cat Makefile.am
INCLUDES = -I$(top_builddir)/include -I@srcdir@/include @THREAD_CFLAGS@ @Z_CFLAGS@
lib_LTLIBRARIES = libxml2.la
libxml2_la_LIBADD = @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) @M_LIBS@ @WIN32_EXTRA_LIBADD@
libxml2_la_LDFLAGS = @CYGWIN_EXTRA_LDFLAGS@ @WIN32_EXTRA_LDFLAGS@ -version-info @LIBXML_VERSION_INFO@ @MODULE_PLATFORM_LIBS@
if WITH_TRIO_SOURCES
libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c \
valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c \
xpointer.c xinclude.c nanohttp.c nanoftp.c DOCBparser.c \
catalog.c globals.c threads.c c14n.c xmlstring.c \
xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
triostr.c trio.c xmlreader.c relaxng.c dict.c SAX2.c \
xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c \
xmlmodule.c schematron.c
else
libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c \
valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c \
xpointer.c xinclude.c nanohttp.c nanoftp.c DOCBparser.c \
catalog.c globals.c threads.c c14n.c xmlstring.c \
xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
xmlreader.c relaxng.c dict.c SAX2.c \
xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c \
xmlmodule.c schematron.c
endif
cleanup:
-@(find . -name .\#\* -exec rm {} \;)
-@(find . -name \*.gcda -o *.gcno -exec rm {} \;)
-@(find . -name \*.orig -o -name \*.rej -o -name \*.old -exec rm {} \;)
2)修改Makefile.am依赖关系,使之生成静态库,修改后的Makefile.am源码
cat Makefile.am
INCLUDES = -I$(top_builddir)/include -I@srcdir@/include @THREAD_CFLAGS@ @Z_CFLAGS@
lib_LIBRARIES = libxml2.a
#libxml2_a_LIBADD = @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) @M_LIBS@ @WIN32_EXTRA_LIBADD@
#libxml2_a_LDFLAGS = @CYGWIN_EXTRA_LDFLAGS@ @WIN32_EXTRA_LDFLAGS@ -version-info @LIBXML_VERSION_INFO@ @MODULE_PLATFORM_LIBS@
if WITH_TRIO_SOURCES
libxml2_a_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c \
valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c \
xpointer.c xinclude.c nanohttp.c nanoftp.c DOCBparser.c \
catalog.c globals.c threads.c c14n.c xmlstring.c \
xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
triostr.c trio.c xmlreader.c relaxng.c dict.c SAX2.c \
xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c \
xmlmodule.c schematron.c
else
libxml2_a_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c \
valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c \
xpointer.c xinclude.c nanohttp.c nanoftp.c DOCBparser.c \
catalog.c globals.c threads.c c14n.c xmlstring.c \
xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
xmlreader.c relaxng.c dict.c SAX2.c \
xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c \
xmlmodule.c schematron.c
endif
cleanup:
-@(find . -name .\#\* -exec rm {} \;)
-@(find . -name \*.gcda -o *.gcno -exec rm {} \;)
-@(find . -name \*.orig -o -name \*.rej -o -name \*.old -exec rm {} \;)
二、修改configure.in+autogen.sh
1)去掉libtool的相关支持
autogen.sh中注释如下代码 #libtoolize --copy --force
configure.in中注释如下代码
#AC_LIBTOOL_WIN32_DLL
#AM_PROG_LIBTOOL
2)去掉不需要生成的makefile及其他文件声明(configure.in),下面是diff的输出
-AC_OUTPUT(libxml2.spec:libxml.spec.in Makefile include/Makefile include/libxml/Makefile doc/Makefile doc/examples/Makefile doc/devhelp/Makefile example/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h
xml2-config libxml-2.0.pc libxml-2.0-uninstalled.pc python/setup.py)
+AC_OUTPUT(libxml2.spec:libxml.spec.in Makefile )
3) 添加AC_PROG_RANLIB(configure.in)
三、编译过程
1)设置环境变量
export ARCH=sh4
export CC=sh4-linux-gcc
export CXX=sh4-linux-g++
export RANLIB=sh4-linux-ranlib
export BUILD_ROOT=/opt/STM/STLinux-2.3/devkit/sh4/target
2)执行./autogen.sh --host=sh4-linux
生成makefile
3)make
make
make all-am
make[1]: Entering directory `/home/WebKit-r103151-avit/app/WebKit-r103151-avit/Source/ThirdParty
4000
/lib_src/LIBXML2.7.2'
rm -f libxml2.a
ar cru libxml2.a SAX.o entities.o encoding.o error.o parserInternals.o parser.o tree.o hash.o list.o xmlIO.o xmlmemory.o uri.o valid.o xlink.o HTMLparser.o HTMLtree.o debugXML.o xpath.o xpointer.o xinclude.o nanohttp.o nanoftp.o
DOCBparser.o catalog.o globals.o threads.o c14n.o xmlstring.o xmlregexp.o xmlschemas.o xmlschemastypes.o xmlunicode.o xmlreader.o relaxng.o dict.o SAX2.o xmlwriter.o legacy.o chvalid.o pattern.o xmlsave.o xmlmodule.o schematron.o
sh4-linux-ranlib libxml2.a
make[1]: Leaving directory `/home/WebKit-r103151-avit/app/WebKit-r103151-avit/Source/ThirdParty/lib_src/LIBXML2.7.2'
一、Makefile.am制作过程
1)从原始am文件提取要生成的目标和依赖关系,生成新的Makefile.am
使用awk进行提取:awk ' {if((NR >= 18&& NR <=43)||(NR>=1137&&NR<=1140)||(NR==7))print $0}' Makefile.am.ori > Makefile.am
生成的Makefile.am源码
cat Makefile.am
INCLUDES = -I$(top_builddir)/include -I@srcdir@/include @THREAD_CFLAGS@ @Z_CFLAGS@
lib_LTLIBRARIES = libxml2.la
libxml2_la_LIBADD = @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) @M_LIBS@ @WIN32_EXTRA_LIBADD@
libxml2_la_LDFLAGS = @CYGWIN_EXTRA_LDFLAGS@ @WIN32_EXTRA_LDFLAGS@ -version-info @LIBXML_VERSION_INFO@ @MODULE_PLATFORM_LIBS@
if WITH_TRIO_SOURCES
libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c \
valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c \
xpointer.c xinclude.c nanohttp.c nanoftp.c DOCBparser.c \
catalog.c globals.c threads.c c14n.c xmlstring.c \
xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
triostr.c trio.c xmlreader.c relaxng.c dict.c SAX2.c \
xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c \
xmlmodule.c schematron.c
else
libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c \
valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c \
xpointer.c xinclude.c nanohttp.c nanoftp.c DOCBparser.c \
catalog.c globals.c threads.c c14n.c xmlstring.c \
xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
xmlreader.c relaxng.c dict.c SAX2.c \
xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c \
xmlmodule.c schematron.c
endif
cleanup:
-@(find . -name .\#\* -exec rm {} \;)
-@(find . -name \*.gcda -o *.gcno -exec rm {} \;)
-@(find . -name \*.orig -o -name \*.rej -o -name \*.old -exec rm {} \;)
2)修改Makefile.am依赖关系,使之生成静态库,修改后的Makefile.am源码
cat Makefile.am
INCLUDES = -I$(top_builddir)/include -I@srcdir@/include @THREAD_CFLAGS@ @Z_CFLAGS@
lib_LIBRARIES = libxml2.a
#libxml2_a_LIBADD = @THREAD_LIBS@ @Z_LIBS@ $(ICONV_LIBS) @M_LIBS@ @WIN32_EXTRA_LIBADD@
#libxml2_a_LDFLAGS = @CYGWIN_EXTRA_LDFLAGS@ @WIN32_EXTRA_LDFLAGS@ -version-info @LIBXML_VERSION_INFO@ @MODULE_PLATFORM_LIBS@
if WITH_TRIO_SOURCES
libxml2_a_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c \
valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c \
xpointer.c xinclude.c nanohttp.c nanoftp.c DOCBparser.c \
catalog.c globals.c threads.c c14n.c xmlstring.c \
xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
triostr.c trio.c xmlreader.c relaxng.c dict.c SAX2.c \
xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c \
xmlmodule.c schematron.c
else
libxml2_a_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
parser.c tree.c hash.c list.c xmlIO.c xmlmemory.c uri.c \
valid.c xlink.c HTMLparser.c HTMLtree.c debugXML.c xpath.c \
xpointer.c xinclude.c nanohttp.c nanoftp.c DOCBparser.c \
catalog.c globals.c threads.c c14n.c xmlstring.c \
xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
xmlreader.c relaxng.c dict.c SAX2.c \
xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c \
xmlmodule.c schematron.c
endif
cleanup:
-@(find . -name .\#\* -exec rm {} \;)
-@(find . -name \*.gcda -o *.gcno -exec rm {} \;)
-@(find . -name \*.orig -o -name \*.rej -o -name \*.old -exec rm {} \;)
二、修改configure.in+autogen.sh
1)去掉libtool的相关支持
autogen.sh中注释如下代码 #libtoolize --copy --force
configure.in中注释如下代码
#AC_LIBTOOL_WIN32_DLL
#AM_PROG_LIBTOOL
2)去掉不需要生成的makefile及其他文件声明(configure.in),下面是diff的输出
-AC_OUTPUT(libxml2.spec:libxml.spec.in Makefile include/Makefile include/libxml/Makefile doc/Makefile doc/examples/Makefile doc/devhelp/Makefile example/Makefile python/Makefile python/tests/Makefile xstc/Makefile include/libxml/xmlversion.h
xml2-config libxml-2.0.pc libxml-2.0-uninstalled.pc python/setup.py)
+AC_OUTPUT(libxml2.spec:libxml.spec.in Makefile )
3) 添加AC_PROG_RANLIB(configure.in)
三、编译过程
1)设置环境变量
export ARCH=sh4
export CC=sh4-linux-gcc
export CXX=sh4-linux-g++
export RANLIB=sh4-linux-ranlib
export BUILD_ROOT=/opt/STM/STLinux-2.3/devkit/sh4/target
2)执行./autogen.sh --host=sh4-linux
生成makefile
3)make
make
make all-am
make[1]: Entering directory `/home/WebKit-r103151-avit/app/WebKit-r103151-avit/Source/ThirdParty
4000
/lib_src/LIBXML2.7.2'
rm -f libxml2.a
ar cru libxml2.a SAX.o entities.o encoding.o error.o parserInternals.o parser.o tree.o hash.o list.o xmlIO.o xmlmemory.o uri.o valid.o xlink.o HTMLparser.o HTMLtree.o debugXML.o xpath.o xpointer.o xinclude.o nanohttp.o nanoftp.o
DOCBparser.o catalog.o globals.o threads.o c14n.o xmlstring.o xmlregexp.o xmlschemas.o xmlschemastypes.o xmlunicode.o xmlreader.o relaxng.o dict.o SAX2.o xmlwriter.o legacy.o chvalid.o pattern.o xmlsave.o xmlmodule.o schematron.o
sh4-linux-ranlib libxml2.a
make[1]: Leaving directory `/home/WebKit-r103151-avit/app/WebKit-r103151-avit/Source/ThirdParty/lib_src/LIBXML2.7.2'
相关文章推荐
- autotools生成makefile文件实例
- 借助 GNU autotools 生成 makefile 的简易流程
- linux autotools libtool 生成库版本号设置方法
- makefile学习 (2) —— autotools生成makefile
- autotools实现makefile的自动生成
- Tips: 使用autotools生成动态.so库文件 / Generate .so library files using autotools in Solaris and Linux
- autotools生成Makefile(二)
- Makefile文件生成 GNU Autotools的使用方法
- autotools生成makefile文件实例
- 一个简单的执行程序的GNU automake自动生成Makefile的方法及案例
- 自动生成 Makefile 的全过程详解! automake/autoconf 入门
- GNU Autotools的使用方法
- 使用 GNU autotools 改造一个软件项目
- [BuildRelease]Mozilla Build Tools - Autoconf + GNU Make
- Eclipse下使用JPA Tools生成DB Entity
- Ubuntu autotools的安装
- automake&autoconf生成makefile【转载】
- autotools工具使用
- [Tools]位图字体生成工具Bitmap Font Generator的使用
- Mac下安装MacProt,并GNU autotools的安装和使用 autoconf,automake