Fix:Build:Allow build in external tree
[navit-package] / navit / Makefile.am
1 include $(top_srcdir)/Makefile.inc
2 DIST_SUBDIRS=binding map fib-1.1 font fonts gui graphics osd speech support vehicle xpm maps
3 SUBDIRS=binding map fib-1.1 font gui graphics osd speech support vehicle xpm
4 if BUILD_SAMPLEMAP
5   SUBDIRS += maps
6 endif
7
8 if FONTS
9   SUBDIRS += fonts
10 endif
11
12 AM_CPPFLAGS = -I$(top_srcdir)/navit/fib-1.1 @NAVIT_CFLAGS@ @ZLIB_CFLAGS@ -DPREFIX=\"@prefix@\" -DLIBDIR=\"@libdir@\" -DMODULE=navit
13 BUILT_SOURCES = version.h navit_config.h
14 if BUILD_SAMPLEMAP
15   BUILT_SOURCES += osm2navit$(EXEEXT)
16 endif
17
18 if SUPPORT_ANDROID
19   lib_LTLIBRARIES        = libnavit.la
20   libnavit_la_LDFLAGS = -module -avoid-version @MODULE_LDFLAGS@ -Wl,--no-undefined
21   libnavit_la_LIBADD = @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib -llog
22
23 else
24   bin_PROGRAMS = navit osm2navit
25   noinst_LTLIBRARIES        = libnavit.la
26 endif
27
28 pkgdata_DATA = navit.xml
29
30 EXTRA_DIST = navit_shipped.xml 
31
32 libnavit_la_SOURCES = announcement.c atom.c attr.c cache.c callback.c command.c compass.c coord.c country.c cursor.c data_window.c debug.c \
33         event.c event_glib.h file.c graphics.c gui.c item.c layout.c log.c main.c map.c \
34         linguistics.c mapset.c maptype.c menu.c messages.c navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c \
35         profile.c projection.c roadprofile.c route.c search.c speech.c start_real.c transform.c track.c \
36         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 coord.h country.h \
37         cursor.h data.h data_window.h data_window_int.h debug.h destination.h draw_info.h endianess.h event.h \
38         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\
39         map_data.h mapset.h maptype.h menu.h messages.h navigation.h navit.h osd.h \
40         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 \
41         transform.h track.h util.h vehicle.h vehicleprofile.h window.h xmlconfig.h zipfile.h \
42         navit_nls.h
43
44 comma=,
45 navit.xml: navit_shipped.xml  $(foreach xslt, $(subst $(comma), ,@XSLTS@), $(addsuffix .xslt,$(addprefix xslt/,$(xslt))))
46         cp $< navit.xml.tmp
47         cp $< navit.xml.new
48         if [ "$(builddir)" != "$(srcdir)" ]; then cp $(srcdir)/navit.dtd $(builddir)/navit.dtd; fi
49         for i in $^; do if [ "$${i%.xslt}" != "$$i" ]; then saxon -snone navit.xml.tmp $$i >navit.xml.new || exit ; fi ; done
50         mv navit.xml.new navit.xml
51         
52
53 if SUPPORT_ANDROID
54   libnavit_la_SOURCES += android.c
55   navit_SOURCES =
56   navit_LDADD =
57   osm2navit_SOURCES =
58   osm2navit_LDADD =
59
60 android/build.xml: android/AndroidManifest.xml
61         if [ "$(builddir)" != "$(srcdir)" ]; then cp -rp $(srcdir)/android $(builddir)/android; fi
62         android update project -t 3 -p android
63
64 apk: all android/build.xml navit.xml
65         mkdir -p android/libs/armeabi
66         cp .libs/*.so */*/.libs/*.so android/libs/armeabi
67         for i in $(shell cd $(srcdir)/xpm && echo *.xpm); do convert $(srcdir)/xpm/$$i android/res/drawable/$${i%.xpm}.png; done 
68         for i in $(shell cd $(srcdir)/xpm && echo *.png); do cp $(srcdir)/xpm/$$i android/res/drawable/$$( echo $$i | tr "[A-Z]" "[a-z]") ; done
69         if [ "$(builddir)" != "$(srcdir)" ]; then for i in $(shell cd $(builddir)/xpm && echo *.png); do cp $(builddir)/xpm/$$i android/res/drawable/$$( echo $$i | tr "[A-Z]" "[a-z]") ; done ; fi
70         mkdir -p android/res/raw
71         for i in $(shell cd ../po && echo *.mo); do cp ../po/$$i android/res/raw/$$( echo $$i | tr "[A-Z]" "[a-z]") ; done
72         cp navit.xml android/res/raw
73         cd android && ant debug
74
75 else
76 navit_SOURCES = start.c
77 navit_LDADD = libnavit.la @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib
78
79 osm2navit_CPPFLAGS = $(AM_CPPFLAGS) @ZLIB_CFLAGS@ @POSTGRESQL_CFLAGS@
80 osm2navit_SOURCES = osm2navit.c
81 osm2navit_LDADD = libnavit.la @NAVIT_LIBS@ @ZLIB_LIBS@ @POSTGRESQL_LIBS@ @INTLLIBS@
82 endif
83
84 if EVENT_GLIB
85   libnavit_la_SOURCES += event_glib.c
86 endif
87
88 if !PLUGINS
89   navit_SOURCES += builtin.c
90   navit_LDADD += $(wildcard $(top_builddir)/navit/*/*/*.la)
91   osm2navit_SOURCES += support-builtin.c
92   osm2navit_LDADD += $(wildcard $(top_builddir)/navit/support/*/*.la)
93 endif
94
95 if SUPPORT_WIN32
96   navit_LDADD += resource.rsc
97 if SUPPORT_WIN32CE
98   navit_LDADD += -lcommctrl
99 else
100   navit_LDADD += -lgdi32 -lcomctl32
101 endif
102
103 resource.rsc: $(top_srcdir)/navit/gui/win32/resources/resource.rc
104         $(WINDRES) -I $(top_srcdir)/navit/gui/win32/resources $(top_srcdir)/navit/gui/win32/resources/resource.rc resource.rsc
105 endif
106
107 .PHONY: version.h.tmp
108
109 version.h.tmp:
110         echo "#include \"config.h\"" >version.h.tmp
111 if SOURCE_MODE_SVN
112         echo "#define SVN_VERSION \"$$(LANG=C svnversion 2>/dev/null)\"" >>version.h.tmp
113 else
114         echo "#define SVN_VERSION \"@SOURCE_MODE@\"" >>version.h.tmp
115 endif
116         echo "#define NAVIT_VARIANT \"@NAVIT_VARIANT@\"" >>version.h.tmp
117         if ! diff version.h.tmp version.h >/dev/null 2>/dev/null; \
118         then \
119                 mv version.h.tmp version.h; \
120         fi
121
122 version.h: version.h.tmp
123
124 navit_config.h: ../config.h
125         cp ../config.h navit_config.h.tmp
126         if ! diff navit_config.h.tmp navit_config.h >/dev/null 2>/dev/null; \
127         then \
128                 mv navit_config.h.tmp navit_config.h; \
129         fi
130
131
132 distclean-local:
133         rm -f version.h version.h.tmp navit_config.h navit_config.h.tmp builtin.c support-builtin.c
134
135 builtin.c: $(top_builddir)/config.h
136         ls $(top_builddir)/navit/*/*/*.la | sed -e "s/.la/_init(void);/" -e "s/.*lib/extern void module_/" >builtin.c
137         echo "extern void builtin_init(void);" >>builtin.c
138         echo "void builtin_init(void) {" >>builtin.c
139         ls $(top_builddir)/navit/*/*/*.la | sed -e "s/.la/_init();/" -e "s/.*\\/lib/    module_/" >>builtin.c
140         echo "}" >>builtin.c
141 support-builtin.c: $(top_builddir)/config.h
142         ls $(top_builddir)/navit/support/*/*.la | sed -e "s/.la/_init(void);/" -e "s/.*lib/extern void module_/" >support-builtin.c
143         echo "extern void builtin_init(void);" >>support-builtin.c
144         echo "void builtin_init(void) {" >>support-builtin.c
145         ls $(top_builddir)/navit/support/*/*.la | sed -e "s/.la/_init();/" -e "s/.*\\/lib/      module_/" >>support-builtin.c
146         echo "}" >>support-builtin.c