Param_Polyhedron_Enumerate: plug memory leak in case of exception
[barvinok.git] / Makefile.am
blob28044158dc84c11004c4c812050f76c69c25a081
1 if BUNDLED_POLYLIB
2     MAYBE_POLYLIB = polylib
3     POLYLIB_LA = $(top_builddir)/polylib/libpolylibgmp.la
4     LOCAL_POLYLIB_LA = polylib/libpolylibgmp.la
5 endif
6 if BUNDLED_ISL
7     MAYBE_ISL = isl
8     ISL_LA = $(top_builddir)/isl/libisl.la
9     LOCAL_ISL_LA = isl/libisl.la
10 endif
11 if BUILD_ISL
12     ISL_LA = $(ISL_BUILDDIR)/libisl.la
13 endif
14 if BUNDLED_PET
15     MAYBE_PET = pet
16     PET_LA = $(top_builddir)/pet/libpet.la
17 endif
18 if BUILD_PET
19     PET_LA = $(PET_BUILDDIR)/libpet.la
20 endif
21 if USE_ZSOLVE
22     MAYBE_ZSOLVE = zsolve
23 endif
24 if USE_PARKER
25     MAYBE_PARKER = parker
26 endif
27 SUBDIRS = $(MAYBE_POLYLIB) $(MAYBE_ISL) $(MAYBE_PET) \
28                 $(MAYBE_ZSOLVE) $(MAYBE_PARKER) . doc
29 DIST_SUBDIRS = $(MAYBE_POLYLIB) $(MAYBE_ISL) $(MAYBE_PET) \
30                 zsolve parker doc
32 FORCE:
33 polylib/libpolylibgmp.la: FORCE
34         cd polylib; $(MAKE) $(AM_MAKEFLAGS) libpolylibgmp.la
35 isl/libisl.la: FORCE
36         cd isl; $(MAKE) $(AM_MAKEFLAGS) libisl.la
37 pet/libpet.la: FORCE
38         cd pet; $(MAKE) $(AM_MAKEFLAGS) libpet.la
39 zsolve/libzsolve.la: FORCE
40         cd zsolve; $(MAKE) $(AM_MAKEFLAGS) libzsolve.la
41 parker/libparker.la: FORCE
42         cd parker; $(MAKE) $(AM_MAKEFLAGS) libparker.la
44 AM_CPPFLAGS = @POLYLIB_CPPFLAGS@ \
45               @ISL_CFLAGS@ @NTL_CPPFLAGS@
46 AM_LDFLAGS = @POLYLIB_LDFLAGS@ @NTL_LDFLAGS@
48 LIB_ISL = $(ISL_LA) @ISL_LIBS@
49 LIB_PET = $(PET_LA) @PET_LIBS@
50 LIB_POLYLIB = $(POLYLIB_LA) @POLYLIB_LIBS@
52 lib_LTLIBRARIES = libbarvinok.la
53 bin_PROGRAMS = barvinok_count barvinok_enumerate barvinok_enumerate_e \
54                   barvinok_ehrhart polytope_scan iscc
55 noinst_PROGRAMS = test testlib randomtest \
56                   remove_redundant_equalities \
57                   barvinok_union polytope_volume test_approx \
58                   barvinok_summate verify_lexsmaller \
59                   polyhedron_sample 4coins lexmin \
60                   @bv_cone_hilbert_basis@ cone_integer_hull \
61                   polytope_lattice_width \
62                   polyhedron_integer_hull vector_partition_chambers \
63                   semigroup_holes \
64                   barvinok_bound test_bound
65 EXTRA_PROGRAMS = cone_hilbert_basis
66 pkginclude_HEADERS = \
67     barvinok/NTL_QQ.h \
68     barvinok/isl.h \
69     barvinok/barvinok.h \
70     barvinok/util.h \
71     barvinok/evalue.h \
72     barvinok/genfun.h \
73     barvinok/options.h \
74     barvinok/polylib.h \
75     barvinok/sample.h \
76     barvinok/basis_reduction.h
77 nodist_pkginclude_HEADERS = \
78     barvinok/NTL.h \
79     barvinok/set.h
80 LINK = $(CXXLINK)
82 if HAVE_CDDLIB
83     BR_CDD = basis_reduction_cdd.cc initcdd.cc
84     POLYSIGN_CDD = polysign_cddf.cc polysign_cdd.cc
85 endif
86 if HAVE_GLPK
87     BR_GLPK = basis_reduction_glpk.c
88     POLYSIGN_GLPK = polysign_glpk.c
89 endif
90 if HAVE_TOPCOM
91     TOPCOM = topcom.c topcom.h
92 endif
93 if USE_ZSOLVE
94     HILBERT_C = hilbert.c
95 endif
96 libbarvinok_la_SOURCES = \
97     barvinok/evalue.h \
98     barvinok/genfun.h \
99     barvinok/util.h \
100     barvinok/barvinok.h \
101     NTL_QQ.cc \
102     basis_reduction.c \
103     evalue.c \
104     genfun.cc \
105     util.c \
106     version.c \
107     bernoulli.c \
108     bernoulli.h \
109     bfcounter.cc \
110     bfcounter.h \
111     binomial.c \
112     binomial.h \
113     conversion.cc \
114     conversion.h \
115     counter.cc \
116     counter.h \
117     decomposer.cc \
118     decomposer.h \
119     dpoly.cc \
120     dpoly.h \
121     euler.cc \
122     euler.h \
123     evalue_isl.c \
124     genfun_constructor.cc \
125     genfun_constructor.h \
126     $(HILBERT_C) \
127     hilbert.h \
128     hull.c \
129     hull.h \
130     ilp.c \
131     ilp.h \
132     isl_polylib.h \
133     isl_aff_polylib.c \
134     isl_aff_polylib.h \
135     isl_map_polylib.c \
136     isl_map_polylib.h \
137     isl_set_polylib.h \
138     isl_param_util.c \
139     isl_param_util.h \
140     lattice_point.cc \
141     lattice_point.h \
142     lattice_width.c \
143     lattice_width.h \
144     laurent.cc \
145     laurent.h \
146     laurent_old.cc \
147     laurent_old.h \
148     normalization.c \
149     normalization.h \
150     options.c \
151     param_polynomial.cc \
152     param_polynomial.h \
153     param_util.c \
154     param_util.h \
155     $(POLYSIGN_CDD) \
156     $(POLYSIGN_GLPK) \
157     $(POLYSIGN_PIP) \
158     polysign.c \
159     polysign_isl.c \
160     polysign_polylib.c \
161     polysign.h \
162     power.h \
163     reduce_domain.c \
164     reduce_domain.h \
165     reducer.cc \
166     reducer.h \
167     remove_equalities.h \
168     remove_equalities.c \
169     sample.c \
170     scale.c \
171     scale.h \
172     scarf.cc \
173     section_array.h \
174     series.cc \
175     $(TOPCOM) \
176     summate.c \
177     summate.h \
178     vertex_cone.cc \
179     vertex_cone.h \
180     volume.c \
181     volume.h \
182     mat_util.cc \
183     mat_util.h \
184     matrix_read.cc \
185     matrix_read.h \
186     barvinok.cc \
187     barvinok_e.cc \
188     $(BR_CDD) \
189     $(BR_GLPK) \
190     $(BR_PIP)
191 EXTRA_libbarvinok_la_SOURCES = \
192     basis_reduction_cdd.cc \
193     basis_reduction_glpk.c \
194     hilbert.c \
195     polysign_cddf.cc \
196     polysign_cdd.cc \
197     polysign.c \
198     initcdd.cc \
199     initcdd.h \
200     topcom.c \
201     topcom.h
202 if USE_ZSOLVE
203     ZSOLVE_LA = zsolve/libzsolve.la
204 endif
205 libbarvinok_la_LIBADD = @LTLIBOBJS@ $(LIB_ISL) \
206                              $(LIB_POLYLIB) $(ZSOLVE_LA)
207 libbarvinok_la_LDFLAGS = @BV_LDFLAGS@ -version-info @versioninfo@ \
208                                 $(AM_LDFLAGS)
209 LDADD = libbarvinok.la $(LIB_ISL) $(LIB_POLYLIB)
211 test_SOURCES = \
212         test.c
213 testlib_SOURCES = \
214         evalue_read.c \
215         evalue_read.h \
216         testlib.cc
217 barvinok_count_SOURCES = barvinok_count.c
218 barvinok_ehrhart_SOURCES = \
219         barvinok_ehrhart_options.c \
220         barvinok_ehrhart_options.h \
221         barvinok_ehrhart.cc \
222         evalue_convert_options.c \
223         evalue_convert.cc \
224         evalue_convert.h \
225         $(FDSTREAM)
226 barvinok_union_SOURCES = \
227         barvinok_union_options.c \
228         barvinok_union_options.h \
229         barvinok_union.cc
230 if HAVE_OMEGA
231 BEEO_SOURCES = \
232         omega_interface/Exit.cc \
233         omega_interface/convert.h \
234         omega_interface/convert.cc \
235         omega_interface/count.h \
236         omega_interface/count.cc
237 else
238 BEEO_SOURCES = 
239 endif
240 if USE_FDSTREAM
241 FDSTREAM = fdstream.cc fdstream.h
242 endif
243 barvinok_enumerate_SOURCES = \
244         barvinok_enumerate_options.c \
245         barvinok_enumerate_options.h \
246         barvinok_enumerate.cc \
247         evalue_convert_options.c \
248         evalue_convert.cc \
249         evalue_convert.h \
250         $(FDSTREAM) \
251         skewed_genfun.cc \
252         skewed_genfun.h \
253         verify.h \
254         verify.c \
255         verif_ehrhart.h \
256         verif_ehrhart.c \
257         verify_series.h \
258         verify_series.cc
259 EXTRA_barvinok_enumerate_SOURCES = fdstream.cc fdstream.h
260 barvinok_enumerate_e_SOURCES = \
261         barvinok_enumerate_e_options.c \
262         barvinok_enumerate_e_options.h \
263         barvinok_enumerate_e.cc \
264         evalue_convert_options.c \
265         evalue_convert.cc \
266         evalue_convert.h \
267         $(FDSTREAM) \
268         skewed_genfun.cc \
269         skewed_genfun.h \
270         verify.h \
271         verify.c \
272         verif_ehrhart.h \
273         verif_ehrhart.c \
274         verify_series.h \
275         verify_series.cc \
276         $(BEEO_SOURCES)
277 EXTRA_barvinok_enumerate_e_SOURCES = fdstream.cc fdstream.h
278 if USE_PARKER
279     MONA_LIBS = -ldfa -lbdd -lmem
280     PARKER_LA = parker/libparker.la
281     PARKERLDFLAGS = -L$(MONAPATH)/DFA -L$(MONAPATH)/BDD -L$(MONAPATH)/Mem
282     PARKERCPPFLAGS = -I$(MONAPATH)/Mem -I$(MONAPATH)/DFA -I$(MONAPATH)/BDD
283 endif
284 barvinok_enumerate_e_CPPFLAGS = \
285         $(PARKERCPPFLAGS) @OMEGA_CPPFLAGS@ $(AM_CPPFLAGS)
286 barvinok_enumerate_e_LDFLAGS = $(PARKERLDFLAGS) @OMEGA_LDFLAGS@ @LDFLAGS@
287 barvinok_enumerate_e_LDADD = \
288         $(PARKER_LA) $(MONA_LIBS) @OMEGA_LIBS@ libbarvinok.la \
289         $(LIB_ISL) $(LIB_POLYLIB)
290 barvinok_bound_SOURCES = \
291         bound.c \
292         verify.h \
293         verify.c
294 EXTRA_barvinok_bound_SOURCES = fdstream.cc fdstream.h
295 barvinok_summate_SOURCES = \
296         barvinok_summate.c \
297         verify.h \
298         verify.c
299 EXTRA_barvinok_summate_SOURCES = fdstream.cc fdstream.h
300 4coins_SOURCES = 4coins.cc
301 semigroup_holes_SOURCES = semigroup_holes.cc
302 lexmin_SOURCES = \
303         lexmin_options.c \
304         lexmin.h \
305         lexmin.cc \
306         edomain.cc \
307         edomain.h \
308         evalue_util.cc \
309         evalue_util.h \
310         verify.h \
311         verify.c
312 test_approx_SOURCES = \
313         test_approx.c \
314         verify.h \
315         verify.c
316 test_bound_SOURCES = \
317         test_bound.c \
318         verify.h \
319         verify.c
320 EXTRA_test_bound_SOURCES = fdstream.cc fdstream.h
321 iscc_SOURCES =  \
322         isl_obj_list.h \
323         isl_obj_list.c \
324         isl_obj_str.h \
325         isl_obj_str.c \
326         iscc.c
327 iscc_CPPFLAGS = @PET_CFLAGS@ $(AM_CPPFLAGS)
328 iscc_LDADD = \
329         libbarvinok.la $(LIB_PET) $(LIB_ISL) \
330         $(LIB_POLYLIB)
332 isl.py: interface/isl.py.top
333         (cat interface/isl.py.top; \
334                 @ISL_BUILDDIR@/interface/extract_interface$(EXEEXT) \
335                         $(DEFAULT_INCLUDES) @ISL_CFLAGS@ -I"@ISL_SRCDIR@" \
336                         $(srcdir)/interface/all_barvinok.h) \
337                         > isl.py
339 TESTFILES = $(shell find $(top_srcdir)/tests -type f ! -path '*CVS*')
341 EXTRA_DIST = \
342     ChangeLog \
343     $(TESTFILES) \
344     latte2polylib.pl \
345     NTL_5_3_2.patch \
346     basis_reduction_templ.c \
347     cdd94e-test \
348     polysign_cdd_template.cc \
349     barvinok/NTL.h.broken \
350     barvinok/NTL.h.normal \
351     barvinok/set.h.broken \
352     barvinok/set.h.normal \
353     doc/isl.tex \
354     doc/Internal.tex \
355     doc/applications.tex \
356     doc/barvinok.tex \
357     doc/polymake.tex \
358     doc/reports.tex \
359     doc/barvinok.bib \
360     doc/barvinok.gdf \
361     doc/chicago.bst \
362     doc/chicago.sty \
363     doc/mydefs.sty \
364     interface/all_barvinok.h \
365     interface/isl.py.top \
366     polymake/Makefile.in \
367     polymake/README \
368     polymake/autogen.sh \
369     polymake/configure.in \
370     polymake/convert.cc \
371     polymake/convert.h \
372     polymake/h_star_vector.cc \
373     polymake/lattice_points.cc
375 ACLOCAL_AMFLAGS = -I m4
377 install-data-local:
378         @test -z "$(pkgconfig_libdir)" || $(mkdir_p) "$(DESTDIR)$(pkgconfig_libdir)"
379         $(INSTALL_DATA) $(pkgconfig_libfile) "$(DESTDIR)$(pkgconfig_libdir)/$(pkgconfig_libfile)"
381 uninstall-local:
382         rm -f "$(DESTDIR)$(pkgconfig_libdir)/$(pkgconfig_libfile)"
384 dist-hook: isl.py
385         cp isl.py $(distdir)/
386         (cd $(distdir)/polymake; \
387             ./autogen.sh; rm -rf autogen.sh autom4te.cache)
388         (cd doc; make barvinok.pdf)
389         cp doc/barvinok.pdf $(distdir)/doc/
390         if test -f $(top_srcdir)/.git/HEAD; then \
391             echo @GIT_HEAD_VERSION@ > $(distdir)/GIT_HEAD_ID; \
392         else \
393             echo $(GIT_HEAD_ID) > $(distdir)/GIT_HEAD_ID; \
394         fi
396 dist-git: dist
397         mv $(distdir).tar.gz @GIT_HEAD_VERSION@.tar.gz
399 BEE_TESTDIRS = ehrhart_e ehrhart_e/scarf ehrhart_e/piplib
401 check: check-testlib check-enumerate check-enumerate_e check-test \
402         check-lexmin check-approx check-pwqp check-euler check-iscc
403 check-testlib: testlib$(EXEEXT)
404         ./testlib$(EXEEXT)
405 check-approx: test_approx$(EXEEXT)
406         @for i in $(top_srcdir)/tests/ehrhart/*; do \
407             if test -f $$i; then \
408                 echo $$i | ./test_approx$(EXEEXT) -q -r 10 || exit; \
409             fi \
410         done
411 check-pwqp: barvinok_bound$(EXEEXT) test_bound$(EXEEXT) barvinok_summate$(EXEEXT)
412         @for i in $(top_srcdir)/tests/pwqp/*; do \
413             if test -f $$i; then \
414                 echo $$i; \
415                 ./barvinok_bound$(EXEEXT) -T -r30 < $$i || exit; \
416                 echo $$i | ./test_bound$(EXEEXT) -q -r30 || exit; \
417                 ./barvinok_summate$(EXEEXT) -T -r30 < $$i || exit; \
418             fi \
419         done
420 check-euler: barvinok_summate$(EXEEXT)
421         @for i in $(top_srcdir)/tests/euler/*; do \
422             if test -f $$i; then \
423                 for method in 'euler' 'laurent_old' 'laurent'; do \
424                     opt="--summation=$$method"; \
425                     echo $$i $$opt; \
426                     ./barvinok_summate$(EXEEXT) -T $$opt < $$i || exit; \
427                 done \
428             fi \
429         done
430 if HAVE_TOPCOM
431     TOPCOM_CD = '--chamber-decomposition=topcom'
432 endif
433 ISL_CD = '--chamber-decomposition=isl'
434 check-enumerate: barvinok_enumerate$(EXEEXT)
435         @for i in $(top_srcdir)/tests/ehrhart/*; do \
436             if test -f $$i; then \
437                 echo $$i; \
438                 for options in '' '--series' '--series --primal' $(TOPCOM_CD) $(ISL_CD); do \
439                     for spec in 'random' 'bf' 'df'; do \
440                         opt="--specialization=$$spec $$options"; \
441                         echo "        $$opt"; \
442                         ./barvinok_enumerate$(EXEEXT) --verify $$opt < $$i || exit; \
443                     done \
444                 done; \
445                 opt="--summation=bernoulli"; \
446                 echo "        $$opt"; \
447                 ./barvinok_enumerate$(EXEEXT) --verify $$opt < $$i || exit; \
448             fi \
449         done
450 if HAVE_OMEGA
451     SPEC_OMEGA = '--isl --omega'
452 endif
453 check-enumerate_e: barvinok_enumerate_e$(EXEEXT)
454         @for dir in $(BEE_TESTDIRS); do \
455             for i in $(top_srcdir)/tests/$$dir/*; do \
456                 if test -f $$i; then \
457                     for options in '' $(SPEC_OMEGA) '--isl'; do \
458                         for spec in 'random' 'bf' 'df'; do \
459                             opt="--specialization=$$spec $$options"; \
460                             echo $$i $$opt; \
461                             ./barvinok_enumerate_e$(EXEEXT) --verify $$opt < $$i || exit; \
462                         done \
463                     done \
464                 fi \
465             done \
466         done
467         @for i in $(top_srcdir)/tests/ehrhart_e/scarf/*; do \
468             if test -f $$i; then \
469                 for spec in 'random' 'bf' 'df'; do \
470                     opt="--specialization=$$spec --scarf"; \
471                     echo $$i $$opt; \
472                     ./barvinok_enumerate_e$(EXEEXT) --verify $$opt < $$i || exit; \
473                 done; \
474                 echo $$i --series; \
475                 ./barvinok_enumerate_e$(EXEEXT) --verify --series < $$i || exit; \
476             fi \
477         done
478 check-test: test$(EXEEXT)
479         @failed=0; \
480         for i in $(top_srcdir)/tests/*; do \
481             if test -f $$i; then \
482                 for options in '--index=10' '--primal --index=10'; do \
483                     for spec in 'random' 'bf' 'df' 'todd'; do \
484                         opt="--specialization=$$spec $$options"; \
485                         echo -n $$i $$opt; \
486                         ./test$(EXEEXT) $$opt < $$i; \
487                         if test "$$?" -ne "0"; then \
488                             failed=`expr $$failed + 1`; \
489                             echo " NOT ok"; \
490                         else \
491                             echo " ok"; \
492                         fi; \
493                     done \
494                 done \
495             fi \
496         done; \
497         for i in $(top_srcdir)/tests/sample/*; do \
498             echo -n $$i; \
499             ./test$(EXEEXT) < $$i; \
500             if test "$$?" -ne "0"; then \
501                 failed=`expr $$failed + 1`; \
502                 echo " NOT ok"; \
503             else \
504                 echo " ok"; \
505             fi; \
506         done; \
507         if test $$failed != 0; then \
508                 echo "$$failed tests failed"; \
509                 exit -1; \
510         fi
511 check-lexmin: lexmin$(EXEEXT)
512         @for i in $(top_srcdir)/tests/lexmin/*; do \
513             if test -f $$i; then \
514                 for spec in 'random' 'bf' 'df'; do \
515                     opt="--specialization=$$spec"; \
516                     echo $$i $$opt; \
517                     ./lexmin$(EXEEXT) --verify $$opt < $$i || exit; \
518                 done \
519             fi \
520         done
521 check-iscc: iscc$(EXEEXT)
522         @for i in $(top_srcdir)/tests/iscc/*; do \
523                 if test -f $$i; then \
524                         echo $$i; \
525                         ./iscc$(EXEEXT) < $$i || exit; \
526                 fi \
527         done
529 version.h: @GIT_HEAD@
530         echo '#define GIT_HEAD_ID "'@GIT_HEAD_VERSION@'"' > $@