--- imach/src/Makefile	2015/03/10 20:35:56	1.56
+++ imach/src/Makefile	2018/04/20 17:18:27	1.82
@@ -1,26 +1,36 @@
-VERSION=0.98q0
-COPYRIGHT=Copyright (C)  2002-2015 INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121, Intel Software 2015)
-#IMACHSETUPVERSION=ilc64
-IMACHSETUPVERSION=mvc
+#Version has to be set in ../CMakeLists.txt too.
+#VERSION=0.98r2
+#VERSION=$(shell echo `grep IMACH_VERSION__ version.h | echo 'titi'`)
+VERSION=$(shell echo `grep IMACH_VERSION__ version.h | awk 'BEGIN { FS = "[ \t\n\"]+" }  { print $$3 }'`)
+OSTYPE = $(shell echo $$OSTYPE)
+# DRIVEG is for VirtualBox Windows 64bit 
+DRIVEG=f:
+#DIRG is the corresponding build directory for Virtual Windows
+DIRG=\imach\cvs\imach\build
+COPYRIGHT=Copyright (C)  2002-2016 INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121) - Intel Software 2016-18
+IMACHSETUPVERSION=icl
+# This is for Windows only
+#IMACHSETUPVERSION=mvc
 
 #       Linux
 # make _linux=1 imachopt
 # make _linux=1 imach
-#
+# make _linux=1 imachrpm
+# cd to build/gnulinux ; cmake ../..; cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -D CPACK_RPM_SPEC_INSTALL_POST="/bin/true" -G RPM
 # make _linux32onosx=1 imachopt
 # make _linux64onosx=1 imachopt
 
 #       OS/X
+# make _macosx=1 imachdmg
 # make _intel64onosx=1 imachopt
 # make _intel32onosx=1 imachopt
 # make _intelUNBonosx=1 imachdmg # Not implemented (not useful)
 # make _macosx=1 imach
 # make _macosx=1 imachopt
-# make _macosx=1 imachdmg
 #  valgrind  --dsymutil=yes --leak-check=full --show-leak-kinds=all --track-origins=yes ~/Documents/imachcvs/imach/src/imach-1.129cvsmac radlc-1.129.imach
 
 #        Windows
-# make _windowsonosx=1 imachILC64-setup (touch setup.iss.in) #binary should have been compiled on Windows with cl
+# make _windowsonosx=1 imachICL-setup (touch setup.iss.in) #binary should have been compiled on Windows with Intel
 # make _windowsonosx=1 imachMVC-setup (touch setup.iss.in) #binary should have been compiled on Windows with cl
 # make _windowsonosx=1 imachMVC-noreg-setup
 #
@@ -43,7 +53,20 @@ IMACHSETUPVERSION=mvc
 #TESTFILE=$$HOME/Documents/Recherches/REVES/SAITO/Tokyo2014/adlc-test-mac/adecode-1.142c.imach
 #TESTFILE=$(HOME)/Documents/Recherches/REVES/carol/carol-june2014/educadlmwt24.imach
 #TESTFILE=$(HOME)/Documents/Recherches/REVES/Biaspar/biaspar-wopowell.imach
-TESTFILE=$(HOME)/Documents/Recherches/REVES/Biaspar/rbiaspar-098p.imach
+#TESTFILE=$(HOME)/Documents/Recherches/REVES/Biaspar/rbiaspar-098p.imach
+#TESTFILE=$(HOME)/Documents/Recherches/REVES/Aaron/brouard/results/COVARAITE_94/rmypar24pis1cov1-age.imach
+#TESTFILE=$(HOME)/Documents/Recherches/REVES/Flavia/rADL0w_V1V2b.imach
+#TESTFILE=$(HOME)/Documents/Recherches/REVES/Yao/rrtest3b.imach
+#TESTFILE=$(HOME)//Documents/Recherches/REVES/Flavia/Flavia-nov-2015/rtest3c.imach
+#TESTFILE=/mnt/tugault/Documents/Recherches/REVES/Yao/rhrs-yao-test-back.imach
+#TESTFILE=/mnt/tugault/Documents/Recherches/REVES/Flavia/Flavia-nov-2015/rtest3bb.imach
+#TESTFILE=$(HOME)/Documents/Recherches/REVES/Flavia/Flavia-nov-2015/rtest3bb.imach
+#TESTFILE=$(HOME)/Documents/Recherches/REVES/SAITO/saito-12-feb-2016/rHRS_relig_import_M_NB.imach
+#TESTFILE=$(HOME)/Documents/Recherches/REVES/Biaspar/biaspar-0.98r-powellf1f3linmnb-zeroes.imach
+#TESTFILE=$(HOME)/Documents/Recherches/REVES/Yao/Yao-19-jan-2016/r2V4V3V5.imach
+#TESTFILE=$(HOME)/Documents/Recherches/REVES/Yao/Yao-19-jan-2016/r2b4V4V3V5.imach
+TESTFILE=$(HOME)/Documents/Recherches/REVES/Yao/Yao-19-jan-2016/Vn1b.imach
+#TESTFILE=$(HOME)/Documents/Recherches/REVES/Yao/Yao-19-jan-2016/rrrV4V3V5-suite6.imach
 #TESTFILE=$(HOME)/Documents/Recherches/REVES/SAITO/Tokyo2014/adlc-test-mac/adecode-1.142c.imach
 #TESTFILE=$(HOME)/Documents/Recherches/REVES/SAITO/Tokyo2014/adlc_test_magei4/radlc_often.imach
 #CC= gcc -v
