summaryrefslogtreecommitdiff
path: root/Makefile.incl.am
blob: f7e7b4dfe214122376f027d80e5653ea82ff3c9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336

# Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
# Copyright (C) 2006-2008 - INRIA - Sylvestre LEDRU <sylvestre.ledru@inria.fr>
# Copyright (C) 2008      - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
#
# This file must be used under the terms of the CeCILL.
# This source file is licensed as described in the file COPYING, which
# you should have received as part of this distribution.  The terms
# are also available at
# http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
#

##########
### Makefile included stuff
### Target, variable, suffixes which are supposed to be useful in every makefile.am
##########

# Where all the Scilab stuff is installed (macros, help, ...)
mydatadir=$(pkgdatadir)/modules/$(modulename)

# Set AM_* SCI detected settings
AM_CPPFLAGS = $(SCI_CPPFLAGS)
AM_CFLAGS   = $(SCI_CFLAGS)
AM_CXXFLAGS = $(SCI_CXXFLAGS)
AM_FFLAGS   = $(SCI_FFLAGS)
AM_LDFLAGS  = $(SCI_LDFLAGS)

# Tag shared libraries with the Scilab version
AM_LDFLAGS += -version-number $(SCILAB_LIBRARY_VERSION)
# append includes to AM_FFLAGS to manage fortran includes
AM_FFLAGS  += -I$(top_srcdir)/modules/core/includes/

# This target enables tests for Scilab
check-local: $(top_builddir)/scilab-bin test
	if test -d $(mydatadir)/tests; then \
	  @COMMAND="try test_run('$(modulename)');catch exit(-1);end;exit(0)"; export LANG=C; $(top_builddir)/bin/scilab -nwni -nb -e "$$COMMAND"; \
	fi

# splint options
SPLINT_OPTIONS=-weak -booltype BOOL
check-code:
	if test -f build.xml; then \
		$(ANT) checkstyle; \
	fi
	if test -x "$(SPLINT)"; then \
		$(SPLINT) $(SPLINT_OPTIONS) -I$(top_srcdir)/modules/core/includes/ -I$(top_srcdir)/libs/MALLOC/includes/ -I$(top_srcdir)/modules/localization/includes/ $(INCLUDE_FLAGS) $(CHECK_SRC); \
	fi

########################### JAVA ######################################
#### We are delegating java compilation to ant... Thanks to that
#### the procedure will be the same with Microsoft Windows (C)
#### and Linux/Unix
#######################################################################

TARGETS_ALL=
if NEED_JAVA
TARGETS_ALL+=java
java:
# Some configurations needs to export JAVA_HOME in the current env
	@if test "$(JAVA_HOME)"; then export JAVA_HOME=$(JAVA_HOME); fi; \
	if test -z "$(USEANT)"; then USEANT=0; else USEANT=1; fi; \
	if test -f build.xml -a $$USEANT -eq 1; then \
		$(ANT); \
	fi

clean-java:
# Some configurations needs to export JAVA_HOME in the current env
	@if test "$(JAVA_HOME)"; then export JAVA_HOME=$(JAVA_HOME); fi; \
	if test -z "$(USEANT)"; then USEANT=0; else USEANT=1; fi; \
	if test -f build.xml -a $$USEANT -eq 1; then \
		$(ANT) clean; \
	fi;
endif

if SWIG

# If the user request for the SWIG generation of the wrappers Java => C/C++ 
# We call the target swig-build on the variable SWIG_WRAPPERS

## build Swig Java => C wrappers
swig: $(SWIG_WRAPPERS)
	@SWIG_PACKAGENAME=org.scilab.modules.$(modulename); \
	SWIG_OUTDIR=src/java/org/scilab/modules/$(modulename)/; \
	if test -n "$(SWIG_WRAPPERS)"; then \
		for file in $(SWIG_WRAPPERS) ; do \
			echo "Swig process of $$file (Java) ..."; \
			$(SWIG_BIN) $(SWIG_JAVA) -package $$SWIG_PACKAGENAME  -outdir $$SWIG_OUTDIR $$file; \
		done; \
	fi

