Skip to content

Commit da6539c

Browse files
committed
configure uses --with-swig now, if without it will try to reuse previously generted api
1 parent 6cb1858 commit da6539c

File tree

7 files changed

+68
-21
lines changed

7 files changed

+68
-21
lines changed

configure.ac

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,45 @@ else
154154
fi
155155
AM_CONDITIONAL([WITH_GDAL], test "x$with_gdal" != "xno")
156156

157-
157+
#SWIG
158158
#-------------------------------------------------------------------------------------
159-
AC_ARG_VAR([SWIG],[path to swig, python api generator])
160-
AC_PATH_PROG([SWIG],[swig],[])
161-
if test "x$SWIG" = "x"; then
162-
AC_MSG_ERROR([swig is not found, set SWIG variable!])
163-
fi
164-
SWIG_VERSION=`$SWIG -version|grep ersion|cut -d ' ' -f 3`
165-
SWIG_VERSION_MAJOR=`echo $SWIG_VERSION|cut -d . -f1`
166-
if test "x$SWIG_VERSION_MAJOR" != "x3"; then
167-
AC_MSG_ERROR([swig is too old should be at least 3.0, set SWIG variable for custom location!])
168-
fi
169-
AC_MSG_NOTICE([swig version: $SWIG_VERSION])
159+
AC_ARG_WITH(swig,
160+
AS_HELP_STRING([--with-swig=<path to swig executable>],
161+
[Specify path to SWIG executable. ]
162+
[If set will (re)generate python API, otherwise will try to use previously generated sources. ]
163+
[Note that github repository do not track them.]),)
164+
#only developers/advanced user should call swig
165+
#the public source code releases should come with swig generated files
166+
if test -n "$with_swig"; then
167+
SWIG=$with_swig
168+
AC_PATH_PROG([SWIG],[swig],[])
169+
if test "x$SWIG" = "x"; then
170+
AC_MSG_ERROR([swig is not found, set SWIG variable!])
171+
fi
172+
SWIG_VERSION=`$SWIG -version|grep ersion|cut -d ' ' -f 3`
173+
SWIG_VERSION_MAJOR=`echo $SWIG_VERSION|cut -d . -f1`
174+
if test "x$SWIG_VERSION_MAJOR" != "x3"; then
175+
AC_MSG_ERROR([swig is too old should be at least 3.0, set SWIG variable for custom location!])
176+
fi
177+
AC_MSG_NOTICE([swig: $SWIG])
178+
AC_MSG_NOTICE([swig version: $SWIG_VERSION])
179+
else
180+
#check for swig generated files presence
181+
AC_CHECK_FILE($srcdir/src/main/cxxtitan_wrap.cxx,
182+
AC_MSG_NOTICE([found cxxtitan_wrap.cxx]),
183+
AC_MSG_FAILURE([Couldn't find SWIG generated python API sources.]
184+
[Set --with-swig to SWIG to regenerate interface.])
185+
)
186+
AC_CHECK_FILE($srcdir/src/main/cxxtitan.py,
187+
AC_MSG_NOTICE([found cxxtitan_wrap.cxx]),
188+
AC_MSG_FAILURE([Couldn't find SWIG generated python API sources.]
189+
[Set --with-swig to SWIG to regenerate interface.])
190+
)
191+
fi
192+
AM_CONDITIONAL([WITH_SWIG], test "x$with_swig" != "xno")
170193

171194
#-------------------------------------------------------------------------------------
172195
AC_CHECK_LIB(m,matherr)
173-
AC_CHECK_LIB(nsl, inet_ntoa)
174196

175197
## Checks for header files
176198
#=====================================================================================

src/header/hd5calls.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const int XDMF_NEW = 0;
2626
const int XDMF_OLD = 1;
2727
const int XDMF_CLOSE = 2;
2828

29+
#define __STDC_FORMAT_MACROS
2930
#include <hdf5.h>
3031

3132

@@ -97,7 +98,6 @@ hid_t GH5_createdataset(hid_t gid, hid_t spcid, const char *dsetname, unsigned t
9798

9899

99100

100-
#ifdef __cplusplus
101101
#include <H5Cpp.h>
102102

103103
#include <iostream>
@@ -422,5 +422,4 @@ inline void TiH5_readArray2DDataSet__(const H5::Group &group, double *value, con
422422

423423

424424

425-
#endif
426425
#endif

src/header/sfc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ inline SFC_Key sfc_key_read_from_space(const unsigned readspace[],int & pos)
152152
}
153153
#else
154154
#include <stdio.h>
155-
#include <stdint.h>
156155
#define __STDC_FORMAT_MACROS
157156
#include <inttypes.h>
158157
typedef uint64_t SFC_Key;
159158

159+
160160
inline void fprintf_sfc_key(FILE *fout, const SFC_Key& obj)
161161
{
162162
fprintf(fout,"%" PRIu64 "\n",obj);

src/main/Makefile.am

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ titan_LDADD = ../preproc/libtitan_preprocess.a ../gisapi/libgisapi.a ../adapt/li
1616
../datstr/libdatstr.a ../geoflow/libgeoflow.a ../useful/libuseful.a \
1717
../repartition/librepartition.a ../tecplot/libtecplot.a \
1818
../vectordatapreproc/libvectordatpreproc.a \
19-
-L@PYTHON_ROOT@/lib -lpython@PYTHON_VERSION@ -lutil
19+
-L@PYTHON_ROOT@/lib -lpython@PYTHON_VERSION@
2020

2121
#titan_simulation_CXXFLAGS = -fpic
2222

23+
if WITH_SWIG
2324
cxxtitan_wrap.cxx:cxxtitan.i ../header/properties.h ../header/titan_simulation.h ../preproc/preproc.h
2425
@SWIG@ $(CPPFLAGS) -c++ -v -python -o $(srcdir)/cxxtitan_wrap.cxx -oh $(srcdir)/cxxtitan.py $(srcdir)/cxxtitan.i
25-
26+
endif
2627

2728

2829
pyfilesdir=$(pythondir)/titan

src/main/cxxtitan.i

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616

1717
%module cxxtitan
18-
18+
%begin %{
19+
#define __STDC_FORMAT_MACROS
20+
%}
1921
%{
2022
#include "../header/constant.h"
2123
#include "../header/properties.h"

src/main/titan.C

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#endif
2424

2525
#include <stdio.h>
26+
#include <string.h>
2627
#include <unistd.h>
2728

2829
#include "../header/ticore/omp_mpi.hpp"
@@ -45,6 +46,7 @@ extern "C" void init_cxxtitan();
4546

4647
int main(int argc, char *argv[])
4748
{
49+
printf("Titan2d\n");
4850
int myid, master, numprocs;
4951
int namelen;
5052

@@ -55,12 +57,33 @@ int main(int argc, char *argv[])
5557
//set program full name
5658
int i;
5759
char executable[1028];
60+
char python_home[1028];
5861
char buffer[1028];
5962

6063
i = readlink("/proc/self/exe", executable, 1028);
6164
executable[i] = '\0';
6265
Py_SetProgramName(executable);
63-
66+
67+
//#define MAKE_PORTABLE
68+
#ifdef MAKE_PORTABLE
69+
strncpy(python_home,executable,1028);
70+
printf("%s\n",python_home);
71+
int count=0;
72+
for(i=strlen(python_home);i>=0;--i)
73+
{
74+
if(python_home[i]=='/')
75+
{
76+
python_home[i]='\0';
77+
++count;
78+
if(count==2)break;
79+
}
80+
}
81+
82+
printf("%s\n",python_home);
83+
sprintf(python_home+strlen(python_home),"/lib/python");
84+
printf("%s\n",python_home);
85+
Py_SetPythonHome(python_home);
86+
#endif
6487
Py_Initialize();
6588

6689
if(myid == 0)

src/main/titan_simulation.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,8 @@ void cxxTitanSimulation::save_restart_file()
612612
xmdf<<"\t\t\t\t</DataItem>\n";
613613
}
614614
xmdf<<"\t\t\t</DataItem>\n";
615-
#endif
616615
xmdf<<"\t\t</Topology>\n";
616+
#endif
617617

618618
//Geometry
619619
xmdf<<"\t\t<Geometry Type=\"XYZ\">\n";

0 commit comments

Comments
 (0)