@@ -53,9 +76,11 @@ GCC= gcc
 ifdef _macosx
 # Mac OS/X version
 LFLAGS= -g -lm 
-CFLAGS= -g -DDEBUG 
+#CFLAGS= -g -DDEBUG 
+CFLAGS= -g 
 LFLAGSOPT= -O3 -lm 
 CFLAGSOPT= -O3 
+CP= cp
 CROSSCOMPILATION= -DCROSS=0
 UNIX2DOS= echo "Unix2dos " 
 DSYMUTIL= dsymutil
@@ -207,7 +232,8 @@ endif
 ifdef _linux
 #CFLAGS= -g -DUNIX -DDEBUGHESS
 #CFLAGS= -g -DDEBUG -DFIXMNBRAK
-CFLAGS= -g -DDEBUG 
+#CFLAGS= -g -DDEBUG 
+CFLAGS= -g
 LFLAGS= -g -lm
 IGSL= -I/usr/include/gsl
 LGSL= -lgsl -lgslcblas
@@ -232,7 +258,8 @@ TMPNOREGSETUPSCRIPT=noreg-setup.iss
 TMPSCRIPTIN=setup.iss.in
 APPLICATION=IMaCh
 APPNAME=$(APPLICATION)-$(VERSION)
-GNUPLOTVERSION=4.0
+APPCOMPILATIONMODE=$(IMACHSETUPVERSION)
+GNUPLOTVERSION=5.1
 LICENSE=Copying
 TMPSETUPEXE=imach-$(VERSION)-$(IMACHSETUPVERSION)-setup.exe
 TMPNOREGSETUPEXE=imach-$(VERSION)-$(IMACHSETUPVERSION)-noreg-setup.exe
@@ -244,6 +271,7 @@ setup.iss: setup.iss.in
 		s/@NOTINNOREG@//g; \
 		s/@NOREG@//g; \
 		s/@IMACHSETUPVERSION@/$(IMACHSETUPVERSION)/g; \
+		s/@APPCOMPILATIONMODE@/$(APPCOMPILATIONMODE)/g; \
 		s/@VERSION@/$(VERSION)/g; \
 		s/@GNUPLOTVERSION@/$(GNUPLOTVERSION)/g; \
 		s/@INFOBEFOREFILE@/$(INFOBEFOREFILE)/g; \
@@ -273,8 +301,8 @@ $(TMPNOREGSETUPSCRIPT): $(TMPSCRIPTIN)
 $(TMPSETUPEXE): $(TMPSETUPSCRIPT)
 	$(SETUPCOMP) /cc $(TMPSETUPSCRIPT)
 
-$(TMPNOREGSETUPEXE): $(TMPNOREGSETUPSCRIPT)
-	$(SETUPCOMP) /cc $(TMPNOREGSETUPSCRIPT)
+#$(TMPNOREGSETUPEXE): $(TMPNOREGSETUPSCRIPT)
+#	$(SETUPCOMP) /cc $(TMPNOREGSETUPSCRIPT)
 
 PARAM=mypar1
 
@@ -292,36 +320,87 @@ imachcyg-noreg-setup: imachcygopt.exe no
 	$(CP) imachcygopt.exe imach$(VERSION)-$(BINVERSION).exe
 	$(SETUPCOMP) /cc $(TMPNOREGSETUPSCRIPT)
 	cp Output/$(TMPNOREGSETUPEXE) imachcyg-noreg-setup
+# ICL compiler 64
+imachICL-build: imach.c
+	icl /GS /W3 /Zc:wchar_t /O2  /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "UNICODE" /Qipo /Zc:forScope  /MT imach.c 
+#/GS /W3 /Gy /Zc:wchar_t /Zi /O2 /Fd"x64\Release\vc120.pdb" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_LIB" /D "_UNICODE" /D "UNICODE" /Qipo /Zc:forScope /Oi /MT /Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /Qprof-dir "x64\Release\" /Fp"x64\Release\IMaCh-icl-x64-0.98q2.pch"
+#  /Users/nbrouard/Documents/imach/imach-gui/build/icl64/Release/imach.exe
+# both 32 and 64 executables should have been built on Windows with Intel compiler.
 
-imachILC64-setup: IMaCh-ilc64.exe setup.iss
+imachICL-setup: ../build/icl64/Release/IMaCh-$(VERSION).exe ../build/icl32/Release/IMaCh-$(VERSION).exe setup.iss ../distributions/windows/mybuildicl64.bat ../distributions/windows/mybuildicl32.bat setup.iss 
 	pwd