## build Swig C => Scilab wrappers
swig-scilab: $(SWIG_SCILAB_WRAPPERS)
	@SWIG_OUTDIR=src/swig/; \
	if test -n "$(SWIG_SCILAB_WRAPPERS)"; then \
		for file in $(SWIG_SCILAB_WRAPPERS) ; do \
			echo "Swig process of $$file (Scilab) ..."; \
			$(SWIG_BIN) $(SWIG_SCILAB)  -outdir $$SWIG_OUTDIR $$file; \
		done; \
	fi

endif

if GIWS
# If the user request for the SWIG generation of the wrappers Java => C/C++ 
# We call the target swig-build on the variable SWIG_WRAPPERS

## build Swig Java => C wrappers
giws: $(GIWS_WRAPPERS)
	@GIWS_OUTPUTDIR=src/jni/; \
	MANDATORY_OPTIONS="--throws-exception-on-error --description-file"; \
	if test -n "$(GIWS_WRAPPERS)"; then \
		for file in $(GIWS_WRAPPERS) ; do \
			echo "GIWS process of $$file ..."; \
			if test -z "$(GIWS_OPTIONS)"; then \
				$(GIWS_BIN) --disable-return-size-array --output-dir $$GIWS_OUTPUTDIR $$MANDATORY_OPTIONS $$file; \
			else \
				echo "Custom GIWS call with '$$GIWS_OPTIONS'"; \
				$(GIWS_BIN) $$GIWS_OPTIONS --output-dir $$GIWS_OUTPUTDIR $$MANDATORY_OPTIONS $$file; \
			fi \
		done; \
	fi

## build GIWS Exception
giws-exception:
	@GIWS_OUTPUTDIR=src/jni/;\
	echo "GIWS: Generation of exception class ..."; \
	$(GIWS_BIN) --generate-exception-class --output-dir $$GIWS_OUTPUTDIR 

endif


## Build the macros of the module
macros:
	-@( if test ! -x $(top_builddir)/scilab-bin; then \
		echo "Error : Cannot build $< : Scilab has not been built"; \
	else \
		$(top_builddir)/bin/scilab -ns -nwni -e "exec('macros/buildmacros.sce');quit;";\
	fi)


# Removes the macros
clean-macros:
# Removes macros (*.bin generated from .sci)
	@for dir in $(MACRODIRS) $(MACROSDIRSEXT) ; do \
		echo "rm -f $(builddir)/$$dir/$(MACROBINMASK)"; \
		rm -f $(builddir)/$$dir/$(MACROBINMASK); \
	done

test:
# More tests could be added here
	@if test -z "$(USEANT)"; then USEANT=0; else USEANT=1; fi; \
	if test -f build.xml -a $$USEANT -eq 1; then \
		$(ANT) test; \
	fi



all-local: $(TARGETS_ALL)

################ MACROS ######################
# Rule to build a macro
# NOT USED  AT THE MOMENT
SUFFIXES = .sci 

.sci.bin:
	-@( if test ! -x $(top_builddir)/scilab-bin; then \
	echo "Error : Cannot build $< : Scilab has not been build"; \
	else \
	echo "Creating $@"; \
	$(top_builddir)/bin/scilab -ns -nwni -e "exec('$(abs_srcdir)/$<');save('$(abs_srcdir)/$@');exit;"; \
	fi )

########### INSTALL DOCUMENTATION ###################

# Install documentation files into the right target
# We do not use the automake mechanism (libxxxx_la_help_fr_DATA) because
# automake needs the html files to be present which is not the case when
# we are building Scilab

# Where it should be installed
pkgdocdir = $(mydatadir)

# What is the mask of the help source
DOCMASKXML = *.xml

# What is the mask of the MathML sources
DOCMASKMML = *.mml

install-html-local:

install-data-local-local:
# Mainly for javasci
	@if test -d $(srcdir)/javadoc; then \
		cp -R $(srcdir)/javadoc $(DESTDIR)/$(mydatadir)/; \
	fi
