67db1d08f8b8847659190a2ceade129c2d260a1d
[scilab.git] / scilab / Makefile.am
1 #
2 # Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 # Copyright (C) INRIA - 2006-2008 - Sylvestre Ledru
4 # Copyright (C) DIGITEO - 2009 - Sylvestre Ledru
5 #
6 # This file must be used under the terms of the CeCILL.
7 # This source file is licensed as described in the file COPYING, which
8 # you should have received as part of this distribution.  The terms
9 # are also available at
10 # http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11 #
12
13 ## Process this file with automake to produce Makefile.in (which will be changed by the ./configure)
14
15 AUTOMAKE_OPTIONS = 1.11 dist-zip dist-bzip2
16
17 SUBDIRS= libs \
18         modules \
19         contrib \
20         desktop
21
22 ACLOCAL_AMFLAGS = -I m4/
23
24 changelogs = CHANGES CHANGES_5.1.X CHANGES_5.2.X CHANGES_5.3.X CHANGES_5.4.X
25
26 bin_PROGRAMS            = scilab-bin scilab-cli-bin
27
28 bin_SCRIPTS                     = bin/scilab bin/scilab-adv-cli bin/scilab-cli
29
30 if IS_MACOSX
31 bin_SCRIPTS             += bin/checkmacosx.applescript
32 endif
33
34 scilab_bin_LDFLAGS          =
35 scilab_cli_bin_LDFLAGS  =
36
37 if IS_MACOSX
38 scilab_bin_LDFLAGS              += -framework Cocoa
39 endif
40
41 scilab_bin_CFLAGS               = -I$(top_srcdir)/modules/io/includes
42 # --no-undefined --relax
43
44 # Localization dep already exists because of the `exportLocaleToSystem' symbol
45 # (causing issues on some platform)
46 COMMON_LIBS = $(LTLIBINTL)
47
48 scilab_bin_SOURCES              = $(top_srcdir)/modules/console/src/c/others/mainscic.c
49
50 scilab_bin_LDADD                = $(COMMON_LIBS) $(top_builddir)/modules/libscilab.la $(FLIBS)
51
52 # Match scilab -nwni (ie command line without graphics)
53 scilab_cli_bin_SOURCES  = $(top_srcdir)/modules/console/src/c/others/mainscic.c
54
55 scilab_cli_bin_CFLAGS           = -DWITHOUT_GUI -I$(top_srcdir)/modules/io/includes
56 scilab_cli_bin_LDADD            = $(COMMON_LIBS) $(top_builddir)/modules/libscilab-cli.la $(FLIBS)
57
58
59 if NEED_JAVA
60 # Don't do it for scilab_cli_bin. We want to be able to call it without
61 # the java libs
62         scilab_bin_LDADD += $(JAVA_JNI_LIBS)
63 endif
64
65 if IS_SOLARIS
66 # The binary itself needs this dep
67         scilab_bin_LDADD += $(BLAS_LIBS)
68 endif
69
70 if ENABLE_STATIC
71 scilab_static_bin_LDFLAGS               = -static -static-libgcc --start-group
72 scilab_static_bin_CFLAGS =  -Wl,--start-group `$(CXX) -print-file-name=libstdc++.a`
73
74 #-static
75 bin_PROGRAMS                    += scilab-static-bin
76 scilab_static_bin_LDADD = $(top_builddir)/modules/libscilab.la
77
78 scilab_static_bin_SOURCES = $(scilab_bin_SOURCES)
79 endif
80
81 LANG_DOMAIN=scilab
82
83 TARGETS_ALL=macros
84
85 #  The user wants to compile the localization files
86 if GENERATE_LOCALIZATION_FILES
87 TARGETS_ALL+=localization
88 endif
89
90 if COMPILATION_TESTS
91 TARGETS_ALL+=check-java
92 endif
93
94 all-local: $(TARGETS_ALL)
95
96 rootdir=$(pkgdatadir)/etc/
97 root_DATA = $(top_srcdir)/etc/scilab.start \
98 $(top_srcdir)/etc/scilab.quit \
99 $(top_srcdir)/etc/toolboxes.xml \
100 $(top_builddir)/etc/jvm_options.xml \
101 $(top_builddir)/etc/modules.xml \
102 $(top_builddir)/etc/classpath.xml \
103 $(top_builddir)/etc/logging.properties \
104 $(top_builddir)/etc/librarypath.xml
105
106 infofilesdir=$(pkgdatadir)/
107 infofiles_DATA = $(top_srcdir)/CHANGES_2.X \
108 $(top_srcdir)/CHANGES_3.X \
109 $(top_srcdir)/CHANGES_4.X \
110 $(top_srcdir)/CHANGES_5.0.X \
111 $(top_srcdir)/CHANGES_5.1.X \
112 $(top_srcdir)/CHANGES_5.2.X \
113 $(top_srcdir)/CHANGES_5.3.X \
114 $(top_srcdir)/CHANGES_5.4.X \
115 $(top_srcdir)/ACKNOWLEDGEMENTS \
116 $(top_srcdir)/COPYING \
117 $(top_srcdir)/COPYING-BSD \
118 $(top_srcdir)/COPYING-FR \
119 $(top_srcdir)/README_Unix \
120 $(top_srcdir)/RELEASE_NOTES_5.0.X \
121 $(top_srcdir)/RELEASE_NOTES_5.1.X \
122 $(top_srcdir)/RELEASE_NOTES_5.2.X \
123 $(top_srcdir)/RELEASE_NOTES_5.3.X \
124 $(top_srcdir)/Readme_Visual.txt \
125 $(top_srcdir)/README_Windows.txt \
126 $(top_builddir)/Version.incl
127
128 valgrinddir=$(pkgdatadir)/tools/profiling
129 valgrind_DATA = $(top_srcdir)/tools/profiling/valgrind.supp
130
131 macros:$(top_builddir)/scilab-cli-bin $(top_builddir)/bin/scilab-cli
132         -@( cd $(top_builddir) ; \
133         echo "$(top_builddir)/bin/scilab-cli -ns -f modules/functions/scripts/buildmacros/buildmacros.sce" ; \
134         $(top_builddir)/bin/scilab-cli -ns -f modules/functions/scripts/buildmacros/buildmacros.sce) || exit 1
135
136
137 # Build the public Javadoc (javasci v2 and Java/Scilab types)
138 # This is not done in the module itself because its needs also the "types"
139 # module
140 javadoc:
141         $(JAVADOC) -noindex -nohelp -nonavbar -notree \
142         -d $(top_builddir)/modules/javasci/javadoc \
143         -sourcepath $(top_srcdir)/modules/javasci/src/java:$(top_srcdir)/modules/types/src/java::$(top_srcdir)/modules/localization/src/java \
144         org.scilab.modules.javasci org.scilab.modules.types
145
146 doc: javadoc $(top_builddir)/scilab-bin $(top_builddir)/bin/scilab-adv-cli
147 if BUILD_HELP
148         @if test -x $(top_builddir)/scilab-bin; then \
149                 cd $(top_builddir);\
150                 for l in $(ALL_LINGUAS_DOC); do \
151                         echo "-- Building documentation ($$l) --"; \
152                         COMMAND="try xmltojar([],[],'$$l');catch exit(-1);end;exit(0);"; \
153                         echo "LANG=C SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e \"$$COMMAND\"";\
154                         LANG=C SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 $(top_builddir)/bin/scilab-adv-cli -nb -l $$l -nouserstartup -e "$$COMMAND" || exit 1;\
155                 done; \
156         else \
157                 echo "Cannot find Scilab-adv-cli binary"; \
158         fi
159 else
160         @echo "Cannot buid help. Add --enable-build-help to the ./configure if you want to build it."
161 endif
162
163 doc-web:$(top_builddir)/scilab-bin $(top_builddir)/bin/scilab-adv-cli
164 if BUILD_HELP
165         @if test -x $(top_builddir)/scilab-bin; then \
166                 cd $(top_builddir);\
167                 for l in $(ALL_LINGUAS_DOC); do \
168                         echo "-- Building documentation ($$l) --"; \
169                         COMMAND="try xmltoweb([],[],'$$l');catch exit(-1);end;exit(0);";\
170                         echo "LANG=C SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 $(top_builddir)/bin/scilab-adv-cli -nb -nouserstartup -e \"$$COMMAND\"";\
171                         LANG=C SCI_DISABLE_TK=1 SCI_JAVA_ENABLE_HEADLESS=1 $(top_builddir)/bin/scilab-adv-cli -nb -l $$l -nouserstartup -e "$$COMMAND" || exit 1;\
172                         JAVADOC_TARGET=$(top_builddir)/modules/helptools/web/$$l/javasci; \
173                         if test ! -d $$JAVADOC_TARGET; then \
174                                 mkdir $$JAVADOC_TARGET; \
175                                 ln -s ../../../../javasci/javadoc/ $$JAVADOC_TARGET/; \
176                         fi; \
177                 done; \
178         else \
179                 echo "Cannot find Scilab-adv-cli binary"; \
180         fi
181 else
182         @echo "Cannot buid help. Add --enable-build-help to the ./configure if you want to build it."
183 endif
184
185 check-help:$(top_builddir)/scilab-cli-bin $(top_builddir)/bin/scilab-cli
186         @if test -x $(top_builddir)/scilab-cli-bin; then \
187                 for l in $(ALL_LINGUAS_DOC); do \
188                         echo "-- Checking documentation ($$l) --"; \
189                         COMMAND="try check_help();catch exit(-1);end;exit(0);";\
190                         echo "$(top_builddir)/bin/scilab-cli -nb -l $$l -e \"$$COMMAND\"";\
191                         $(top_builddir)/bin/scilab-cli -nb -l $$l -e "$$COMMAND" || exit 1;\
192                 done; \
193         else \
194                 echo "Cannot find Scilab binary"; \
195         fi
196
197 check-recursive: check-local
198 check-local:
199         @if test -x $(top_builddir)/scilab-bin; then \
200                 COMMAND="try test_run();catch exit(-1);end;exit(0)";\
201                 export LANG=C;\
202                 $(top_builddir)/bin/scilab-adv-cli -nb -e "$$COMMAND"; \
203         else \
204                 echo "Cannot find Scilab binary"; \
205         fi
206
207 code-coverage:
208 if CODE_COVERAGE
209         @if test ! -d $(top_builddir)/coverage/; then \
210                 mkdir $(top_builddir)/coverage/; \
211         fi; \
212         touch $(top_srcdir)/modules/differential_equations/callinter.h $(top_srcdir)/modules/linear_algebra/callinter.h $(top_srcdir)/modules/scicos/callinter.h $(top_srcdir)/modules/scicos_blocks/callinter.h; \
213         $(LCOV) --directory $(top_builddir) --capture --ignore-errors source --output-file $(top_builddir)/coverage/scilab-code-coverage.info; \
214         $(GENHTML) -o $(top_builddir)/coverage/results/ --show-details --highlight --legend $(top_builddir)/coverage/scilab-code-coverage.info; \
215         echo "To open the result: firefox  $(top_builddir)/coverage/results/index.html"; \
216         rm -f $(top_srcdir)/modules/differential_equations/callinter.h $(top_srcdir)/modules/linear_algebra/callinter.h $(top_srcdir)/modules/scicos/callinter.h $(top_srcdir)/modules/scicos_blocks/callinter.h
217 #--frames is disable because of : http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=607206
218 else
219         @echo "Cannot start the code coverage. Add --enable-code-coverage to the ./configure and 'make clean all'."
220 endif
221
222 distclean-recursive: distclean-generated clean-recursive
223
224 clean-recursive: clean-help clean-localization clean-macros clean-generated
225
226 clean-macros:
227 # Find is necessary because of subdirs...
228         -@echo "-- Cleaning macros (*.bin) --"; \
229         find $(top_builddir) -name "*.bin" | xargs --no-run-if-empty rm 2> /dev/null; \
230         echo "-- Cleaning names files (names) --"; \
231         find $(top_builddir)/modules/*/macros -name "names" | xargs --no-run-if-empty rm 2> /dev/null; \
232         echo "-- Cleaning lib files (lib) --"; \
233         find $(top_builddir)/modules/*/macros -name "lib" | xargs --no-run-if-empty rm 2> /dev/null
234
235 # To ensure previous compatibility
236 clean-doc: clean-help
237
238 clean-help:
239         -@if test -x $(top_builddir)/scilab-cli-bin; then \
240                 COMMAND="try clean_help();catch exit(-1);end;exit(0)"; \
241                 for l in $(ALL_LINGUAS_DOC); do \
242                         echo "$(top_builddir)/bin/scilab-cli -nb -l $$l -e '$$COMMAND'"; \
243                         $(top_builddir)/bin/scilab-cli -nb -l $$l -e "$$COMMAND" || exit 1; \
244                 done; \
245         else \
246                 echo "Cannot find Scilab binary"; \
247         fi; \
248         echo "rmdir $(top_builddir)/modules/helptools/javaHelp/"; \
249         rm -rf $(top_builddir)/modules/helptools/javaHelp/; \
250         echo "rm -rf $(top_builddir)/modules/scicos/help/*/scilab_*_help"; \
251         rm -rf $(top_builddir)/modules/scicos/help/*/scilab_*_help; \
252         echo "rm -f $(top_builddir)/modules/scicos/help/en_US/master_help.xml"; \
253         rm -f $(top_builddir)/modules/scicos/help/en_US/master_help.xml; \
254         echo "rm -f $(top_builddir)/modules/scicos/jar/"; \
255         rm -rf $(top_builddir)/modules/scicos/jar/; \
256         echo "rm -rf $(top_builddir)/modules/javasci/javadoc"; \
257         rm -rf $(top_builddir)/modules/javasci/javadoc;
258
259 clean-tests:
260         @if test -x $(top_builddir)/scilab-cli-bin; then \
261                 $(top_builddir)/bin/scilab-cli -nb -l fr -e 'try test_clean();catch exit(-1);end;exit(0);' || exit 1; \
262         else \
263                 echo "Cannot find Scilab binary"; \
264         fi
265
266 clean-localization:
267         rm -rf $(top_srcdir)/locale/
268
269 clean-generated:
270         rm -rf $(top_builddir)/modules/scicos_blocks/build/ 2> /dev/null
271
272 distclean-generated:
273         rm -f $(top_builddir)/modules/core/includes/stack.h 2> /dev/null
274
275
276 if IS_MACOSX
277 # Used for mac os x because it needs to remove the charset=UTF-8 because it is breaking the accents.
278 MACOSX=1
279 endif
280
281 # For each module, build and call Java unitary tests
282 # If fails, stops the call
283 check-java:
284         @echo "-- Launch all TestNG (Java) unitary tests"; \
285         MASK="$(top_srcdir)/modules/*/tests/java/"; \
286         MODULES=`ls -d $$MASK`; \
287         for M in $$MODULES; do \
288                 BASE=`echo $$M|sed -e "s|tests/java/$$||g"`; \
289                 $(ANT) -buildfile $$BASE/build.xml test || exit $$?; \
290         done
291
292 # The user wants to compile the localization files
293 # Please note that ALL_LINGUAS is defined in configure.ac
294 if GENERATE_LOCALIZATION_FILES
295 localization:
296         @echo "-- Build localization (.mo from .po) --"; \
297         MASK="modules/*/locales/"; \
298         LC="LC_MESSAGES"; \
299         MSGFMT_OPTS="$MSGFMT_OPTS --check"; \
300         EXTENSION="*.po"; \
301         rm modules/*/locales/*~ 2> /dev/null; \
302         for LOCALE in $(ALL_LINGUAS); do \
303                 echo "        -- Building for $$LOCALE --"; \
304                 FILES=`ls $$MASK/$$LOCALE$$EXTENSION`; \
305                 PATHTO=$(top_builddir)/locale/$$LOCALE/$$LC/; \
306                 if test ! -d $$PATHTO; then \
307                         echo "        Creating $$PATHTO"; \
308                         mkdir -p $$PATHTO; \
309                 fi; \
310                 POFILE=$$PATHTO/$(LANG_DOMAIN).po; \
311                 $(MSGCAT) --use-first -o $$POFILE $$FILES; \
312                 if test "$(MACOSX)" = "1"; then sed -i -e '/charset=UTF-8/d' $$POFILE; fi; \
313                 $(MSGFMT) $(MSGFMT_OPTS) --statistics -o $$PATHTO/$(LANG_DOMAIN).mo $$POFILE; \
314         done;
315
316
317 localization-status:
318         @for LOCALE in $(ALL_LINGUAS_DOC); do \
319                 if test "$$LOCALE" != "en_US"; then \
320                         PATHTO=$(top_builddir)/locale-status/$$LOCALE/; \
321                         if test ! -d $$PATHTO; then \
322                                 echo "        Creating $$PATHTO"; \
323                                 mkdir -p $$PATHTO; \
324                         fi; \
325                         echo "Building status for $$LOCALE"; \
326                         echo "SCI=$(top_srcdir) php tools/localization/revcheck.php $$LOCALE > $$PATHTO/index.html"; \
327                         SCI=$(top_srcdir) php tools/localization/revcheck.php $$LOCALE > $$PATHTO/index.html; \
328                 fi; \
329         done;
330
331 endif
332
333 # Misc variable for the documentation installation
334
335 # How help files look like.
336 DOCMASK=scilab_*_help.jar
337
338 # Path to builded files
339 PATHTOHELPFILES = modules/helptools/jar/
340
341 # Path javasci to builded files
342 PATHTOJAVASCIDOC = modules/javasci/javadoc/
343 JAVASCI_DIRS = . resources \
344         org/scilab/modules/javasci/ \
345         org/scilab/modules/types/
346
347 if GENERATE_LOCALIZATION_FILES
348 install-data-local:
349         @$(mkinstalldirs) $(DESTDIR)$(localedir); \
350         echo $(mkinstalldirs) $(DESTDIR)$(localedir); \
351         for lang in $(ALL_LINGUAS); do \
352                 LANG_PATH_DIST=$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/; \
353                 echo $(mkinstalldirs) $$LANG_PATH_DIST; \
354                 $(mkinstalldirs) $$LANG_PATH_DIST; \
355                 echo $(INSTALL_DATA) $(top_builddir)/locale/$$lang/LC_MESSAGES/$(LANG_DOMAIN).mo $$LANG_PATH_DIST/; \
356                 $(INSTALL_DATA) $(top_builddir)/locale/$$lang/LC_MESSAGES/$(LANG_DOMAIN).mo $$LANG_PATH_DIST/; \
357         done
358 endif
359
360 ################ INSTALL DOCUMENTATION #################
361 # Starting from Scilab 5, documentation file are provided by Docbook
362 # In the Scilab application we are generating a JavaHelp file.
363 if BUILD_HELP
364         @$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/$(PATHTOHELPFILES); \
365         echo $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/$(PATHTOHELPFILES); \
366         if ls -lLd $(top_builddir)/$(PATHTOHELPFILES)/$(DOCMASK) >/dev/null 2>&1; then \
367                 for file in $(top_builddir)/$(PATHTOHELPFILES)/$(DOCMASK); do \
368                     echo "$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/$(PATHTOHELPFILES)" ; \
369                 $(INSTALL_DATA) "$$file" $(DESTDIR)$(pkgdatadir)/$(PATHTOHELPFILES) ; \
370                 done; \
371         fi
372 ## Install Javasci documentation (javadoc)
373 ## See target javadoc in this file to see how it is build
374         @if test -d $(PATHTOJAVASCIDOC); then \
375         $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/$(PATHTOJAVASCIDOC); \
376         echo $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/$(PATHTOJAVASCIDOC); \
377         for dir in $(JAVASCI_DIRS) ; do \
378                 $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/$(PATHTOJAVASCIDOC)/$$dir; \
379                 echo $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/$(PATHTOJAVASCIDOC)/$$dir; \
380                         for file in $(top_builddir)/$(PATHTOJAVASCIDOC)/$(dir)/*; do \
381                             echo "$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/$(PATHTOJAVASCIDOC)/$$dir" ; \
382                                 $(INSTALL_DATA) "$$file" $(DESTDIR)$(pkgdatadir)/$(PATHTOJAVASCIDOC)/$$dir ; \
383                         done; \
384         done; \
385         fi
386 endif
387
388 # Pkgconfig directory
389 pkgconfigdir = $(libdir)/pkgconfig
390
391 # Files to install in Pkgconfig directory
392 pkgconfig_DATA = scilab.pc
393
394 .PHONY: macros localization doc
395
396 .NOTPARALLEL: macros doc
397
398 include $(top_srcdir)/Makefile.call_scilab.am