-	$(CP) IMaCh-ilc64.exe imach.exe
+	touch setup.iss.in
 	$(SETUPCOMP) /cc setup.iss
-	$(CP) Output/$(TMPSETUPEXE) imachILC64-setup
+	$(CP) Output/$(TMPSETUPEXE) imachICL-setup
 
-imachILC64-noreg-setup: IMaCh-ilc64.exe noreg-setup.iss
+# imachICL64-setup: IMaCh-icl64-$(VERSION).exe setup.iss
+# 	pwd
+# 	$(CP) IMaCh-icl64-$(VERSION).exe imach.exe
+# 	$(SETUPCOMP) /cc setup.iss
+# 	$(CP) Output/$(TMPSETUPEXE) imachICL64-setup
+
+imachICL64-noreg-setup: IMaCh-icl64-$(VERSION).exe noreg-setup.iss
 	touch setup.iss.in
-	$(CP) IMaCh-ilc64.exe imach.exe
 	$(SETUPCOMP) /cc $(TMPNOREGSETUPSCRIPT)
-	$(CP) Output/$(TMPSETUPEXE) imachILC64-noreg-setup
+	$(CP) Output/$(TMPSETUPEXE) imachICL64-noreg-setup
 
-imachILC32-setup: IMaCh-ilc32-XP.exe setup.iss
-	touch setup.iss.in
-	$(CP) IMaCh-ilc32.exe imach.exe
-	$(SETUPCOMP) /cc setup.iss
-	$(CP) Output/$(TMPSETUPEXE) imachILC32-setup
+../build/icl64/Release/IMaCh-$(VERSION).exe: imach.c ../distributions/windows/mybuildicl64.bat
+	rm -rf ../build/icl64  && mkdir ../build/icl64
+	cp ../distributions/windows/mybuildicl64.bat ../build/icl64/
+	cd ../build/icl64
+	VBoxManage --nologo guestcontrol "Windows7-64" run --exe "C:\Windows\System32\cmd.exe" \
+ --username brouard  --verbose --wait-stdout  --wait-stderr -- "C:\Windows\SysWOW64\cmd.exe" "/c" "$(DRIVEG)$(DIRG)\icl64\mybuildicl64.bat" "$(VERSION)" "$(DRIVEG)" "$(DIRG)"
+
+#       VBoxManage --nologo guestcontrol "Windows7-64" run --exe "c:\\windows\\system32\\ipconfig.exe" --username brouard  --verbose  --wait-stdout  --wait-stderr -- "/all"
+#       VBoxManage --nologo guestcontrol "Windows7-64" run --exe "C:\Windows\SysWOW64\cmd.exe" --username brouard  --verbose  --wait-stdout  --wait-stderr -- "/c" "DIR"
+
+#	VBoxManage --nologo guestcontrol "Windows7-64" run --exe "C:\Windows\SysWOW64\cmd.exe" --username brouard  --verbose  --wait-stdout  --wait-stderr -- "/c" "DIR" 
+#	VBoxManage --nologo guestcontrol "Windows7-64" run --exe "c:\\windows\\system32\\ipconfig.exe" --username brouard  --verbose  --wait-stdout  --wait-stderr -- "/all"
+#VBoxManage --nologo guestcontrol "Windows7-64" run --exe "C:\Windows\SysWOW64\cmd.exe" \
+#	--username brouard  --verbose  --wait-stdout  --wait-stderr -- "/c" "$(DRIVEG)$(DIRG)\icl64\mybuildicl64.bat" "$(VERSION)" "$(DRIVEG)" "$(DIRG)"
+
+../build/icl32/Release/IMaCh-$(VERSION).exe: imach.c ../distributions/windows/mybuildicl32.bat
+	rm -rf ../build/icl32 && mkdir -p ../build/icl32
+	cp ../distributions/windows/mybuildicl32.bat ../build/icl32/
+	cd ../build/icl32
+	VBoxManage --nologo guestcontrol "Windows7-64" run --exe "C:\Windows\System32\cmd.exe" \
+  --username brouard  --verbose --wait-stdout -- "C:\Windows\SysWOW64\cmd.exe" "/c" "$(DRIVEG)$(DIRG)\icl32\mybuildicl32.bat" "$(VERSION)" "$(DRIVEG)" "$(DIRG)"
+
+#VBoxManage --nologo guestcontrol "Windows7-64" run --exe "C:\Windows\SysWOW64\cmd.exe" \
+# --username brouard  --verbose  --wait-stdout -- "/c" "$(DRIVEG)$(DIRG)\icl32\mybuildicl32.bat" "$(VERSION)" "$(DRIVEG)" "$(DIRG)"
+
+../build/vs32/Release/IMaCh-$(VERSION).exe: imach.c mybuildvs32.bat
+	rm -rf ../build/vs32 && mkdir -p ../build/vs32
+	cp mybuildvs32.bat ../build/vs32/
+	cd ../build/vs32
+	VBoxManage --nologo guestcontrol "Windows7-64" run --exe "C:\Windows\System32\cmd.exe" \
+	--username brouard  --verbose  --wait-stdout --  "C:\Windows\SysWOW64\cmd.exe" "/c" "g:\imach\imach-gui\build\vs32\mybuildvs32.bat" "$(VERSION)"
+# C:\Windows\SysWOW64\cmd.exe /E:ON /V:ON /K "g:\imach\imach-gui\build\icl32\mybuild.bat"
+#WORK	--username brouard  --verbose --wait-exit --wait-stdout -- "/c" "c:\users\brouard\mybuild.bat"
+#	--username brouard  --verbose --wait-exit --wait-stdout -- "/c" "g: && cd \imach\imach-gui\build\icl32 && mybuild.bat"
+#	--username brouard  --verbose --wait-exit --wait-stdout -- "/c" "g: && cd \imach\imach-gui\build\icl32-xp  &&" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat" "&&" "C:\Program Files (x86)\Intel\Composer XE 2015\bin\ipsxe-comp-vars.bat" "ia32" "vs2013" "&&" "msbuild imach-0.98q3.vcxproj /t:Build /p:Configuration=Release"
+#	--username brouard --wait-exit --wait-stdout -- "/c" "g: && cd \imach\imach-gui\build\icl32-xp\ &&C:\Windows\SysWOW64\cmd.exe /E:ON /V:ON /K ""C:\Program Files (x86)\Intel\Composer XE 2015\bin\ipsxe-comp-vars.bat" ia32 vs2013"&& msbuild imach.vcxproj >c:\users\brouard\totog.txt"
+#		--username brouard --wait-exit --wait-stdout -- "/c" "g: && dir >c:\users\brouard\totog.txt"
+#C:\Windows\SysWOW64\cmd.exe /E:ON /V:ON /K ""C:\Program Files (x86)\Intel\Composer XE 2015\bin\ipsxe-comp-vars.bat" ia32 vs2013"
+#C:\Windows\SysWOW64\cmd.exe /E:ON /V:ON /K ""C:\Program Files (x86)\Intel\Composer XE 2015\bin\ipsxe-comp-vars.bat" intel64 vs2013"
+
+imachICL64-setup: ../build/icl64/Release/IMaCh-$(VERSION).exe setup.iss mybuildicl64.bat
+
+imachICL32-setup: ../build/icl32/Release/IMaCh-$(VERSION).exe setup.iss mybuildicl32.bat
+
+imachVS32-setup: ../build/vs32/Release/IMaCh-$(VERSION).exe setup.iss mybuildvs32.bat
 
