2
0

triplet.pas 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.str
  37. else if target_info.system = system_aarch64_iphonesim then
  38. result:=result+'-ios-simulator'+iPhoneOSVersionMin.str
  39. else
  40. result:=result+'-ios'+iPhoneOSVersionMin.str;
  41. end
  42. else if target_info.system in (systems_linux+systems_android) then
  43. result:=result+'-unknown-linux'
  44. else if target_info.system in systems_all_windows then
  45. begin
  46. { WinCE isn't supported (yet) by llvm, but if/when added this is
  47. presumably how they will differentiate it }
  48. if target_info.system in systems_windows then
  49. result:=result+'-pc';
  50. result:=result+'-windows-msvc19'
  51. end
  52. else if target_info.system in systems_freebsd then
  53. result:=result+'-unknown-freebsd'
  54. else if target_info.system in systems_openbsd then
  55. result:=result+'-unknown-openbsd'
  56. else if target_info.system in systems_netbsd then
  57. result:=result+'-unknown-netbsd'
  58. else if target_info.system in systems_solaris then
  59. result:=result+'-sun-solaris2'
  60. else if target_info.system in systems_aix then
  61. result:=result+'-ibm-aix53'
  62. else if target_info.system in [system_i386_haiku] then
  63. result:=result+'-unknown-haiku'
  64. else if target_info.system in systems_embedded then
  65. result:=result+'-none'
  66. else
  67. result:=result+'-unknown';
  68. { environment/ABI }
  69. if target_info.system in systems_android then
  70. result:=result+'-android'
  71. else
  72. {$ifdef arm}
  73. if target_info.abi=abi_eabihf then
  74. result:=result+'-gnueabihf'
  75. else if target_info.system in systems_embedded then
  76. result:=result+'-eabi'
  77. else if target_info.abi=abi_eabi then
  78. result:=result+'-gnueabi'
  79. else
  80. {$endif}
  81. if target_info.system in systems_embedded then
  82. result:=result+'-elf'
  83. else if target_info.system in systems_linux then
  84. result:=result+'-gnu';
  85. end;
  86. end.