Commit 2e40bee2 authored by Erwan Jahier's avatar Erwan Jahier

More code regorganisation and Makefile cleanning.

parent 70a2023a
......@@ -4,8 +4,11 @@
#
# A modifier si ncessaire !!!
LURETTE_PATH = $(HOME)/lurette
# XXX HOSTTYPE doit etre defini !!
ifeq ($(HOST_TYPE),win32)
OCAML_LIB="c:\TEMP\ocaml\lib"
OCAMLOPT = /cygdrive/c/TEMP/ocaml/bin/ocamlopt
......
......@@ -4,8 +4,8 @@ VERSION:="1.50"
SHA:=`git log -1 --pretty=format:"%h"`
gen_version:
rm -f source/version.ml
echo "let str=\"$(VERSION)\"" > source/version.ml
echo "let sha=\"$(SHA)\"" >> source/version.ml
echo "let str=\"$(VERSION)\"" > source/common/version.ml
echo "let sha=\"$(SHA)\"" >> source/common/version.ml
rm -f version.tex
date +VERSION_DATE=%d-%m-%y > version.tex
echo "\\newcommand{\\version}{$(VERSION)}" > version.tex
......
......@@ -6,7 +6,7 @@ USE_CAMLP4 = yes
LIBS = str unix
SOURCES = ../genlex.ml gnuplot-rif.ml
SOURCES = ../common/genlex.ml gnuplot-rif.ml
RESULT = gnuplot-rif
......
......@@ -7,7 +7,7 @@ OCAMLNCFLAGS = -inline 10
ifndef OCAMLFLAGS
OCAMLFLAGS := -noassert -unsafe
endif
OCAMLFLAGS += -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
OCAMLFLAGS += -I ../common -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
IDLFLAGS=-nocpp
......@@ -36,7 +36,7 @@ USE_CAMLP4 = yes
HERE=$(LURETTE_PATH)/source/
HERE=.
THERE=..
THERE=../common
SOURCES_C = \
$(THERE)/liblutin_c.c \
......
......@@ -9,7 +9,7 @@ OCAMLNCFLAGS = -inline 10
ifndef OCAMLFLAGS
OCAMLFLAGS := -noassert -unsafe
endif
OCAMLFLAGS += -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
OCAMLFLAGS += -I ../common -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
IDLFLAGS=-nocpp
......@@ -36,7 +36,7 @@ CLIBS = camlidl $(CLIBS_WIN32) bdd_stubs
USE_CAMLP4 = yes
HERE=.
THERE=..
THERE=../common
......
......@@ -7,7 +7,7 @@ OCAMLNCFLAGS = -inline 10
ifndef OCAMLFLAGS
OCAMLFLAGS := -noassert -unsafe
endif
OCAMLFLAGS += -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
OCAMLFLAGS += -I ../common -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
IDLFLAGS=-nocpp
......@@ -35,7 +35,7 @@ USE_CAMLP4 = yes
HERE=$(LURETTE_PATH)/source/
HERE=.
THERE=..
THERE=../common
SOURCES_C = \
......
......@@ -44,7 +44,7 @@ USE_CAMLP4 = yes
HERE=$(LURETTE_PATH)/source/
HERE=.
THERE=..
THERE=../common
SOURCES_C = \
$(THERE)/Ezdl_c.c $(THERE)/liblutin_c.c $(THERE)/liblutin.idl \
......
......@@ -35,7 +35,7 @@ CLIBS = bdd_stubs bdd camlidl gmp stdc++ polkag_caml polkag
USE_CAMLP4 = yes
HERE=.
THERE=..
THERE=../common
SOURCES_OCAML = \
......
......@@ -13,7 +13,7 @@ OCAMLNCFLAGS = -inline 10
ifndef OCAMLFLAGS
OCAMLFLAGS := -noassert -unsafe
endif
OCAMLFLAGS += -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
OCAMLFLAGS += -I ../common -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
IDLFLAGS=-nocpp
......@@ -41,7 +41,7 @@ USE_CAMLP4 = yes
HERE=.
THERE=..
THERE=../common
SOURCES_C = \
......@@ -123,7 +123,7 @@ SOURCES_OCAML0:= \
$(THERE)/rif.mli \
$(THERE)/rif.ml \
$(HERE)/luc_exe.mli \
$(HERE)/luc_exe.ml \
$(HERE)/luc_exe.ml
ifdef MLONLY
......
......@@ -11,7 +11,7 @@ OCAMLNCFLAGS = -inline 10
ifndef OCAMLFLAGS
OCAMLFLAGS := -noassert -unsafe
endif
OCAMLFLAGS += -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
OCAMLFLAGS += -I ../common -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
IDLFLAGS=-nocpp
......@@ -37,9 +37,8 @@ CLIBS = camlidl $(CLIBS_WIN32) bdd_stubs
USE_CAMLP4 = yes
HERE=$(LURETTE_PATH)/source/
HERE=.
THERE=..
THERE=../common
SOURCES_C = \
$(THERE)/liblutin_c.c \
......
......@@ -19,7 +19,7 @@ endif
USE_CAMLP4 = yes
THERE=..
THERE=../common
HERE=.
......@@ -30,9 +30,6 @@ SOURCES = \
RESULT = ./lurettetop_exe
v:
ocamlc.opt -v
OCAMLMAKEFILE = ../../OcamlMakefile
-include $(OCAMLMAKEFILE)
......@@ -13,7 +13,7 @@ OCAMLNCFLAGS = -inline 10
ifndef OCAMLFLAGS
OCAMLFLAGS := -noassert -unsafe
endif
OCAMLFLAGS += -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
OCAMLFLAGS += -I ../common -I $(OCAMLLIB) -I $(PREFIX)/$(HOSTTYPE)/lib
IDLFLAGS=-nocpp
......@@ -38,7 +38,7 @@ CLIBS = camlidl $(CLIBS_WIN32) bdd_stubs
ZELANG=lut
LURETTEDIR=..
LURETTEDIR=../common
LUTDIR=.
RESULT=lutin
......
This diff is collapsed.
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include "LibMathAdvanced.h"
/* Inverse hyperbolic cosine */
void AcoshR (real In, real * pOut)
{
*pOut = log( In +sqrt( ( In * In) - 1.0));
}
/* Inverse Cosine */
void AcosR (real In, real * pOut)
{
*pOut = acos(In);
}
/* Inverse hyperbolic sine */
/* The Result is slightly different from Simulink result
Difference is of kind E-13
(for big input (for example E4) diference is of kind E-8 ) */
void AsinhR (real In, real * pOut)
{
*pOut = log( In +sqrt( 1.0 + ( In * In)));
}
/* Inverse sine */
void AsinR (real In, real * pOut)
{
*pOut = asin(In);
}
/* Inverse hyperbolic tangent */
void AtanhR (real In, real * pOut)
{
*pOut = 0.5 * log( ( 1 + In) / ( 1 - In));
}
/* Inverse tangent */
void AtanR (real In, real * pOut)
{
*pOut = atan(In);
}
/* Four quadrant inverse tangent */
void Atan2R (real In1, real In2, real * pOut)
{
*pOut = atan2( In1, In2);
}
/* Hyperbolic cosine */
void CoshR (real In, real * pOut)
{
*pOut = cosh(In);
}
/* Cosine */
void CosR (real In, real * pOut)
{
*pOut = cos(In);
}
/* Exponential */
void ExpR(real In, real * pOut)
{
*pOut = exp( In );
}
/* Logarithm with base e */
void LnR(real In, real * pOut)
{
*pOut = log(In);
}
/* Logarithm with base 10 */
void LogR(real In, real * pOut)
{
*pOut = log10(In);
}
/* Power */
void PowR(real In, real Power, real * pOut)
{
assert(In>0 || (In=0 && Power>0));
*pOut = pow(In, Power);
}
/* Hyperbolic sine */
void SinhR (real In, real * pOut)
{
*pOut = sinh(In);
}
/* Sine */
void SinR (real In, real * pOut)
{
*pOut = sin(In);
}
/* Sqrt */
void SqrtR (real In, real * pOut)
{
*pOut = sqrt(In);
}
/* Tangent */
void TanR (real In, real * pOut)
{
*pOut = tan(In);
}
/* Hyperbolic tangent */
void TanhR (real In, real * pOut)
{
*pOut = tanh(In);
}
/* 10^x */
void TenPowR(real In, real * pOut)
{
*pOut = pow(10,In);
}
#
-include ../Makefile.common.source
-include ../../Makefile.common.source
OCAMLNCFLAGS = -inline 10
ifndef OCAMLFLAGS
......@@ -33,7 +33,6 @@ CLIBS = camlidl $(CLIBS_WIN32) bdd_stubs
USE_CAMLP4 = yes
HERE=$(LURETTE_PATH)/source/
HERE=./
SOURCES_C = \
......@@ -81,8 +80,8 @@ SOURCES_OCAML = \
$(HERE)/lexer.mll \
$(HERE)/gne.mli \
$(HERE)/gne.ml \
$(HERE)/Lucky/lucParse.mli \
$(HERE)/Lucky/lucParse.ml \
$(HERE)/../Lucky/lucParse.mli \
$(HERE)/../Lucky/lucParse.ml \
$(HERE)/polyhedron.mli \
$(HERE)/polyhedron.ml \
$(HERE)/formula_to_bdd.mli \
......@@ -97,12 +96,12 @@ SOURCES_OCAML = \
$(HERE)/fair_bddd.ml \
$(HERE)/solver.mli \
$(HERE)/solver.ml \
$(HERE)/Lucky/show_env.mli \
$(HERE)/Lucky/show_env.ml \
$(HERE)/../Lucky/show_env.mli \
$(HERE)/../Lucky/show_env.ml \
$(HERE)/prog.mli \
$(HERE)/prog.ml \
$(HERE)/Lucky/lucProg.mli \
$(HERE)/Lucky/lucProg.ml \
$(HERE)/../Lucky/lucProg.mli \
$(HERE)/../Lucky/lucProg.ml \
$(HERE)/fGen.mli \
$(HERE)/fGen.ml \
\
......@@ -138,5 +137,6 @@ SOURCES = $(SOURCES_C) $(SOURCES_OCAML)
RESULT = gen_stubs_exe
OCAMLMAKEFILE = ../../OcamlMakefile
-include $(OCAMLMAKEFILE)
......@@ -2,7 +2,7 @@
# Makefile for luckyDraw
#
-include ../Makefile.common.source
-include ../../Makefile.common.source
######################################################################
......@@ -40,7 +40,6 @@ CLIBS = bdd_stubs bdd camlidl gmp stdc++ polkag_caml polkag
USE_CAMLP4 = yes
HERE=$(LURETTE_PATH)/source/
HERE=.
......@@ -129,8 +128,8 @@ SOURCES_OCAML := \
$(HERE)/lexer.mll \
$(HERE)/gne.mli \
$(HERE)/gne.ml \
$(HERE)/Lucky/lucParse.mli \
$(HERE)/Lucky/lucParse.ml \
$(HERE)/../Lucky/lucParse.mli \
$(HERE)/../Lucky/lucParse.ml \
$(HERE)/polyhedron.mli \
$(HERE)/polyhedron.ml \
$(HERE)/formula_to_bdd.mli \
......@@ -145,12 +144,14 @@ SOURCES_OCAML := \
$(HERE)/fair_bddd.ml \
$(HERE)/solver.mli \
$(HERE)/solver.ml \
$(HERE)/Lucky/show_env.mli \
$(HERE)/Lucky/show_env.ml \
$(HERE)/../Lucky/show_env.mli \
$(HERE)/../Lucky/show_env.ml \
$(HERE)/prog.mli \
$(HERE)/prog.ml \
$(HERE)/Lucky/lucProg.mli \
$(HERE)/Lucky/lucProg.ml \
$(HERE)/../Lucky/lucProg.mli \
$(HERE)/../Lucky/lucProg.ml \
$(HERE)/fGen.mli \
$(HERE)/fGen.ml \
$(HERE)/print.mli \
$(HERE)/print.ml \
$(HERE)/lucky.mli \
......@@ -167,7 +168,7 @@ SOURCES = $(SOURCES_OCAML)
RESULT = luckyDraw
OCAMLMAKEFILE = ../OcamlMakefile
OCAMLMAKEFILE = ../../OcamlMakefile
-include $(OCAMLMAKEFILE)
pack :
......@@ -175,8 +176,8 @@ pack :
mkdir luckydraw-src
mkdir luckydraw-src/source
cp $(SOURCES_OCAML) luckydraw-src/source
cp ../Makefile.common.source luckydraw-src
cp ../OcamlMakefile luckydraw-src
cp ../../Makefile.common.source luckydraw-src
cp ../../OcamlMakefile luckydraw-src
cp Makefile.luckyDraw luckydraw-src/source
cp Makefile.luckydraw.src luckydraw-src/source/Makefile
tar cvfz luckydraw-src-$(VERSION).tgz luckydraw-src
\ No newline at end of file
......@@ -2,7 +2,7 @@
# Makefile for lurette
#
-include ../Makefile.common.source
-include ../../Makefile.common.source
######################################################################
......@@ -42,13 +42,14 @@ LIBS = str unix nums polka bdd #cudd
USE_CAMLP4 = yes
SOURCES_C = call_lurette_main.c lurette_exe.c ocaml2c.idl \
$(HERE)/Ezdl_c.c $(HERE)/liblutin_c.c $(HERE)/liblutin.idl
HERE=.
LUTDIR=Lutin
LUTDIR=../Lutin
LUCKYDIR=../Lucky
SOURCES_C = $(HERE)/call_lurette_main.c $(HERE)/lurette_exe.c $(HERE)/ocaml2c.idl \
$(HERE)/Ezdl_c.c $(HERE)/liblutin_c.c $(HERE)/liblutin.idl
SOURCES = $(SOURCES_C) \
$(HERE)/Ezdl.ml \
......@@ -124,8 +125,8 @@ SOURCES = $(SOURCES_C) \
$(HERE)/lexer.mll \
$(HERE)/gne.mli \
$(HERE)/gne.ml \
$(HERE)/Lucky/lucParse.mli \
$(HERE)/Lucky/lucParse.ml \
$(LUCKYDIR)/lucParse.mli \
$(LUCKYDIR)/lucParse.ml \
$(HERE)/polyhedron.mli \
$(HERE)/polyhedron.ml \
$(HERE)/formula_to_bdd.mli \
......@@ -140,14 +141,14 @@ SOURCES = $(SOURCES_C) \
$(HERE)/fair_bddd.ml \
$(HERE)/solver.mli \
$(HERE)/solver.ml \
$(HERE)/Lucky/show_env.mli \
$(HERE)/Lucky/show_env.ml \
$(LUCKYDIR)/show_env.mli \
$(LUCKYDIR)/show_env.ml \
$(HERE)/prog.mli \
$(HERE)/prog.ml \
$(LUTDIR)/lutProg.ml \
$(LUTDIR)/lutProg.mli \
$(HERE)/Lucky/lucProg.mli \
$(HERE)/Lucky/lucProg.ml \
$(LUCKYDIR)/lucProg.mli \
$(LUCKYDIR)/lucProg.ml \
$(HERE)/fGen.mli \
$(HERE)/fGen.ml \
$(HERE)/print.mli \
......@@ -175,6 +176,6 @@ install: libinstall
OCAMLMAKEFILE = ../OcamlMakefile
OCAMLMAKEFILE = ../../OcamlMakefile
-include $(OCAMLMAKEFILE)
......@@ -2,7 +2,7 @@
# Makefile for lurette
#
-include ../Makefile.common.source
-include ../../Makefile.common.source
######################################################################
......@@ -119,5 +119,6 @@ all: nc
install: libinstall
OCAMLMAKEFILE = ../../OcamlMakefile
-include $(OCAMLMAKEFILE)
/*-------------------------------------------------------------
Une collection de macros qui permet de faire du link
dynamique indiffremment sous unix ou win32
Les macros fournies sont des versions "simplifies"
de dlopen et dlsym (posix) :
void* ezdlopen(char* n)
- retourne le handler (NULL si erreur)
void* ezdlsym(void* h, char* n)
- retourne la fonction n dans h (NULL si erreur)
char* ezdlerror()
- une explication si et quand il vient juste
d'y avoir une erreur (indfini sinon)
Pour utiliser il faut juste inclure :
#include "ezdl.h"
et, sous win32, compiler avec l'option -DWIN32
(par dfaut c'est du posix)
--------------------------------------------------------------*/
#include <stdio.h>
#ifdef WIN32
#include <windows.h>
#define HANDLE HANDLE
#ifndef EZDL_ERROR_BUFF_ALOC
#define EZDL_ERROR_BUFF_ALOC
char EZDL_ERROR_BUFF[1024];
#endif
#define RTLD_LAZY 0
#define ezdlopen(n) ((void*)LoadLibrary(n))
#define ezdlsym(l,n) ((void*)GetProcAddress(l,n))
#define ezdlerror() (sprintf(EZDL_ERROR_BUFF,"win32 dll error %d", GetLastError()),&EZDL_ERROR_BUFF[0])
#define ezdlclose(l) (FreeLibrary(l))
#else
#include <dlfcn.h>
#define ezdlopen(n) (dlopen(n,RTLD_LAZY))
#define ezdlsym(l,n) (dlsym(l,n))
#define ezdlerror() (dlerror())
#define ezdlclose(l) (dlclose(l))
#endif
/*-------------------------------------------------------------
Une collection de macros qui permet de compiler
des programmes linux utilisant dlfnc.h en win32 natif
N.B. IL FAUT UTLISER
#include <ezdlfcn.h>
A LA PLACE DE
#include <dlfcn.h>
ET COMPILER AVEC -DWIN32
--------------------------------------------------------------*/
#include <stdio.h>
#ifdef WIN32
#include <windows.h>
#define HANDLE HANDLE
#ifndef EZDL_ERROR_BUFF_ALOC
#define EZDL_ERROR_BUFF_ALOC
char EZDL_ERROR_BUFF[1024];
char* EZDL_ERROR;
#endif
inline dlopen(n,x) {
HANDLE res = LoadLibrary(n);
if(res){
EZDL_ERROR = NULL;
} else {
sprintf(EZDL_ERROR_BUFF,"win32 dll error %d", GetLastError());
EZDL_ERROR = &EZDL_ERROR_BUFF[0];
}
return res;
}
#define dlsym(l,n) GetProcAddress(l,n)
char* win32dllerror(){
sprintf(ERROR_BUFF,"win32 dll error %d", GetLastError());
return &ERROR_BUFF[0];
}
#define dlerror() win32dllerror()
#define DLEXT "dll"
#else
#include <dlfcn.h>
#define HANDLE void*
#define DLEXT "so"
#endif
HANDLE opendl(char* n){
HANDLE res;
char* error;
char buff[1024];
sprintf(buff, "%s.%s", n, DLEXT);
res = dlopen (buff, RTLD_LAZY);
if(! res ){
error = dlerror();
fprintf(stderr,"%s\n", error);
exit(1);
}
return res;
}
void* symdl(void* l, char* n){
void* res;
char* error;
res = dlsym(l, n);
if(! res ){
error = dlerror();
fprintf(stderr,"%s\n", error);
exit(1);
}
return res;
}
int main(){
void* lib;
void* f;
lib = opendl ("liblutin");
f = symdl (lib, "average_goon");
int (*agoon)(int,int,int) = (int(*))f;
int i = (*agoon)(7,10,2);
printf("average_goon(7,10,2)=%d\n", i);
return 0;
}