#!/bin/bash

date +\'%d-%m-%Y\' > build-date 

PROJECT_PATH=$('pwd')/..
LAZARUS_PATH=/usr/local/share/lazarus

COMPONENTS_ROOT=../..

RX_ROOT=$COMPONENTS_ROOT/rx
COMPONENTS_PATH="$RX_ROOT;$COMPONENTS_ROOT/foreign"
COMPONENTS_DEBUG_PATH="$COMPONENTS_ROOT/foreign;$PROJECT_PATH/patches"

#ARM arch
#Arch dependent dirs
UNITS_OUTPUT_ARM=../units/arm-wince
PRECOMPILED_COMPONENTS_ARM="-Fu$LAZARUS_PATH/ideintf/units/arm-wince/ \
                            -Fu$LAZARUS_PATH/lcl/units/arm-wince/ \
                            -Fu$LAZARUS_PATH/lcl/units/arm-wince/wince \
                            -Fu$LAZARUS_PATH/packager/units/arm-wince/"
PPC_ARM="fpc -TWinCE -Parm -dLCLwince $PRECOMPILED_COMPONENTS_ARM -FU$UNITS_OUTPUT_ARM"

#native GTK2 build
UNITS_OUTPUT_NATIVE=../units/i386-linux
PRECOMPILED_COMPONENTS_NATIVE="-Fu$LAZARUS_PATH/ideintf/units/i386-linux/ \
                            -Fu$LAZARUS_PATH/lcl/units/i386-linux/ \
                            -Fu$LAZARUS_PATH/lcl/units/i386-linux/gtk2 \
                            -Fu$LAZARUS_PATH/packager/units/i386-linux/"
PPC_NATIVE="fpc $PRECOMPILED_COMPONENTS_NATIVE -FU$UNITS_OUTPUT_NATIVE"

#no crosscompiling (default)
PPC=$PPC_NATIVE

#Rx No debug info
$PPC -CX -B -XX  -WG -WN -vewnhi -l \
  -Fu$PROJECT_PATH \
  -Fu$COMPONENTS_PATH \
  -Fu$LAZARUS_PATH/components/rx \
  -dLCL $RX_ROOT/rxnew.pas 
  
$PPC -CX -B -XX -WG -WN -vewnhi -l \
  -Fu$PROJECT_PATH \
  -Fu$COMPONENTS_PATH \
  -Fu$LAZARUS_PATH/components/rx \
  -dLCL $LAZARUS_PATH/components/rx/rx.pas

#Main Germes Orders Debug Info on 
$PPC -CX -B -XX -gl -WG -WN -vewnhi -l \
  -Fu$PROJECT_PATH \
  -Fu$COMPONENTS_DEBUG_PATH \
  -Fu$PROJECT_PATH \
  -o$PROJECT_PATH/germesorders.exe \
  -dLCL $PROJECT_PATH/germesorders.lpr

#arm-wince-strip --only-keep-debug germesorders.exe
#arm-wince-strip germesorders.exe
