@echo off

set DEST=Mingw64
set OPT=-O3 -ffast-math
set SRC=financial_service
set SRCEXE=financial_service_test


REM **** C ****

echo * Building C source of Win64 DLL and example ...
gcc %OPT% -shared -s -DT2C_DLL %SRC%_dll.c -o %DEST%_DLL\%SRC%.dll -Wl,--out-implib,%DEST%_DLL\lib%SRC%.a
gcc %OPT% -s -DT2C_DLL %SRCEXE%.c -o %DEST%_dll\%SRCEXE% -L %DEST%_dll -l%SRC%

echo * Building C source of Win64 static library and example ...
gcc %OPT% -c %SRC%.c
ar rcs %DEST%_static\lib%SRC%.a %SRC%.o
del %SRC%.o
gcc %OPT% -s %SRCEXE%.c -o %DEST%_static\%SRCEXE% -L %DEST%_static -l%SRC%


REM **** C++ ****

echo * Building C++ source of Win64 static library and example ...
g++ %OPT% -c %SRC%_cpp.cpp
ar rcs %DEST%_g++\lib%SRC%.a %SRC%_cpp.o
del %SRC%_cpp.o
g++ %OPT% -static -s %SRCEXE%.cpp -o %DEST%_g++\%SRCEXE% -L %DEST%_g++ -l%SRC%


REM **** Fortran 90 ****

cd %DEST%_gfortran

echo * Building Fortran 90 source of Win64 static library and example ...
gfortran %OPT% -c ../%SRC%.f90
ar rcs lib%SRC%.a %SRC%.o
del %SRC%.o
gfortran %OPT% -static -s -o %SRCEXE% ../%SRCEXE%.f90 -L. -l%SRC%
cd ..


echo * Done

REM Free the resources

set DEST=
set OPT=
set SRC=
set SRCEXE=

