SUBDIRS = c++ lua python ruby

EXTRA_DIST = libpreludecpp.i perl/libpreludecpp-perl.i perl/Makefile.PL.in perl/Prelude.cxx perl/Prelude.pm

CLEANFILES = perl/Prelude.o
DISTCLEANFILES = lua/prelude.cxx perl/Prelude.cxx ruby/Prelude.cxx
MAINTAINERCLEANFILES =   \
			lua/prelude.cxx	     \
			perl/Makefile		     \
                        perl/Prelude.cxx         \
			perl/Prelude.pm	     \
			perl/Prelude.bs 	     \
                        python/_prelude.cxx	     \
			python/prelude.py	     \
			ruby/Prelude.cxx

swigdatadir = @SWIG_DATA_DIR@
dist_swigdata_DATA = libpreludecpp.i

swigperldatadir = @SWIG_DATA_DIR@/perl
dist_swigperldata_DATA = perl/libpreludecpp-perl.i

all-am: perl

if HAVE_EASY_BINDINGS
if HAVE_PERL
perl: perl-build
#
# Workaround invalid Makefile generated by MakeMaker when UTF-8 is enabled.
#
perl-makefile:
	cd perl && LANG="" DESTDIR=$(DESTDIR) LIBDIR=$(libdir) $(PERL) Makefile.PL @PERL_EXTRA_PARAMS@ CC="$(CXX)"

perl/Prelude.cxx: $(top_srcdir)/bindings/c++/include/*.hxx libpreludecpp.i perl/libpreludecpp-perl.i
if HAVE_SWIG
	$(SWIG) -c++ -DSWIG_COMPILE_LIBPRELUDE -I$(top_srcdir)/bindings -I$(top_srcdir)/bindings/c++/include -I$(top_srcdir)/src/include -I$(top_srcdir)/src/libprelude-error -perl5 -o $@ libpreludecpp.i
endif


perl-build: perl/Prelude.cxx perl-makefile
	cd perl && $(MAKE) LD_RUN_PATH="" CC="$(CXX)"

install-exec-hook: perl-makefile 
	cd perl && $(MAKE) LD_RUN_PATH="" install

uninstall-hook: perl-makefile
	cd perl && $(MAKE) uninstall


clean-local:
	if test -f perl/Makefile; then cd perl && $(MAKE) clean; fi
	rm -f perl/Makefile.old
else
perl:
endif
else
perl:
endif

-include $(top_srcdir)/git.mk
