上一篇《Navit學習筆記(四)》主要講述了Navit的目錄結構,並對根目錄下的configure.in、Makefile.am、Makefile.inc三個主要的工程文件做了簡要的分析和說明。這在一片中我們繼續解析和說明Navit的工程文件。在Navit工程的源代碼目錄(navit/navit)中有Makefile.am文件.文件的首行包含了根目錄下的Makefile.inc文件
接着聲明包含的子目錄fib-1.1 和 support,再做了一個判斷,如果支持插件PLUGINS,PLUGINS宏定義在根目錄下在configure.in文件的335行中,則包含所有的子目錄。
SUBDIRS += .
endif
DIST_SUBDIRS=autoload binding map maptool fib-1.1 font fonts gui graphics osd plugin speech support vehicle xpm maps
SUBDIRS+=autoload binding map font gui graphics osd plugin speech vehicle xpm
接下來定義了變量“MODULES”,用於包含用於Navit用到的模塊。其中,wildcard函數表示列出當前目錄下所有符合“定義(PATTERN)”的文件。
根據configure.in對插件模塊的定義,添加工程的子目錄。FONTS、PLUGINGS、BUILD_SAMPLEMAP 都是自定的宏。
2 SUBDIRS += fonts
3 endif
4 if !PLUGINS
5 SUBDIRS += .
6 endif 7
8 if MAPTOOL
9 SUBDIRS += maptool
10 endif11
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發行包中。
BUILT_SOURCES = version.h navit_config.h
if BIN_NAVIT
bin_PROGRAMS = navit
endif
if SHARED_LIBNAVIT
lib_LTLIBRARIES = lib@[email protected]
lib@LIBNAVIT@_la_LDFLAGS = -avoid-version @MODULE_LDFLAGS@ -no-undefined -Wl,--no-undefined
else
noinst_LTLIBRARIES = lib@[email protected]
endif
lib@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_libc
endif
pkgdata_DATA = navit.xml
EXTRA_DIST = navit_shipped.xml navit.dtd
在定義好所包含的庫類、插件和模塊後,用自定義變量包含主程序所需要的源代碼。
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文件。
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系統瞭解甚少,所以這裏就直接跳過。
2 //以下是省略的代碼
3 ....
4 else
5 navit_SOURCES = start.c
6 navit_LDADD = lib@[email protected]
7 endif
接下來又是根據configure.in文件中一些配置對一些自定義變量進行設置。
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