2
0

triplet.pas 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. {
  2. Copyright (c) 2007-2008, 2013, 2019-2020 by Jonas Maebe
  3. This unit handles constructing target triples
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit triplet;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype;
  22. function targettriplet(tripletstyle: ttripletstyle): ansistring;
  23. implementation
  24. uses
  25. globals,systems,
  26. cpuinfo,tripletcpu;
  27. function targettriplet(tripletstyle: ttripletstyle): ansistring;
  28. begin
  29. { architecture }
  30. result:=tripletcpustr(tripletstyle);
  31. { vendor and/or OS }
  32. if target_info.system in systems_darwin then
  33. begin
  34. result:=result+'-apple';
  35. if target_info.system in systems_macosx then
  36. result:=result+'-macosx'+MacOSXVersionMin
  37. else
  38. result:=result+'-ios'+iPhoneOSVersionMin;
  39. end
  40. else if target_info.system in (systems_linux+systems_android) then
  41. result:=result+'-unknown-linux'
  42. else if target_info.system in systems_all_windows then
  43. begin
  44. { WinCE isn't supported (yet) by llvm, but if/when added this is
  45. presumably how they will differentiate it }
  46. if target_info.system in systems_windows then
  47. result:=result+'-pc';
  48. result:=result+'-windows-msvc19'
  49. end
  50. else if target_info.system in systems_freebsd then
  51. result:=result+'-unknown-freebsd'
  52. else if target_info.system in systems_openbsd then
  53. result:=result+'-unknown-openbsd'
  54. else if target_info.system in systems_netbsd then
  55. result:=result+'-unknown-netbsd'
  56. else if target_info.system in systems_solaris then
  57. result:=result+'-sun-solaris2'
  58. else if target_info.system in systems_aix then
  59. result:=result+'-ibm-aix53'
  60. else if target_info.system in [system_i386_haiku] then
  61. result:=result+'-unknown-haiku'
  62. else if target_info.system in systems_embedded then
  63. result:=result+'-none'
  64. else
  65. result:=result+'-unknown';
  66. { environment/ABI }
  67. if target_info.system in systems_android then
  68. result:=result+'-android'
  69. else
  70. {$ifdef arm}
  71. if target_info.abi=abi_eabihf then
  72. result:=result+'-gnueabihf'
  73. else if target_info.system in systems_embedded then
  74. result:=result+'-eabi'
  75. else if target_info.abi=abi_eabi then
  76. result:=result+'-gnueabi'
  77. else
  78. {$endif}
  79. if target_info.system in systems_embedded then
  80. result:=result+'-elf'
  81. else if target_info.system in systems_linux then
  82. result:=result+'-gnu';
  83. end;
  84. end.