all: omoptim

.PHONY: omoptim omoptimbasis paradiseo

prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@

ifeq (@APP@,)
install:
	mkdir -p ${DESTDIR}/@bindir@
	cp -a OMOptim/bin/OMOptim@EXE@ ${DESTDIR}/@bindir@
else
install:
	mkdir -p ${DESTDIR}/Applications/
	cp -a OMOptim/bin/OMOptim@APP@ ${DESTDIR}/Applications/
endif

mkbuilddirs:
ifeq (@APP@,)
	mkdir -p @OMBUILDDIR@/@bindir@
else
	mkdir -p @OMBUILDDIR@/Applications
endif

PARADISEO=ParadisEO-2.0.1/build

$(PARADISEO)/Makefile: Makefile
	mkdir -p $(PARADISEO)
	(cd $(PARADISEO) && CC="@CC@" CXX="@CXX@" CFLAGS="@CFLAGS@" CPPFLAGS="@CPPFLAGS@" CXXFLAGS="@CXXFLAGS@" cmake ..)

paradiseo: $(PARADISEO)/Makefile
	$(MAKE) -C $(PARADISEO) VERBOSE=1
omoptim: omoptimbasis paradiseo mkbuilddirs
	$(MAKE) -C OMOptim/build -f Makefile.unix
ifeq (@APP@,)
	cp -a OMOptim/bin/OMOptim@EXE@ @OMBUILDDIR@/bin
else
	cp -a OMOptim/bin/OMOptim@APP@ @OMBUILDDIR@/Applications/
endif

omoptimbasis:
	$(MAKE) -C OMOptimBasis/build -f Makefile.unix
clean:
	$(MAKE) -C OMOptimBasis/build -f Makefile.unix clean
	$(MAKE) -C OMOptim/build -f Makefile.unix clean
	test ! -d $(PARADISEO) || rm -r $(PARADISEO)
distclean: clean
	rm -f config.status configure Makefile OMOptim/build/Makefile.unix OMOptim/build/OMOptim.config OMOptimBasis/build/Makefile.unix OMOptimBasis/build/OMOptimBasis.config OMOptim/Core/OMC/omc_config.h
Makefile: Makefile.in config.status
	./config.status
config.status: configure
	./config.status -recheck
configure: configure.ac common/m4/*.m4
	autoconf
