Salome HOME
Increment version of 7.1.0
[tools/yacsgen.git] / module_generator / mod_tmpl.py
1 # Copyright (C) 2009-2012  EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 try:
21   from string import Template
22 except:
23   from compat import Template,set
24
25 application="""
26 <application>
27 <prerequisites path="${prerequisites}"/>
28 ${resources}
29 <modules>
30 ${modules}
31 </modules>
32 </application>
33 """
34 application=Template(application)
35
36 autogen="""#!/bin/sh
37
38 rm -rf autom4te.cache
39 rm -f aclocal.m4 adm_local/ltmain.sh
40
41 echo "Running aclocal..."    ;
42 aclocal --force -I adm_local || exit 1
43 echo "Running autoheader..." ; autoheader --force -I adm_local            || exit 1
44 echo "Running autoconf..."   ; autoconf --force                    || exit 1
45 echo "Running libtoolize..." ; libtoolize --copy --force           || exit 1
46 echo "Running automake..."   ; automake --add-missing --copy       || exit 1
47 """
48
49 mainMakefile="""include $$(top_srcdir)/adm_local/make_common_starter.am
50 SUBDIRS = idl resources src ${docsubdir}
51 ACLOCAL_AMFLAGS = -I adm_local
52 """
53 mainMakefile=Template(mainMakefile)
54
55 configure="""
56 AC_INIT(${module}, 1.0)
57 AC_CONFIG_AUX_DIR(adm_local)
58 AM_INIT_AUTOMAKE
59 AM_CONFIG_HEADER(${module}_config.h)
60
61 dnl Check Salome Install
62 CHECK_KERNEL
63 if test "x$$Kernel_ok" = "xno"; then
64   AC_MSG_ERROR([You must define a correct KERNEL_ROOT_DIR or use the --with-kernel= configure option !])
65 fi
66
67 dnl Check Salome modules Install
68 ${modules}
69
70 AC_PROG_LIBTOOL
71 AC_PROG_CC
72 AC_PROG_CXX
73 CHECK_F77
74 CHECK_OMNIORB
75 CHECK_PACO
76 CHECK_MPI
77
78 MODULE_NAME=${module}
79 AC_SUBST(MODULE_NAME)
80
81 AC_CHECK_ASTER
82
83 ${other_check}
84
85 echo
86 echo
87 echo
88 echo "------------------------------------------------------------------------"
89 echo "$$PACKAGE $$VERSION"
90 echo "------------------------------------------------------------------------"
91 echo
92 echo "Configuration Options Summary:"
93 echo
94 echo "  Threads ................ : $$threads_ok"
95 echo "  OmniOrb (CORBA) ........ : $$omniORB_ok"
96 echo "  OmniOrbpy (CORBA) ...... : $$omniORBpy_ok"
97 echo "  Python ................. : $$python_ok"
98 echo "  SALOME KERNEL .......... : $$Kernel_ok"
99 echo "  PaCO++ ................. : $$PaCO_ok"
100 echo "  MPI .................... : $$mpi_ok"
101 echo "  Code Aster ............. : $$Aster_ok"
102 ${other_summary}
103 echo
104 echo "------------------------------------------------------------------------"
105 echo
106
107 if test "x$$threads_ok" = "xno"; then
108   AC_MSG_ERROR([Thread is required],1)
109 fi
110 if test "x$$python_ok" = "xno"; then
111   AC_MSG_ERROR([Python is required],1)
112 fi
113 if test "x$$omniORB_ok" = "xno"; then
114   AC_MSG_ERROR([OmniOrb is required],1)
115 fi
116 if test "x$$omniORBpy_ok" = "xno"; then
117   AC_MSG_ERROR([OmniOrbpy is required],1)
118 fi
119 if test "x$$Kernel_ok" = "xno"; then
120   AC_MSG_ERROR([SALOME KERNEL is required],1)
121 fi
122 ${other_require}
123
124 ${paco_configure}
125
126 AC_CONFIG_FILES([
127         Makefile
128         idl/Makefile
129         resources/Makefile
130         src/Makefile
131 ${makefiles}
132         ])
133 AC_OUTPUT
134 """
135 configure=Template(configure)
136
137 paco_configure="""\
138 if test "x$$PaCO_ok" = "xno"; then
139   AC_MSG_ERROR([PaCO++ is required],1)
140 fi
141 """
142
143 makecommon="""
144 # Standard directory for installation
145 salomeincludedir   = $$(includedir)/salome
146 libdir             = $$(prefix)/lib/salome
147 bindir             = $$(prefix)/bin/salome
148 salomescriptdir    = $$(bindir)
149 salomepythondir    = $$(prefix)/lib/python$$(PYTHON_VERSION)/site-packages/salome
150
151 # Directory for installing idl files
152 salomeidldir       = $$(prefix)/idl/salome
153
154 # Directory for installing resource files
155 salomeresdir       = $$(prefix)/share/salome/resources/$${MODULE_NAME}
156
157 # Directories for installing admin files
158 admlocaldir       = $$(prefix)/adm_local
159 admlocalunixdir     = $$(admlocaldir)/unix
160 admlocalm4dir        = $$(admlocaldir)/unix/config_files
161
162 # Shared modules installation directory
163 sharedpkgpythondir =$$(pkgpythondir)/shared_modules
164
165 # Documentation directory
166 salomedocdir             = $$(prefix)/share/doc/salome/gui/$${MODULE_NAME}
167
168 IDL_INCLUDES = -I$$(KERNEL_ROOT_DIR)/idl/salome
169 KERNEL_LIBS= -L$$(KERNEL_ROOT_DIR)/lib/salome -lSalomeContainer -lOpUtil -lSalomeDSCContainer -lSalomeDSCSuperv -lSalomeDatastream -lSalomeDSCSupervBasic -lCalciumC
170 KERNEL_INCLUDES= -I$$(KERNEL_ROOT_DIR)/include/salome $$(OMNIORB_INCLUDES) ${other_includes}
171
172 SALOME_LIBS= $${KERNEL_LIBS}
173 SALOME_IDL_LIBS= -L$$(KERNEL_ROOT_DIR)/lib/salome -lSalomeIDLKernel
174 SALOME_INCLUDES= $${KERNEL_INCLUDES}
175
176 """
177 makecommon=Template(makecommon)
178
179 resMakefile="""
180 include $$(top_srcdir)/adm_local/make_common_starter.am
181 DATA_INST = ${module}Catalog.xml
182 salomeres_DATA = $${DATA_INST}
183 EXTRA_DIST = $${DATA_INST}
184 """
185 resMakefile=Template(resMakefile)
186
187 check_sphinx="""
188 AC_DEFUN([CHECK_SPHINX],[
189
190 AC_CHECKING(for sphinx doc generator)
191
192 sphinx_ok=yes
193 dnl where is sphinx ?
194 AC_PATH_PROG(SPHINX,sphinx-build)
195 if test "x$SPHINX" = "x"
196 then
197   AC_MSG_WARN(sphinx not found)
198   sphinx_ok=no
199 fi
200
201 dnl Can I load ths sphinx module ?
202 dnl This code comes from the ax_python_module macro.
203 if test -z $PYTHON;
204 then
205    PYTHON="python"
206 fi
207 PYTHON_NAME=`basename $PYTHON`
208 AC_MSG_CHECKING($PYTHON_NAME module: sphinx)
209    $PYTHON -c "import sphinx" 2>/dev/null
210    if test $? -eq 0;
211    then
212      AC_MSG_RESULT(yes)
213      eval AS_TR_CPP(HAVE_PYMOD_sphinx)=yes
214    else
215      AC_MSG_RESULT(no)
216      eval AS_TR_CPP(HAVE_PYMOD_sphinx)=no
217      sphinx_ok=no
218    fi
219
220 AM_CONDITIONAL(SPHINX_IS_OK, [test x"$sphinx_ok" = xyes])
221
222 ])
223 """
224