-imachILC32-noreg-setup: IMaCh-ilc32.exe noreg-setup.iss
+imachICL32-noreg-setup: IMaCh-icl32.exe noreg-setup.iss
 	touch setup.iss.in
-	$(CP) IMaCh-ilc32.exe imach.exe
+	$(CP) IMaCh-icl32.exe imach.exe
 	$(SETUPCOMP) /cc $(TMPNOREGSETUPSCRIPT)
-	$(CP) Output/$(TMPSETUPEXE) imachILC32-noreg-setup
+	$(CP) Output/$(TMPSETUPEXE) imachICL32-noreg-setup
 
 imachMVC-setup: imachMVC.exe setup.iss
 	touch setup.iss.in
 	$(CP) imachMVC.exe imach.exe
 	$(SETUPCOMP) /cc setup.iss
-	$(CP) Output/$(TMPSETUPEXE) imachcyg-setup
+	$(CP) Output/$(TMPSETUPEXE) imachMVC-setup
 
 # imachcyg-noreg-setup : imachcygopt imachcygopt.o setup.iss.in noreg-setup.iss $(TMPNOREGSETUPEXE)
 imachMVC-noreg-setup: imachMVC.exe noreg-setup.iss
@@ -348,10 +427,154 @@ ifdef _macosx
 endif
 
 imach.o : imach.c 