if INSTALL_HELP_XML
# If the user wants the help sources to be installed
	@echo "-------- Install of XML sources of help files --------"; \
	for lang in $(ALL_LINGUAS); do \
	 if test -d $(srcdir)/help/$$lang; then \
	  $(mkinstalldirs) $(DESTDIR)$(pkgdocdir)/help/$$lang && \
		if ls -lLd $(srcdir)/help/$$lang/$(DOCMASKXML) >/dev/null 2>&1; then \
		  for file in $(srcdir)/help/$$lang/$(DOCMASKXML) ; do \
		    echo "$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdocdir)/help/$$lang" ; \
	    	$(INSTALL_DATA) "$$file" $(DESTDIR)$(pkgdocdir)/help/$$lang ; \
		  done ; \
		fi; \
	 fi; \
	done; \
	@echo "-------- Install of MathML sources --------"; \
	 if test -d $(srcdir)/help/mml/; then \
	  $(mkinstalldirs) $(DESTDIR)$(pkgdocdir)/help/mml/ && \
		if ls -lLd $(srcdir)/help/mml/$(DOCMASKMML) >/dev/null 2>&1; then \
		  for file in $(srcdir)/help/mml/$(DOCMASKMML) ; do \
		    echo "$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdocdir)/help/mml" ; \
	    	$(INSTALL_DATA) "$$file" $(DESTDIR)$(pkgdocdir)/help/mml ; \
		  done ; \
		fi; \
	fi
endif

########### INSTALL DATA ###################
# Install macros, help & demos
# Where it should be installed
pkgmacrosdir = $(mydatadir)
# Which directory we process
MACRODIRS = macros/
# Mask of the Scilab sources macros
MACROMASK = *.sci
# Mask of the Scilab executable sources macros
MACROBUILDMASK = *.sce
# Mask of the Scilab compiled macros
MACROBINMASK = *.bin
# List of the standard directory for tests
TESTS_DIR=tests/benchmarks tests/nonreg_tests tests/unit_tests tests/java
# Where the demos should be installed
pkgdemosdir = $(mydatadir)
# List of the standard directory for demos
DEMOS_DIR=demos
# List of the standard directory for examples
EXAMPLES_DIR=examples
# Where to export JAVA archives (.jar)
JARDIR=jar/
# JAR files mask
JARMASK=*.jar
# Chapter file 
HELP_CHAPTERDIR=help/
HELP_CHAPTERFILE=addchapter.sce
HELP_CHAPTERLANG = en_US fr_FR pt_BR
install-data-local:
# Install the tests
	@echo "-------- Install tests (if any) --------"; \
	for dir in $(TESTS_DIR) $(TESTS_DIREXT) ; do \
	  if test -d $(srcdir)/$$dir/; then \
	    $(mkinstalldirs) $(DESTDIR)$(pkgmacrosdir)/$$dir && \
		  for file in `find $(srcdir)/$$dir | sed "s|^$(srcdir)/$$dir||" 2>/dev/null`; do \
		    if test -d "$(srcdir)/$$dir/$$file"; then \
			  echo $(mkinstalldirs) $(DESTDIR)$(pkgmacrosdir)/$$dir/$$file; \
			  $(mkinstalldirs) "$(DESTDIR)$(pkgmacrosdir)/$$dir/$$file"; \
		    else \
		      echo "$(INSTALL_DATA) $(srcdir)/$$dir/$$file $(DESTDIR)$(pkgmacrosdir)/`dirname $$dir/$$file`" ; \
	    	  $(INSTALL_DATA) "$(srcdir)/$$dir/$$file" "$(DESTDIR)$(pkgmacrosdir)/`dirname $$dir/$$file`" ; \
		    fi \
		  done; \
	  fi; \
	done
