; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "BSD 2-clause" license."          |
;|_______________________________________________________________________________________|
;
;  Description: Executable file formating macro library.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

TargetOS equ Linux
strTargetOS equ 'Linux'

match =LINUX_INTERPRETER, LINUX_INTERPRETER {
  LINUX_INTERPRETER equ '/lib/ld-linux.so.2'
}


macro @BinaryType type, model {
  if type eq GUI
    format ELF executable 3
    entry start
  end if

  if type eq console
    format ELF executable 3
    entry start
  end if

  if type eq DLL
    format ELF executable  ; is it correct???
  end if

  postpone \{
    ?FAKE_COMPILE = 0
    match =TRUE, ___FAKE_COMPILE \\{
      ?FAKE_COMPILE = 1
    \\}

    if ?FAKE_COMPILE = 0

      ; global data
      if (model eq )|(model eq default)
        segment readable writeable
      end if

      if ~(model eq manual)
        \IncludeAllGlobals
      end if

      ; imports
      \__create_all_imports
    end if
  \}

  if __imported_count > 0
    segment interpreter readable
    interpreter LINUX_INTERPRETER
  end if

  segment readable writeable executable

  add_initialize ___SwitchLinuxTo3GB

}



macro __create_all_imports {

    rept DynamicLibList@count i:1 \{
      match name:filename, DynamicLibList\#i \\{
        \\include filename
      \\}
    \}

    __ImportAll
}