-	 $(CC) $(CFLAGS) $(CROSSCOMPILATION) -DDEBUGBRENT -c imach.c
+	 $(CC) $(CFLAGS) $(CROSSCOMPILATION)  -c $<
+#	 $(CC) $(CFLAGS) $(CROSSCOMPILATION)  -DDEBUGMEM -c $<
+#	 $(CC) $(CFLAGS) $(CROSSCOMPILATION) -DDEBUGBRENT -c imach.c
+
+imach-0.98r: imach-0.98r.o 
+	$(CC) $(LFLAGS) -o $@ $<
+ifdef _macosx
+	$(DSYMUTIL) $@
+endif
+
+# Horrible no f3<f1 test and direct test,  converges if close to maximum otherwise diverges
+#calls = 13 & 1760, -2 Log likelihood = 46537.411806825585
+imach-0.98r.o : imach-0.98r.c 
+	 $(CC) $(CFLAGS) -DPOWELLNOF3INFF1TEST -DUNKNOWNSTATUSNOTCONTRIBUTING  -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE $(CROSSCOMPILATION)  -c $<
+
+#################
+imach-0.98r-powellsf1f3: imach-0.98r-powellsf1f3.o 
+	$(CC) $(LFLAGS) -o $@ $<
+ifdef _macosx
+	$(DSYMUTIL) $@
+endif
+
+# test f3<f1 but direct test and no powell criteria which are NOPOWELLORIGINALNOMNBAKORIGINAL NOLINMINORIGINAL
+# diverges now from zeroes calls = 18 & 3163, -2 Log likelihood = 50929.075310962719
+# but converges if close to the maximum
+# calls = 13 & 1760, -2 Log likelihood = 46537.411806825585
+imach-0.98r-powellsf1f3.o : imach-0.98r.c 
+	 $(CC) $(CFLAGS)  -DUNKNOWNSTATUSNOTCONTRIBUTING  -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE  $(CROSSCOMPILATION) -o $@  -c $<
+#	 $(CC) $(CFLAGS)  -DUNKNOWNSTATUSNOTCONTRIBUTING  -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE  $(CROSSCOMPILATION) -E -c $< | cppbeauty
+
+######
+imach-0.98r-powellf1f3: imach-0.98r-powellf1f3.o 
+	$(CC) $(LFLAGS) -o $@ $<
+ifdef _macosx
+	$(DSYMUTIL) $@
+endif
+
+#Powell original but with mnbrak fix  -DUNKNOWNSTATUSNOTCONTRIBUTING -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE
+#diverges from zeroes
+# calls = 13 & 1760, -2 Log likelihood = 46537.411806825585 Real minumum
+imach-0.98r-powellf1f3.o : imach-0.98r.c 
+	 $(CC) $(CFLAGS) -DPOWELLORIGINAL -DLINMINORIGINAL -DUNKNOWNSTATUSNOTCONTRIBUTING  -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE $(CROSSCOMPILATION) -o $@  -c $<
+imach-0.98r-powellf1f3.i : imach-0.98r.c 
+	 $(CC) $(CFLAGS) -DPOWELLORIGINAL -DLINMINORIGINAL -DUNKNOWNSTATUSNOTCONTRIBUTING  -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE $(CROSSCOMPILATION) -E   -c $<| cppbeauty
+#	 $(CC) $(CFLAGS) -DPOWELLORIGINAL -DLINMINORIGINAL  $(CROSSCOMPILATION) -E -o $@  -c $<
+
+######################
+imach-0.98r-powell: imach-0.98r-powell.o 
+	$(CC) $(LFLAGS) -o $@ $<
+ifdef _macosx
+	$(DSYMUTIL) $@
+endif
+
+# Powell original means without -DPOWELLNOF3INFF1TEST (with F3<F1 test) 
+#calls = 33 & 4088, -2 Log likelihood = 46623.239341985027 reaches the maximum !
+#From zeroes doesn't reach the maximum calls = 34 & 4212, -2 Log likelihood = 46542.398769900567
+#calls = 34 & 4212, -2 Log likelihood = 46542.398769900567
+imach-0.98r-powell.o : imach-0.98r.c 
+	 $(CC) $(CFLAGS) -DPOWELLORIGINAL -DLINMINORIGINAL -DMNBRAKORIGINAL  -DUNKNOWNSTATUSNOTCONTRIBUTING  -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE $(CROSSCOMPILATION) -o $@  -c $<
+#	 $(CC) $(CFLAGS) -DPOWELLORIGINAL -DLINMINORIGINAL -DMNBRAKORIGINAL $(CROSSCOMPILATION) -E  -c $< | cppbeauty
+
+imach-0.98r-powell.i : imach-0.98r.c 
+	 $(CC) $(CFLAGS) -DPOWELLORIGINAL -DLINMINORIGINAL -DMNBRAKORIGINAL $(CROSSCOMPILATION) -E -o $@ -c $< 
+
+###############
+# powell test with f1f3 powell, linmin fix but no mnbrak fix
+imach-0.98r-powellf1f3lin: imach-0.98r-powellf1f3lin.o 
+	$(CC) $(LFLAGS) -o $@ $<
+ifdef _macosx
+	$(DSYMUTIL) $@
+endif
+
+# ?calls = 41 & 4718, -2 Log likelihood = 46690.242656475864
+#calls = 33 & 4088, -2 Log likelihood = 46623.239341985027
+# from zeroes calls = 34 & 4212, -2 Log likelihood = 46542.398769900567
+imach-0.98r-powellf1f3lin.o : imach-0.98r.c 
+	 $(CC) $(CFLAGS) -DPOWELLORIGINAL -DMNBRAKORIGINAL  -DUNKNOWNSTATUSNOTCONTRIBUTING  -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE $(CROSSCOMPILATION) -o $@  -c $<
+
+#############
+
+
+# directest with f3<f1 without mnbrak fix but linmin fix
+imach-0.98r-powellf1f3orilin: imach-0.98r-powellf1f3orilin.o 
+	$(CC) $(LFLAGS) -o $@ $<
+ifdef _macosx
+	$(DSYMUTIL) $@
+endif
+
+#Maximum not reached but converge from zeroes
+#calls = 34 & 4212, -2 Log likelihood = 46542.398769900567
+imach-0.98r-powellf1f3orilin.o : imach-0.98r.c 
+	 $(CC) $(CFLAGS)  -DMNBRAKORIGINAL -DUNKNOWNSTATUSNOTCONTRIBUTING  -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE $(CROSSCOMPILATION) -o $@  -c $<
+
+#######
+
+# Powell test not direct, with mnbrak and linmin fixes
+imach-0.98r-powellf1f3linmnb: imach-0.98r-powellf1f3linmnb.o 
+	$(CC) $(LFLAGS) -o $@ $<
+ifdef _macosx
+	$(DSYMUTIL) $@
+endif
+
+# worst, diverges from zeroes -DDEBUGMNBRAK
+#calls = 18 & 3163, -2 Log likelihood = 50929.075310962719
+
+imach-0.98r-powellf1f3linmnb.o : imach-0.98r.c 
+	 $(CC) $(CFLAGS) -DDEBUG -DPOWELLORIGINAL -DUNKNOWNSTATUSNOTCONTRIBUTING  -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE $(CROSSCOMPILATION) -o $@  -c $<
+imach-0.98r-powellf1f3linmnb.i : imach-0.98r.c 
+	 $(CC) $(CFLAGS) -DDEBUG -DPOWELLORIGINAL -DUNKNOWNSTATUSNOTCONTRIBUTING  -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE $(CROSSCOMPILATION) -E -c $< | cppbeauty
+#########
+
+# Powell test not direct, with mnbrak and linmin fixes
+imach-0.98r-powellf1f3linmnbiter: imach-0.98r-powellf1f3linmnbiter.o 
+	$(CC) $(LFLAGS) -o $@ $<
+ifdef _macosx
+	$(DSYMUTIL) $@
+endif
+
+#
+#
+
+imach-0.98r-powellf1f3linmnbiter.o : imach-0.98r.c 
+	 $(CC) $(CFLAGS) -DDEBUG -DPOWELLORIGINAL -DUNKNOWNSTATUSNOTCONTRIBUTING  -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE -DNODIRECTIONCHANGEDUNTILNITER $(CROSSCOMPILATION) -o $@  -c $<
+imach-0.98r-powellf1f3linmnbiter.i : imach-0.98r.c 
+	 $(CC) $(CFLAGS) -DDEBUG -DPOWELLORIGINAL -DUNKNOWNSTATUSNOTCONTRIBUTING  -DDISPATCHINGKNOWNDEATHAFTERLASTWAVE -DNODIRECTIONCHANGEDUNTILNITER $(CROSSCOMPILATION) -E -c $< | cppbeauty
+#########
+
+
+imach-0.98r-powellf1f3ori: imach-0.98r-powellf1f3ori.o 
+	$(CC) $(LFLAGS) -o $@ $<
+ifdef _macosx
+	$(DSYMUTIL) $@
+endif
+
+# Powell  with -DPOWELLNOF3INFF1TEST which is not Powell original!
+#calls = 41 & 4718, -2 Log likelihood = 46690.242656475864, doesn't reach the maximum
+imach-0.98r-powellf1f3ori.o : imach-0.98r.c 
+	 $(CC) $(CFLAGS) -DPOWELLNOF3INFF1TEST -DPOWELLORIGINAL -DLINMINORIGINAL -DMNBRAKORIGINAL $(CROSSCOMPILATION) -o $@  -c $< 
+imach-0.98r-powellf1f3ori.i : imach-0.98r.c 
+	 $(CC) $(CFLAGS) -DPOWELLNOF3INFF1TEST -DPOWELLORIGINAL -DLINMINORIGINAL -DMNBRAKORIGINAL $(CROSSCOMPILATION) -E -o $@  -c $<| cppbeauty
+
+
+
+
+
 
 imachtest.o : imach.c 
