上一篇《Navit学习笔记(四)》主要讲述了Navit的目录结构,并对根目录下的configure.in、Makefile.am、Makefile.inc三个主要的工程文件做了简要的分析和说明。这在一片中我们继续解析和说明Navit的工程文件。在Navit工程的源代码目录(navit/navit)中有Makefile.am文件.文件的首行包含了根目录下的Makefile.inc文件
include $(top_srcdir) / Makefile.inc接着声明包含的子目录fib-1.1 和 support,再做了一个判断,如果支持插件PLUGINS,PLUGINS宏定义在根目录下在configure.in文件的335行中,则包含所有的子目录。
if PLUGINS SUBDIRS += .endifDIST_SUBDIRS=autoload binding map maptool fib-1.1 font fonts gui graphics osd plugin speech support vehicle xpm mapsSUBDIRS+=autoload binding map font gui graphics osd plugin speech vehicle xpm
接下来定义了变量“MODULES”,用于包含用于Navit用到的模块。其中,wildcard函数表示列出当前目录下所有符合“定义(PATTERN)”的文件。
MODULES = $(wildcard $(top_builddir) / navit / binding /*/* .la $(top_builddir) / navit / font /*/* .la $(top_builddir) / navit / graphics /*/* .la $(top_builddir) / navit / gui /*/* .la $(top_builddir) / navit / map /*/* .la $(top_builddir) / navit / osd /*/* .la $(top_builddir) / navit / speech /*/* .la $(top_builddir) / navit / vehicle /*/* .la)根据configure.in对插件模块的定义,添加工程的子目录。FONTS、PLUGINGS、BUILD_SAMPLEMAP 都是自定的宏。
1 if FONTS 2 SUBDIRS += fonts 3 endif 4 if ! PLUGINS 5 SUBDIRS += . 6 endif 7 8 if MAPTOOL 9 SUBDIRS += maptool 10 endif 11 12 if BUILD_SAMPLEMAP 13 SUBDIRS += maps 14 endif文件给出了AM_CPPFLAGS 变量用于给出预处理器的参数。$(top_srcdir)/navit/fib-1.1是指INCLUDE宏要搜寻的目录,NAVIT_CFLAGS、ZLIB_CFLAS 都在configure.in中定义。自定义了变量BUILT_SOURCES 用于存放要编译的源代码文件。同理bin_PROGRAMS、lib_LTLIBRARIES、pkgdata_DATA等都是自定义变量,用于存放一些用于编译的信息。而EXTRA_DIST则是用于将指定文件包含到make dist发行包中。
AM_CPPFLAGS = - I$(top_srcdir) / navit / fib - 1.1 @NAVIT_CFLAGS@ @ZLIB_CFLAGS@ - DPREFIX = / " @prefix@/ " - DLIBDIR = / " @libdir@/ " - DMODULE = navitBUILT_SOURCES = version.h navit_config.hif BIN_NAVIT bin_PROGRAMS = navitendifif SHARED_LIBNAVIT lib_LTLIBRARIES = lib@LIBNAVIT@.la lib@LIBNAVIT@_la_LDFLAGS = -avoid-version @MODULE_LDFLAGS@ -no-undefined -Wl,--no-undefinedelse noinst_LTLIBRARIES = lib@LIBNAVIT@.laendiflib@LIBNAVIT@_la_LIBADD = @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib @MODULE_LIBADD@ @CRYPTO_LIBS@if SUPPORT_WIN32CE lib@LIBNAVIT@_la_LIBADD += -Lsupport/libc -lsupport_libcendifpkgdata_DATA = navit.xmlEXTRA_DIST = navit_shipped.xml navit.dtd
在定义好所包含的库类、插件和模块后,用自定义变量包含主程序所需要的源代码。
ib@LIBNAVIT@_la_SOURCES = announcement.c atom.c attr.c cache.c callback.c command.c compass.c config_.c coord.c country.c data_window.c debug.c / event.c event_glib.h file.c graphics.c gui.c item.c layout.c log.c main.c map.c / linguistics.c mapset.c maptype.c menu.c messages.c bookmarks.c bookmarks.h navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c / profile.c projection.c roadprofile.c route.c routech.c search.c speech.c start_real.c transform.c track.c / util.c vehicle.c vehicleprofile.c xmlconfig.c announcement.h atom.h attr.h attr_def.h cache.h callback.h color.h command.h compass.h config_.h coord.h country.h / data.h data_window.h data_window_int.h debug.h destination.h draw_info.h endianess.h event.h / file.h graphics.h gtkext.h gui.h item.h item_def.h keys.h log.h layer.h layout.h linguistics.h main.h map - share.h map.h/ map_data.h mapset.h maptype.h menu.h messages.h navigation.h navit.h osd.h / param.h phrase.h plugin.h point.h plugin_def.h projection.h popup.h route.h profile.h roadprofile.h search.h speech.h start_real.h / transform.h track.h util.h vehicle.h vehicleprofile.h window.h xmlconfig.h zipfile.h / navit_nls.h sunriset.c sunriset.h glib_slice.h因为Navit系统使用了Navit.xml来定义系统的配置,所以在Makefile.am中包含了如下定义,根据navit_shipped.xml文件和navit.dtd文件生成系统运行所需的navit.xml文件。
1 XSLTS = @XSLTS@ 2 navit.xml: navit_shipped.xml $( foreach xslt, $(subst $(comma), ,$(XSLTS)), $(addsuffix .xslt,$(addprefix xslt / ,$(xslt)))) 3 cp $ < navit.xml. new 4 if [ ! - f navit.dtd ]; then cp - f $(top_srcdir) / navit / navit.dtd .; fi 5 for i in $ ^ ; do if [ " $${i%.xslt} " != " $$i " ]; then echo " Applying $$i " ; @SAXON@ - snone navit.xml. new $$i > navit.xml.tmp || exit ; mv navit.xml.tmp navit.xml. new || exit ; fi ; done 6 mv navit.xml. new navit.xml 7 rm - f navit.xml.tmp由于系统支持Android系统,所以接下来,Makefile定了在Android系统的编译设置,由于本人对Android系统了解甚少,所以这里就直接跳过。
1 if SUPPORT_ANDROID 2 // 以下是省略的代码 3 .... 4 else 5 navit_SOURCES = start.c 6 navit_LDADD = lib@LIBNAVIT@.la 7 endif接下来又是根据configure.in文件中一些配置对一些自定义变量进行设置。
1 if EVENT_GLIB 2 lib@LIBNAVIT@_la_SOURCES += event_glib.c 3 endif 4 5 if ! PLUGINS 6 lib@LIBNAVIT@_la_SOURCES += builtin.c 7 lib@LIBNAVIT@_la_LIBADD += $(MODULES) 8 endif 9 10 navit_LDFLAGS = - export - dynamic 11 12 navit_LDADD += @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @CRYPTO_LIBS@ @INTLLIBS@ 13 14 if SUPPORT_WIN32 15 navit_LDADD += resource.rsc 16 if SUPPORT_WIN32CE 17 navit_LDADD += - lcommctrl - Lsupport / libc 18 else 19 navit_LDADD += - lgdi32 - lcomctl32 - lwinmm 20 endif