# Install the help chapter
	@echo "-------- Install the help chapter (if any) --------"; \
	for lang in $(HELP_CHAPTERLANG); do \
		HELPFILE=$(srcdir)/$(HELP_CHAPTERDIR)$$lang/$(HELP_CHAPTERFILE); \
		if test -f $$HELPFILE; then \
			echo $(mkinstalldirs) $(DESTDIR)$(pkgdocdir)/$(HELP_CHAPTERDIR)/$$lang/; \
			$(mkinstalldirs) $(DESTDIR)$(pkgdocdir)/$(HELP_CHAPTERDIR)/$$lang/; \
			echo $(INSTALL_DATA) $$HELPFILE $(DESTDIR)$(pkgdocdir)/$$HELPFILE; \
			$(INSTALL_DATA) $$HELPFILE $(DESTDIR)$(pkgdocdir)/$$HELPFILE; \
		fi; \
	done
# Install the demos & examples
	@echo "-------- Install demos & examples (if any) --------"; \
	for dir in $(DEMOS_DIR) $(DEMOS_DIREXT) $(EXAMPLES_DIR) $(EXAMPLES_DIREXT) ; do \
	  if test -d $(srcdir)/$$dir/; then \
	    $(mkinstalldirs) $(DESTDIR)$(pkgdocdir)/$$dir && \
		  for file in `find $(srcdir)/$$dir | sed "s|^$(srcdir)/$$dir||" 2>/dev/null`; do \
		    if test -d "$(srcdir)/$$dir/$$file"; then \
			  echo $(mkinstalldirs) $(DESTDIR)$(pkgdocdir)/$$dir/$$file; \
			  $(mkinstalldirs) "$(DESTDIR)$(pkgdocdir)/$$dir/$$file"; \
		    else \
		      echo "$(INSTALL_DATA) $(srcdir)/$$dir/$$file $(DESTDIR)$(pkgdocdir)/`dirname $$dir/$$file`" ; \
	    	  $(INSTALL_DATA) "$(srcdir)/$$dir/$$file" "$(DESTDIR)$(pkgdocdir)/`dirname $$dir/$$file`" ; \
		    fi \
		  done; \
	  fi; \
	done
# Install the macros
	@echo "-------- Install macros (if any) --------"; \
	for dir in $(MACRODIRS) $(MACROSDIRSEXT) ; do \
	  $(mkinstalldirs) $(DESTDIR)$(pkgmacrosdir)/$$dir && \
		if test -d $(srcdir)/$$dir/; then \
			FILELIST="$(srcdir)/$$dir/$(MACROMASK) $(srcdir)/$$dir/$(MACROBINMASK) $(srcdir)/$$dir/$(MACROBUILDMASK) $(srcdir)/$$dir/names $(srcdir)/$$dir/lib";\
			if test -n "$(MACROSSPECIALEXT)"; then \
				specialExtDir=""; \
				for specialExt in $(MACROSSPECIALEXT); do \
					specialExtDir="$$specialExtDir $(srcdir)/$$dir/$$specialExt"; \
				done; \
				FILELIST="$$FILELIST $$specialExtDir"; \
			fi; \
		  for file in `ls -1 $$FILELIST 2>/dev/null`; do \
		    echo "$(INSTALL_DATA) $$file $(DESTDIR)$(pkgmacrosdir)/$$dir" ; \
	    	$(INSTALL_DATA) "$$file" $(DESTDIR)$(pkgmacrosdir)/$$dir ; \
		  done; \
		fi; \
	done
# Install java files (.jar)
	@if ls -lLd $(srcdir)/$(JARDIR)$(JARMASK) >/dev/null 2>&1; then \
	echo "-------- Install jar files --------"; \
    $(mkinstalldirs) $(DESTDIR)$(pkgdocdir)/$(JARDIR); \
	  for file in $(srcdir)/$(JARDIR)$(JARMASK); do\
		    echo "$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdocdir)/$(JARDIR)" ; \
	    	$(INSTALL_DATA) "$$file" $(DESTDIR)$(pkgdocdir)/$(JARDIR) ; \
	  done ; \
	fi

########### CLEAN ###################
# Clean help (generated automatically by Scilab)
# It used to clean the macro (clean-macros) but this was causing
# make clean && make to fail Scilab startup
if NEED_JAVA
clean-local: clean-java
else
clean-local:
endif

distclean-local:
	rm -f $(builddir)/help/*/.last_successful_build_javaHelp $(builddir)/help/*/.list_*

.PHONY: macros java swig giws