-	 $(CC) $(CFLAGS) $(CROSSCOMPILATION) -DPOWELLORIGINAL -DNRCORIGINAL -DINFINITYORIGINAL -DDEBUGBRENT -o imachtest.o -c imach.c
+	 $(CC) $(CFLAGS) $(CROSSCOMPILATION) -DPOWELLORIGINAL -DNRCORIGINAL -DINFINITYORIGINAL -DDEBUGBRENT -o $@ -c $<
 
 #	 $(CC) $(CFLAGS) $(CROSSCOMPILATION)  -DFIXMNBRAK -o imachtest.o -c imach.c
 
@@ -404,49 +627,81 @@ ifdef _linux64onosx
 	(cd .. && $(TAR) jcvf src/Output/imach-Linux-$(VERSION)-$(BINVERSION).tar.bz2 bin html/doc/biaspar.imach html/doc/data1.txt)
 endif
 
-imachopt.o : imach.c
+imachopt.o : imach.c version.h
 	$(CC) $(CFLAGSOPT) $(CROSSCOMPILATION) -o imachopt.o -c imach.c
 #	$(CC) $(CFLAGSOPT) -DPOWELL -o imachopt.o -c imach.c
 
 imachUB : imach32 imach64
 	lipo -create -arch i386 imach_32 -arch x86_64 imach_64 -output imach$(VERSION)
 
+imachrpm : imachopt.o 
+	pwd
+	(cd ../build && rm -r gnulinux && mkdir gnulinux && cd gnulinux ;\
+	pwd ;\
+	cmake ../..;\
+	cmake --build . ; \
+	echo $(OSTYPE);\
+	cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -D CPACK_RPM_SPEC_INSTALL_POST="/bin/true" -G RPM;\
+	cp  imach-$(VERSION)-*.rpm ../../src/Output/ ;)
 
 #imachdmg : imachopt.o create-dmg applet IMaChInfo.plist.in IMaChPkgInfo.in IMaCh.icns main.scpt.in IMaCh-ecrandemarrage.rsrc TXT.rtf
-imachdmg : imachopt.o create-dmg applet IMaChInfo.plist.in IMaChPkgInfo.in IMaCh.icns main.scpt.in IMaCh-ecrandemarrage.rsrc TXT.rtf
-	$(CC) $(LFLAGSOPT) -o imach imachopt.o
+#	$(CC) $(LFLAGSOPT) -o imach imachopt.o
 	#hdiutil detach /Volumes/IMaCh\ $(VERSION)
-	rm -rf imach$(VERSION).app
-	mkdir -p imach$(VERSION).app
-	mkdir -p imach$(VERSION).app/Contents
-	mkdir -p imach$(VERSION).app/Contents/MacOS
-	cp applet imach$(VERSION).app/Contents/MacOS
-	mkdir -p imach$(VERSION).app/Contents/Resources
-	mkdir -p imach$(VERSION).app/Contents/Resources/Scripts
-	mkdir -p imach$(VERSION).app/Contents/Resources/bin
-	mkdir -p imach$(VERSION).app/Contents/Resources/html
-	cp imach imach$(VERSION).app/Contents/Resources/bin
-	cp gnuplot_bin/gnuplot_2_6_5_OSX imach$(VERSION).app/Contents/Resources/bin/gnuplot
-	mkdir -p imach$(VERSION).app/Contents/Resources/description.rtfd
-	cp -p TXT.rtf imach$(VERSION).app/Contents/Resources/description.rtfd
-	$(SED) -e "s/@VERSION@/$(VERSION)/g;" \
-	IMaChInfo.plist.in  >imach$(VERSION).app/Contents/Info.plist
-	cp -p IMaChPkgInfo.in  imach$(VERSION).app/Contents/PkgInfo
-	cp -p IMaCh.icns  imach$(VERSION).app/Contents/Resources/applet.icns
-	cp -r -p main.scpt.in imach$(VERSION).app/Contents/Resources/Scripts/main.scpt
-	cp IMaCH-ecrandemarrage.rsrc imach$(VERSION).app/Contents/Resources/applet.rsrc
-	cp ../html/doc/data1.txt  imach$(VERSION).app/Contents/Resources/html
-	cp ../html/doc/biaspar.log  imach$(VERSION).app/Contents/Resources/html
-	cp ../html/doc/biaspar.imach  imach$(VERSION).app/Contents/Resources/html
-	rm -f imach$(VERSION).dmg
-	./createdmg3.sh --volname "IMaCh $(VERSION)" imach$(VERSION).dmg imach$(VERSION)
-	mv  imach$(VERSION).dmg Output/
-#	./create-dmg --volname "IMaCh $(VERSION)" imach$(VERSION).dmg imach$(VERSION).app
+#	cp ../../distributions/osx/gnuplot_bin/gnuplot_2_6_5_OSX imach$(VERSION).app/Contents/Resources/bin/gnuplot;\
+
+imachdmg : imachopt.o ../distributions/osx/create-dmg ../distributions/osx/createdmg4.sh ../distributions/osx/IMaChInfo.plist.in ../distributions/osx/IMaChPkgInfo.in ../distributions/osx/IMaCh.icns  ../distributions/osx/TXT.rtf
+	pwd
+	(cd ../build && rm -r osx && mkdir osx && cd osx ;\
+	pwd ;\
+	cmake ../..;\
+	cmake --build . ; \
+	echo $(OSTYPE);\
+	rm -rf imach$(VERSION).app;\
+	mkdir -p imach$(VERSION).app;\
+	mkdir -p imach$(VERSION).app/Contents;\
+	mkdir -p imach$(VERSION).app/Contents/MacOS;\
+	cp ../../distributions/osx/imach imach$(VERSION).app/Contents/MacOS;\
+	mkdir -p imach$(VERSION).app/Contents/Resources;\
+	mkdir -p imach$(VERSION).app/Contents/Resources/Scripts;\
+	mkdir -p imach$(VERSION).app/Contents/Resources/bin;\
+	mkdir -p imach$(VERSION).app/Contents/Resources/lib;\
+	mkdir -p imach$(VERSION).app/Contents/Resources/doc;\
+	cp IMaCh-$(VERSION) imach$(VERSION).app/Contents/Resources/bin/imach;\
+	cp ../../distributions/osx/gnuplot_bin/bin/gnuplot imach$(VERSION).app/Contents/Resources/bin/gnuplot;\
+	cp ../../distributions/osx/gnuplot_bin/lib/* imach$(VERSION).app/Contents/Resources/lib;\
+	mkdir -p imach$(VERSION).app/Contents/Resources/description.rtfd;\
+	cp -p ../../distributions/osx/TXT.rtf imach$(VERSION).app/Contents/Resources/description.rtfd ;\
+	$(SED) -e "s/@VERSION@/$(VERSION)/g;" ../../distributions/osx/IMaChInfo.plist.in  >imach$(VERSION).app/Contents/Info.plist ;\
+	cp -p ../../distributions/osx/IMaChPkgInfo.in  imach$(VERSION).app/Contents/PkgInfo ;\
+	cp -p ../../distributions/osx/IMaCh.icns  imach$(VERSION).app/Contents/Resources/IMaCh.icns ;\
+	cp ../../html/doc/data1.txt  imach$(VERSION).app/Contents/Resources/doc ;\
+	cp ../../html/doc/biaspar.log  imach$(VERSION).app/Contents/Resources/doc ;\
+	cp ../../html/doc/biaspar.imach  imach$(VERSION).app/Contents/Resources/doc ;\
+	cp ../../src/README.txt  imach$(VERSION).app/Contents/Resources/doc ;\
+	rm -f imach$(VERSION).dmg ;\
+	pwd ;\
+	cp ../../distributions/osx/createdmg4.sh . ;\
+	cp ../../distributions/osx/Background.png .;\
+	pwd ;\
+	./createdmg4.sh  --volname "IMaCh $(VERSION)" imach$(VERSION).dmg imach$(VERSION) ;\
+	cp  imach$(VERSION).dmg ../../src/Output/ ;)
+#	./create-dmg --volname "IMaCh $(VERSION)" imach$(VERSION).dmg imach$(VERSION).app 
 #	./createdmg2.sh --volname "IMaCh $(VERSION)" imach$(VERSION).dmg imach$(VERSION)
 
-upload:
+md5:
 	ls Output/* | xargs md5sum
-	rsync -v Output/* brouard@henry.ined.fr:/home/euroreves/html/imach/
+upload:
+#	rsync -v Output/imach-0.98r4-1.x86_64.rpm brouard@henry.ined.fr:/home/euroreves/html/imach/Download
+#	rsync -v Output/IMaCh-0.99a3-icl-setup.exe brouard@henry.ined.fr:/home/euroreves/html/imach/Download
+#	rsync -v Output/imach0.99a3.dmg brouard@henry.ined.fr:/home/euroreves/html/imach/Download
+#	rsync -v Output/IMaCh-0.98r7-icl-setup.exe brouard@henry.ined.fr:/home/euroreves/html/imach/Download
+#	rsync -v Output/imach0.98r7.dmg brouard@henry.ined.fr:/home/euroreves/html/imach/Download
+#	rsync -v Output/imach-0.99r9-icl-setup.exe brouard@henry.ined.fr:/home/euroreves/html/imach/Download
+#	rsync -v Output/imach0.99r9.dmg brouard@henry.ined.fr:/home/euroreves/html/imach/Download
+	rsync -v Output/imach-0.99r16-icl-setup.exe brouard@henry.ined.fr:/home/euroreves/html/imach/Download
+	rsync -v Output/imach0.99r16.dmg brouard@henry.ined.fr:/home/euroreves/html/imach/Download
+#	rsync -v Output/imach0.99r12-1.x86_64.rpm brouard@henry.ined.fr:/home/euroreves/html/imach/Download
+#	rsync -v Output/* brouard@henry.ined.fr:/home/euroreves/html/imach/Download
 
 imachcyg : imachcyg.o
 	$(CC) $(LFLAGS) -o imach imachcyg.o
@@ -463,8 +718,14 @@ imach.exe : imachw32.o
 	i386-mingw32-gcc  -mwindows -o imach.exe -lm imachw32.o
 	i386-mingw32-strip imach.exe
 
+valgrindtoto: valgrindtoto.c
+	gcc -o valgrindtoto -DCROSS=0 -g valgrindtoto.c
+valgrindtototest: valgrindtoto
+	valgrind  --dsymutil=yes --leak-check=full --show-leak-kinds=all --track-origins=yes ./valgrindtoto
+
 valgrind-test :  imach $(TESTFILE) 
 	valgrind  --dsymutil=yes --leak-check=full --show-leak-kinds=all --track-origins=yes ./imach $(TESTFILE)
+#	valgrind  --dsymutil=yes --leak-check=full --show-leak-kinds=all --track-origins=yes ./imach-0.98r-powellf1f3linmnb $(TESTFILE)
 test:  imach $(TESTFILE) 
 	gdb ./imach $(TESTFILE)