Makefile.fpc 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. #
  2. # Makefile.fpc for Free Pascal Compiler
  3. #
  4. [package]
  5. name=compiler
  6. version=3.3.1
  7. [target]
  8. programs=pp
  9. dirs=utils
  10. [compiler]
  11. targetdir=$(CPU_UNITDIR)/bin/$(FULL_TARGET)
  12. unittargetdir=$(CPU_UNITDIR)/units/$(FULL_TARGET)
  13. unitdir=$(COMPILERSOURCEDIR)
  14. includedir=$(CPC_TARGET)
  15. [require]
  16. packages=rtl
  17. tools=diff cmp
  18. [install]
  19. fpcpackage=y
  20. [default]
  21. fpcdir=..
  22. [prerules]
  23. # Don't export version it can change after the first compile
  24. unexport FPC_VERSION FPC_COMPILERINFO
  25. # Which platforms are ready for inclusion in the cycle
  26. CYCLETARGETS=i386 powerpc sparc arm x86_64 powerpc64 m68k armeb mipsel mips avr jvm i8086 aarch64 sparc64 riscv32 riscv64 xtensa z80 wasm32 loongarch64
  27. # Platforms not yet ready
  28. BETATARGETS=mips64 mips64el
  29. # All supported targets used for clean
  30. ALLTARGETS=$(CYCLETARGETS)
  31. # All OS targets that do not support native compiler
  32. NO_NATIVE_COMPILER_OS_LIST=amstradcpc embedded freertos gba macosclassic msdos msxdos nds palmos sinclairql symbian watcom wii win16 zxspectrum
  33. # All CPU targets that do not support native compiler
  34. NO_NATIVE_COMPILER_CPU_LIST=avr i8086 jvm z80 wasm32
  35. # Don't compile a native compiler & utilities for targets
  36. # which do not support it
  37. ifneq ($(CPU_SOURCE),$(CPU_TARGET))
  38. ifneq ($(findstring $(CPU_TARGET),$(NO_NATIVE_COMPILER_CPU_LIST)),)
  39. NoNativeBinaries=1
  40. endif
  41. endif
  42. ifneq ($(OS_SOURCE),$(OS_TARGET))
  43. ifneq ($(findstring $(OS_TARGET),$(NO_NATIVE_COMPILER_OS_LIST)),)
  44. NoNativeBinaries=1
  45. endif
  46. endif
  47. ifndef FORCE_NATIVE_BINARIES
  48. ifeq ($(NoNativeBinaries),1)
  49. override EXEEXT=$(SRCEXEEXT)
  50. # In those cases, installation in a cross-installation
  51. CROSSINSTALL=1
  52. endif
  53. endif
  54. # Allow POWERPC, POWERPC64, M68K, I386, jvm defines for target cpu
  55. ifdef POWERPC
  56. PPC_TARGET=powerpc
  57. endif
  58. ifdef POWERPC64
  59. PPC_TARGET=powerpc64
  60. endif
  61. ifdef SPARC
  62. PPC_TARGET=sparc
  63. endif
  64. ifdef SPARC64
  65. PPC_TARGET=sparc64
  66. endif
  67. ifdef M68K
  68. PPC_TARGET=m68k
  69. endif
  70. ifdef I386
  71. PPC_TARGET=i386
  72. endif
  73. ifdef X86_64
  74. PPC_TARGET=x86_64
  75. endif
  76. ifdef ARM
  77. PPC_TARGET=arm
  78. endif
  79. ifdef ARMEB
  80. PPC_TARGET=armeb
  81. endif
  82. ifdef MIPS
  83. PPC_TARGET=mips
  84. endif
  85. ifdef MIPSEL
  86. PPC_TARGET=mipsel
  87. endif
  88. ifdef MIPS64
  89. PPC_TARGET=mips64
  90. endif
  91. ifdef MIPS64EL
  92. PPC_TARGET=mips64el
  93. endif
  94. ifdef AVR
  95. PPC_TARGET=avr
  96. endif
  97. ifdef JVM
  98. PPC_TARGET=jvm
  99. endif
  100. ifdef I8086
  101. PPC_TARGET=i8086
  102. endif
  103. ifdef AARCH64
  104. PPC_TARGET=aarch64
  105. endif
  106. ifdef RISCV32
  107. PPC_TARGET=riscv32
  108. endif
  109. ifdef RISCV64
  110. PPC_TARGET=riscv64
  111. endif
  112. ifdef XTENSA
  113. PPC_TARGET=xtensa
  114. endif
  115. ifdef Z80
  116. PPC_TARGET=z80
  117. endif
  118. ifdef LOONGARCH64
  119. PPC_TARGET=loongarch64
  120. endif
  121. # Default is to generate a compiler for the same
  122. # platform as CPU_TARGET (a native compiler)
  123. ifndef PPC_TARGET
  124. PPC_TARGET=$(CPU_TARGET)
  125. endif
  126. ifeq ($(PPC_TARGET),armeb)
  127. CPC_TARGET=arm
  128. else
  129. CPC_TARGET=$(PPC_TARGET)
  130. endif
  131. # Default is to generate a compiler for the same
  132. # target as OS_TARGET (a native compiler)
  133. ifndef PPC_OS
  134. PPC_OS=$(OS_TARGET)
  135. endif
  136. # Where to place the unit files.
  137. CPU_UNITDIR=$(CPC_TARGET)
  138. # RTL
  139. UTILSDIR=../utils
  140. # Directories containing compiler sources
  141. COMPILERSOURCEDIR=$(CPC_TARGET) systems
  142. # Utils used by compiler development/installation
  143. COMPILERUTILSDIR=utils
  144. # Default language for the compiler
  145. ifndef FPCLANG
  146. FPCLANG=e
  147. endif
  148. # Local options for the compiler only
  149. ifndef LOCALOPT
  150. LOCALOPT:=$(OPT)
  151. endif
  152. # Options for the RTL only when cycling
  153. ifndef RTLOPT
  154. RTLOPT:=$(OPT)
  155. endif
  156. SVNVERSION:=$(firstword $(wildcard $(addsuffix /svnversion$(SRCEXEEXT),$(SEARCHPATH))))
  157. ifndef GIT
  158. GIT:=$(firstword $(wildcard $(addsuffix /git$(SRCEXEEXT),$(SEARCHPATH))))
  159. endif
  160. DATE_FMT = +%Y/%m/%d
  161. ifdef SOURCE_DATE_EPOCH
  162. COMPDATESTR ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)")
  163. else
  164. # does a git directory exist? ...
  165. GIT_DIR = $(wildcard ../.git)
  166. ifneq ($(GIT_DIR),)
  167. # ... then take date from head
  168. ifneq ($(GIT),)
  169. COMPDATESTR:=$(shell $(GIT) log -1 --pretty=%cd --date=format:'%Y/%m/%d')
  170. endif
  171. endif
  172. endif
  173. ifdef COMPDATESTR
  174. override OPTNEW+=-DD$(COMPDATESTR)
  175. endif
  176. ifdef CYCLELEVEL
  177. ifeq ($(CYCLELEVEL),1)
  178. override LOCALOPT+=$(OPTLEVEL1)
  179. override RTLOPT+=$(OPTLEVEL1)
  180. override LOCALOPT+=$(LOCALOPTLEVEL1)
  181. override RTLOPT+=$(RTLOPTLEVEL1)
  182. endif
  183. ifeq ($(CYCLELEVEL),2)
  184. override LOCALOPT+=$(OPTLEVEL2)
  185. override RTLOPT+=$(OPTLEVEL2)
  186. override LOCALOPT+=$(LOCALOPTLEVEL2)
  187. override RTLOPT+=$(RTLOPTLEVEL2)
  188. override LOCALOPT+=$(OPTNEW)
  189. override RTLOPT+=$(OPTNEW)
  190. endif
  191. ifeq ($(CYCLELEVEL),3)
  192. override LOCALOPT+=$(OPTLEVEL3)
  193. override RTLOPT+=$(OPTLEVEL3)
  194. override LOCALOPT+=$(LOCALOPTLEVEL3)
  195. override RTLOPT+=$(RTLOPTLEVEL3)
  196. override LOCALOPT+=$(OPTNEW)
  197. override RTLOPT+=$(OPTNEW)
  198. endif
  199. ifeq ($(CYCLELEVEL),4)
  200. override LOCALOPT+=$(OPTLEVEL4)
  201. override RTLOPT+=$(OPTLEVEL4)
  202. override LOCALOPT+=$(LOCALOPTLEVEL4)
  203. override RTLOPT+=$(RTLOPTLEVEL4)
  204. override LOCALOPT+=$(OPTNEW)
  205. override RTLOPT+=$(OPTNEW)
  206. endif
  207. else
  208. ifdef COMPDATESTR
  209. ifeq ($(FPC_VERSION),$(PACKAGE_VERSION))
  210. override LOCALOPT+=-DD$(COMPDATESTR)
  211. endif
  212. endif
  213. endif
  214. # Make OPT empty. It is copied to LOCALOPT and RTLOPT
  215. override OPT=
  216. # Message files
  217. MSGFILES=$(wildcard msg/error*.msg)
  218. # ppcSUFFIX
  219. ifeq ($(CPC_TARGET),i386)
  220. CPUSUF=386
  221. endif
  222. ifeq ($(CPC_TARGET),m68k)
  223. CPUSUF=68k
  224. endif
  225. ifeq ($(CPC_TARGET),powerpc)
  226. CPUSUF=ppc
  227. endif
  228. ifeq ($(CPC_TARGET),powerpc64)
  229. CPUSUF=ppc64
  230. endif
  231. ifeq ($(CPC_TARGET),sparc)
  232. CPUSUF=sparc
  233. endif
  234. ifeq ($(CPC_TARGET),sparc64)
  235. CPUSUF=sparc64
  236. endif
  237. ifeq ($(CPC_TARGET),x86_64)
  238. CPUSUF=x64
  239. endif
  240. ifeq ($(CPC_TARGET),arm)
  241. CPUSUF=arm
  242. endif
  243. ifeq ($(CPC_TARGET),mips)
  244. CPUSUF=mips
  245. endif
  246. ifeq ($(CPC_TARGET),mipsel)
  247. CPUSUF=mipsel
  248. endif
  249. ifeq ($(CPC_TARGET),mips64)
  250. CPUSUF=mips64
  251. endif
  252. ifeq ($(CPC_TARGET),mips64el)
  253. CPUSUF=mips64el
  254. endif
  255. ifeq ($(CPC_TARGET),avr)
  256. CPUSUF=avr
  257. ALLOW_WARNINGS=1
  258. endif
  259. ifeq ($(CPC_TARGET),jvm)
  260. CPUSUF=jvm
  261. endif
  262. ifeq ($(CPC_TARGET),i8086)
  263. CPUSUF=8086
  264. endif
  265. ifeq ($(CPC_TARGET),aarch64)
  266. CPUSUF=a64
  267. endif
  268. ifeq ($(CPC_TARGET),riscv32)
  269. CPUSUF=rv32
  270. endif
  271. ifeq ($(CPC_TARGET),riscv64)
  272. CPUSUF=rv64
  273. endif
  274. ifeq ($(CPC_TARGET),xtensa)
  275. CPUSUF=xtensa
  276. endif
  277. ifeq ($(CPC_TARGET),z80)
  278. CPUSUF=z80
  279. endif
  280. ifeq ($(CPC_TARGET),wasm32)
  281. CPUSUF=wasm32
  282. endif
  283. ifeq ($(CPC_TARGET),loongarch64)
  284. CPUSUF=loongarch64
  285. endif
  286. # Do not define the default -d$(CPU_TARGET) because that
  287. # will conflict with our -d$(CPC_TARGET)
  288. NOCPUDEF=1
  289. # Default message file
  290. MSGFILE=msg/error$(FPCLANG).msg
  291. PPUDUMPPROG:=$(firstword $(strip $(wildcard $(addsuffix /ppudump$(SRCEXEEXT),$(SEARCHPATH)))))
  292. ifndef PPUDUMP
  293. ifdef PPUDUMPPROG
  294. PPUDUMP=$(PPUDUMPPROG)
  295. else
  296. PPUDUMP=ppudump
  297. endif
  298. endif
  299. # Check if revision.inc is present
  300. REVINC:=$(wildcard revision.inc)
  301. ifneq ($(REVINC),)
  302. # File revision.inc is present
  303. #Use it to compile version.pas unit
  304. override LOCALOPT+=-dREVINC
  305. # Automatically update revision.inc if
  306. # git/svnversion executable is available
  307. ifeq ($(REVSTR),)
  308. ifneq ($(wildcard ../.git),)
  309. ifneq ($(GIT),)
  310. GITDESCRIBE=$(shell $(GIT) describe --dirty)
  311. REVSTR:=$(word 2,$(subst -, ,$(GITDESCRIBE)))-$(word 3,$(subst -, ,$(GITDESCRIBE)))
  312. ifneq ($(shell $(GIT) log @{u}..),)
  313. REVSTR:=$(REVSTR)-unpushed
  314. endif
  315. ifneq ($(word 4,$(subst -, ,$(GITDESCRIBE))),)
  316. REVSTR:=$(REVSTR)-$(word 4,$(subst -, ,$(GITDESCRIBE)))
  317. endif
  318. endif
  319. export REVSTR
  320. else
  321. ifneq ($(SVNVERSION),)
  322. SVNVERSTR:=$(shell $(SVNVERSION) -c .)
  323. ifneq ($(words $(SVNVERSTR)),1)
  324. REVSTR:=$(subst $() $(),_,$(SVNVERSTR))
  325. else
  326. REVSTR:=$(subst r,,$(subst r1:,,r$(subst exported,,$(SVNVERSTR))))
  327. endif
  328. export REVSTR
  329. endif
  330. endif
  331. endif
  332. endif
  333. # Avoid infinite loop
  334. ifeq ($(REVINC),force)
  335. ifeq ($(REVSTR),)
  336. REVSTR:=exported
  337. export REVSTR
  338. endif
  339. endif
  340. # set correct defines (-d$(CPU_TARGET) is automatically added in makefile.fpc)
  341. override LOCALOPT+=-d$(CPC_TARGET) -dGDB
  342. #include LLVM define/directory if requested
  343. ifdef LLVM
  344. ifeq ($(findstring $(PPC_TARGET),x86_64 aarch64 arm),)
  345. $(error The $(PPC_TARGET) architecture is not (yet) supported by the FPC/LLVM code generator)
  346. endif
  347. ifeq ($(findstring $(OS_TARGET),darwin iphonesim linux),)
  348. $(error The $(OS_TARGET) target OS is not (yet) supported by the FPC/LLVM code generator)
  349. endif
  350. override LOCALOPT+=-dllvm -Fullvm
  351. endif
  352. # i386 specific
  353. ifeq ($(PPC_TARGET),i386)
  354. override LOCALOPT+=-Fux86 -Fix86
  355. endif
  356. # x86_64 specific
  357. ifeq ($(PPC_TARGET),x86_64)
  358. override LOCALOPT+=-Fux86 -Fix86
  359. endif
  360. # PowerPC specific
  361. ifeq ($(PPC_TARGET),powerpc)
  362. override LOCALOPT+=-Fuppcgen
  363. endif
  364. # PowerPC64 specific
  365. ifeq ($(PPC_TARGET),powerpc64)
  366. override LOCALOPT+=-Fuppcgen
  367. endif
  368. # m68k specific
  369. ifeq ($(PPC_TARGET),m68k)
  370. override LOCALOPT+=
  371. endif
  372. # Sparc specific
  373. ifeq ($(PPC_TARGET),sparc)
  374. override LOCALOPT+=-Fusparcgen -Fisparcgen
  375. endif
  376. # Sparc specific
  377. ifeq ($(PPC_TARGET),sparc64)
  378. override LOCALOPT+=-Fusparcgen -Fisparcgen
  379. endif
  380. # ARM specific
  381. ifeq ($(PPC_TARGET),arm)
  382. override LOCALOPT+=-Fuarmgen
  383. endif
  384. # ARMEB specific
  385. ifeq ($(PPC_TARGET),armeb)
  386. override LOCALOPT+=-Fuarmgen
  387. endif
  388. # mips specific
  389. ifeq ($(PPC_TARGET),mips)
  390. override LOCALOPT+=-Fumips
  391. endif
  392. # mipsel specific
  393. ifeq ($(PPC_TARGET),mipsel)
  394. override LOCALOPT+=-Fumips
  395. endif
  396. # mips64 specific
  397. ifeq ($(PPC_TARGET),mips64)
  398. override LOCALOPT+=-Fumips
  399. endif
  400. # mips64el specific
  401. ifeq ($(PPC_TARGET),mips64el)
  402. override LOCALOPT+=-Fumips
  403. endif
  404. # jvm specific
  405. ifeq ($(PPC_TARGET),jvm)
  406. override LOCALOPT+=-Fujvm
  407. endif
  408. # AArch64 specific
  409. ifeq ($(PPC_TARGET),aarch64)
  410. override LOCALOPT+=-Fuarmgen
  411. endif
  412. # i8086 specific
  413. ifeq ($(PPC_TARGET),i8086)
  414. override LOCALOPT+=-Fux86
  415. endif
  416. # RiscV32 specific
  417. ifeq ($(PPC_TARGET),riscv32)
  418. override LOCALOPT+=-Furiscv
  419. endif
  420. # RiscV64 specific
  421. ifeq ($(PPC_TARGET),riscv64)
  422. override LOCALOPT+=-Furiscv
  423. endif
  424. # WASM32 specific
  425. ifeq ($(PPC_TARGET),wasm32)
  426. override LOCALOPT+=-dNOOPT
  427. endif
  428. # LoongArch64 specific
  429. ifeq ($(PPC_TARGET),loongarch64)
  430. override LOCALOPT+=-Fuloongarch64
  431. endif
  432. OPTWPOCOLLECT=-OWdevirtcalls,optvmts -FW$(BASEDIR)/pp1.wpo
  433. OPTWPOPERFORM=-Owdevirtcalls,optvmts -Fw$(BASEDIR)/pp1.wpo
  434. # symbol liveness WPO requires nm, smart linking and no stripping (the latter
  435. # is forced by the Makefile when necessary)
  436. ifneq ($(findstring $(OS_TARGET),darwin linux dragonfly freebsd solaris),)
  437. ifdef LINKSMART
  438. ifdef CREATESMART
  439. OPTWPOCOLLECT+=-OWsymbolliveness -Xs-
  440. OPTWPOPERFORM+=-Owsymbolliveness
  441. endif
  442. endif
  443. endif
  444. [rules]
  445. #####################################################################
  446. # Setup Targets
  447. #####################################################################
  448. ifneq ($(findstring $(OS_TARGET),win32 win64 aix),)
  449. USE_CMP_FOR_DIFF=1
  450. endif
  451. ifdef USE_CMP_FOR_DIFF
  452. ifdef CMP
  453. override DIFF:=$(CMP) -i218
  454. endif
  455. endif
  456. ifeq ($(OS_TARGET), darwin)
  457. CODESIGN?=$(firstword $(wildcard $(addsuffix /codesign$(SRCEXEEXT),$(SEARCHPATH))))
  458. endif
  459. # Use -Sew option by default
  460. # Allow disabling by setting ALLOW_WARNINGS=1
  461. ifneq ($(CYCLELEVEL),1)
  462. ifndef ALLOW_WARNINGS
  463. override LOCALOPT+=-Sew
  464. endif
  465. endif
  466. # Add Local options
  467. override COMPILER+=$(LOCALOPT)
  468. #####################################################################
  469. # PASDoc
  470. #####################################################################
  471. PASDOC:=$(strip $(wildcard $(addsuffix /pasdoc.exe,$(SEARCHPATH))))
  472. ifeq ($(PASDOC),)
  473. PASDOC:=$(strip $(wildcard $(addsuffix /pasdoc,$(SEARCHPATH))))
  474. endif
  475. ifeq ($(PASDOC),)
  476. PASDOC:=../projects/pasdoc/bin/pasdoc
  477. else
  478. PASDOC:=$(firstword $(PASDOC))
  479. endif
  480. #####################################################################
  481. # Setup os-independent filenames
  482. #####################################################################
  483. ifndef EXENAME
  484. EXENAME=ppc$(CPUSUF)$(EXEEXT)
  485. endif
  486. PPEXENAME=pp$(EXEEXT)
  487. TEMPNAME=ppc$(SRCEXEEXT)
  488. ifneq ($(CPUSUF),jvm)
  489. PPCROSSNAME=ppcross$(CPUSUF)$(SRCEXEEXT)
  490. else
  491. PPCROSSNAME=ppc$(CPUSUF)$(SRCEXEEXT)
  492. endif
  493. TEMPNAME1=ppc1$(EXEEXT)
  494. TEMPNAME2=ppc2$(EXEEXT)
  495. TEMPNAME3=ppc3$(EXEEXT)
  496. TEMPWPONAME1=ppcwpo1$(EXEEXT)
  497. TEMPWPONAME2=ppcwpo2$(EXEEXT)
  498. MAKEDEP=ppdep$(EXEEXT)
  499. MSG2INC=./msg2inc$(EXEEXT)
  500. ifdef CROSSINSTALL
  501. INSTALLEXEFILE=$(PPCROSSNAME)
  502. else
  503. INSTALLEXEFILE=$(EXENAME)
  504. endif
  505. #####################################################################
  506. # Rules to run the compiler trough GDB using utils/gppc386.pp code
  507. # inside specific levels of cycle.
  508. # Simply compile utils and utils/gppc386
  509. # And move generated utils/gppc386 to ./g$(TEMPNAME)
  510. #####################################################################
  511. # Use debugger for all compilations
  512. ifdef DEBUG_CYCLE
  513. DEBUG_EXENAME=1
  514. DEBUG_PPEXENAME=1
  515. DEBUG_TEMPNAME=1
  516. DEBUG_PPCROSSNAME=1
  517. DEBUG_TEMPNAME1=1
  518. DEBUG_TEMPNAME2=1
  519. DEBUG_TEMPNAME3=1
  520. DEBUG_TEMPWPONAME1=1
  521. DEBUG_TEMPWPONAME2=1
  522. endif
  523. # Or DEBUG_XXX to only start a specific compiler
  524. # inside GDB
  525. ifdef DEBUG_EXENAME
  526. EXENAMEPREFIX=g
  527. NEED_G_COMPILERS+=g$(EXENAME)
  528. endif
  529. ifdef DEBUG_PPEXENAME
  530. PPEXENAMEPREFIX=g
  531. NEED_G_COMPILERS+=g$(PPEXENAME)
  532. endif
  533. ifdef DEBUG_TEMPNAME
  534. TEMPNAMEPREFIX=g
  535. NEED_G_COMPILERS+=g$(TEMPNAME)
  536. endif
  537. ifdef DEBUG_PPCROSSNAME
  538. PPCROSSNAMEPREFIX=g
  539. NEED_G_COMPILERS+=g$(PPCROSSNAME)
  540. endif
  541. ifdef DEBUG_TEMPNAME1
  542. TEMPNAME1PREFIX=g
  543. NEED_G_COMPILERS+=g$(TEMPNAME1)
  544. endif
  545. ifdef DEBUG_TEMPNAME2
  546. TEMPNAME2PREFIX=g
  547. NEED_G_COMPILERS+=g$(TEMPNAME2)
  548. endif
  549. ifdef DEBUG_TEMPNAME3
  550. TEMPNAME3PREFIX=g
  551. NEED_G_COMPILERS+=g$(TEMPNAME3)
  552. endif
  553. ifdef DEBUG_TEMPWPONAME1
  554. TEMPNAMEWPO1PREFIX=g
  555. NEED_G_COMPILERS+=g$(TEMPWPONAME1)
  556. endif
  557. ifdef DEBUG_TEMPWPONAME2
  558. TEMPWPONAME2PREFIX=g
  559. NEED_G_COMPILERS+=g$(TEMPWPONAME2)
  560. endif
  561. ALL_G_COMPILERS="g$(EXENAME) g$(PPEXENAME) g$(TEMPNAME) g$(PPCROSSNAME) g$(TEMPNAME1) g$(TEMPNAME2) g$(TEMPNAME3) g$(TEMPWPONAME1) g$(TEMPWPONAME2)"
  562. #####################################################################
  563. # To start a given compiler $(PP) with gdb, copy utils/gppc386 as g$(PP).
  564. # Symbolic link is not working, full copy required.
  565. # Use a file as time stamp to avoid recompiling utils/gppc386
  566. # unless needed.
  567. #####################################################################
  568. g$(COMPILERTEMPNAME): fpcmade.generate_g_compilers
  569. $(COPY) ./utils/gppc386 ./g$(COMPILERTEMPNAME)
  570. fpcmade.generate_g_compilers: utils/gppc386.pp
  571. $(MAKE) rtlclean rtl utils
  572. $(MAKE) -C utils gppc386$(EXEEXT)
  573. $(GECHO) -n "utils/gppc386 generated at " > $@
  574. $(GDATE) >> $@
  575. ifdef EXENAMEPREFIX
  576. $(MAKE) g$(EXENAME) COMPILERTEMPNAME=$(EXENAME)
  577. endif
  578. ifdef PPEXENAMEPREFIX
  579. $(MAKE) g$(PPEXENAME) COMPILERTEMPNAME=$(PPEXENAME)
  580. endif
  581. ifdef TEMPNAMEPREFIX
  582. $(MAKE) g$(TEMPNAME) COMPILERTEMPNAME=$(TEMPNAME)
  583. endif
  584. ifdef PPCROSSNAMEPREFIX
  585. $(MAKE) g$(PPCROSSNAME) COMPILERTEMPNAME=$(PPCROSSNAME)
  586. endif
  587. ifdef TEMPNAME1PREFIX
  588. $(MAKE) g$(TEMPNAME1) COMPILERTEMPNAME=$(TEMPNAME1)
  589. endif
  590. ifdef TEMPNAME2PREFIX
  591. $(MAKE) g$(TEMPNAME2) COMPILERTEMPNAME=$(TEMPNAME2)
  592. endif
  593. ifdef TEMPNAME3PREFIX
  594. $(MAKE) g$(TEMPNAME3) COMPILERTEMPNAME=$(TEMPNAME3)
  595. endif
  596. ifdef TEMPWPONAME1PREFIX
  597. $(MAKE) g$(TEMPWPONAME1) COMPILERTEMPNAME=$(TEMPWPONAME1)
  598. endif
  599. ifdef TEMPWPONAME2PREFIX
  600. $(MAKE) g$(TEMPWPONAME2) COMPILERTEMPNAME=$(TEMPWPONAME2)
  601. endif
  602. #####################################################################
  603. # cpu targets
  604. #####################################################################
  605. PPC_TARGETS=i386 m68k powerpc sparc arm armeb x86_64 powerpc64 mips mipsel mips64 mips64el avr jvm i8086 aarch64 sparc64 riscv32 riscv64 xtensa z80 wasm32 loongarch64
  606. PPC_SUFFIXES=386 68k ppc sparc arm armeb x64 ppc64 mips mipsel mips64 mips64el avr jvm 8086 a64 sparc64 rv32 rv64 xtensa z80 wasm32 loongarch64
  607. INSTALL_TARGETS=$(addsuffix _exe_install,$(sort $(CYCLETARGETS) $(PPC_TARGETS)))
  608. CLEAN_TARGETS=$(addsuffix _clean,$(sort $(CYCLETARGETS) $(PPC_TARGETS)))
  609. SYMLINKINSTALL_TARGETS=$(addsuffix _symlink_install,$(sort $(CYCLETARGETS) $(PPC_TARGETS)))
  610. .PHONY: $(PPC_TARGETS) $(INSTALL_TARGETS)$(SYMLINKINSTALL_TARGETS)
  611. $(PPC_TARGETS):
  612. $(MAKE) PPC_TARGET=$@ CPU_UNITDIR=$@ compiler
  613. $(INSTALL_TARGETS):
  614. $(MAKE) PPC_TARGET=$(subst _exe_install,,$@) CPU_UNITDIR=$(subst _exe_install,,$@) compiler
  615. $(MAKE) PPC_TARGET=$(subst _exe_install,,$@) CPU_UNITDIR=$(subst _exe_install,,$@) exeinstall
  616. $(SYMLINKINSTALL_TARGETS):
  617. $(MAKE) PPC_TARGET=$(subst _symlink_install,,$@) CPU_UNITDIR=$(subst _symlink_install,,$@) compiler
  618. $(MAKE) PPC_TARGET=$(subst _symlink_install,,$@) CPU_UNITDIR=$(subst _symlink_install,,$@) installsymlink
  619. alltargets: $(ALLTARGETS)
  620. #####################################################################
  621. # Default makefile
  622. #####################################################################
  623. .PHONY: all compiler echotime ppuclean execlean clean distclean
  624. all: compiler $(addsuffix _all,$(TARGET_DIRS))
  625. compiler: $(COMPILER_UNITTARGETDIR) $(COMPILER_TARGETDIR) $(EXENAME)
  626. ifeq ($(MAKELEVEL),0)
  627. ifndef STARTTIME
  628. ifdef DATE
  629. STARTTIME:=$(shell $(DATE) +%T)
  630. else
  631. STARTTIME:=unknown
  632. endif
  633. endif
  634. endif
  635. export STARTTIME
  636. ifdef DATE
  637. ENDTIME=$(shell $(DATE) +%T)
  638. else
  639. ENDTIME:=unknown
  640. endif
  641. echotime:
  642. @echo Start $(STARTTIME) now $(ENDTIME)
  643. ppuclean:
  644. -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  645. -$(DEL) $(addsuffix /*$(PPUEXT),$(COMPILERSOURCEDIR))
  646. tempclean:
  647. -$(DEL) $(PPCROSSNAME) $(TEMPNAME) $(TEMPNAME1) $(TEMPNAME2) $(TEMPNAME3) $(MSG2INC) pp1.wpo pp2.wpo
  648. execlean :
  649. -$(DEL) $(addsuffix $(EXEEXT), $(addprefix ppc, $(PPC_SUFFIXES)))
  650. -$(DEL) $(addsuffix $(EXEEXT), $(addprefix ppcross, $(PPC_SUFFIXES)))
  651. -$(DEL) $(EXENAME) $(TEMPWPONAME1) $(TEMPWPONAME2) $(ALL_G_COMPILERS)
  652. -$(DEL) fpcmade.generate_g_compilers
  653. $(CLEAN_TARGETS):
  654. -$(DELTREE) $(addprefix $(subst _clean,,$@),/units)
  655. -$(DELTREE) $(addprefix $(subst _clean,,$@),/bin)
  656. -$(DEL) $(addprefix $(subst _clean,,$@)/,*$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT))
  657. -$(DEL) $(addprefix $(subst _clean,,$@)/ppc,$(addsuffix $(EXEEXT), $(PPC_SUFFIXES)))
  658. cycleclean: cleanall $(addsuffix _clean,$(CPC_TARGET))
  659. -$(DEL) $(EXENAME)
  660. clean: tempclean execlean cleanall $(addsuffix _clean,$(CPC_TARGET)) $(addsuffix _clean,$(TARGET_DIRS))
  661. distclean: tempclean execlean cleanall $(addsuffix _clean,$(ALLTARGETS) $(BETATARGETS)) $(addsuffix _distclean,$(TARGET_DIRS))
  662. #####################################################################
  663. # Make targets
  664. #####################################################################
  665. $(MSG2INC): $(COMPILER_TARGETDIR) $(COMPILER_UNITTARGETDIR) $(COMPILERUTILSDIR)/msg2inc.pp
  666. $(COMPILER) -FE. $(COMPILERUTILSDIR)/msg2inc.pp
  667. # The msgtxt.inc only depends on the error?.msg file, not on msg2inc,
  668. # because that one will be new almost everytime
  669. msgtxt.inc: $(MSGFILE)
  670. $(MAKE) $(MSG2INC)
  671. $(MSG2INC) $(MSGFILE) msg msg
  672. msg: msgtxt.inc
  673. insdatx86 : $(COMPILER_UNITTARGETDIR) x86/x86ins.dat
  674. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkx86ins.pp
  675. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86ins$(SRCEXEEXT) i8086 && mv -f i8086tab.inc i8086op.inc i8086nop.inc i8086att.inc i8086atts.inc i8086int.inc i8086prop.inc ../i8086
  676. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86ins$(SRCEXEEXT) && mv -f i386tab.inc i386op.inc i386nop.inc i386att.inc i386atts.inc i386int.inc i386prop.inc ../i386
  677. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86ins$(SRCEXEEXT) x86_64 && mv -f x8664tab.inc x8664op.inc x8664nop.inc x8664att.inc x8664ats.inc x8664int.inc x8664pro.inc ../x86_64
  678. insdatarm : arm/armins.dat
  679. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkarmins.pp
  680. cd arm && ..$(PATHSEP)utils$(PATHSEP)mkarmins$(SRCEXEEXT)
  681. insdataarch64 : aarch64/a64ins.dat
  682. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mka64ins.pp
  683. cd aarch64 && ..$(PATHSEP)utils$(PATHSEP)mka64ins$(SRCEXEEXT)
  684. insdatz80 : z80/z80ins.dat
  685. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkz80ins.pp
  686. cd z80 && ..$(PATHSEP)utils$(PATHSEP)mkz80ins$(SRCEXEEXT)
  687. insdatloongarch64 : loongarch64/loongarchins.dat
  688. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkloongarch64ins.pp
  689. cd loongarch64 && ..$(PATHSEP)utils$(PATHSEP)mkloongarch64ins$(SRCEXEEXT)
  690. insdat: insdatx86 insdatarm insdataarch64 insdatz80 insdatloongarch64
  691. regdatx86 : x86/x86reg.dat
  692. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkx86reg.pp
  693. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86reg$(SRCEXEEXT) i8086
  694. mv -f x86/r8086*.inc i8086
  695. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86reg$(SRCEXEEXT)
  696. mv -f x86/r386*.inc i386
  697. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86reg$(SRCEXEEXT) x86_64
  698. mv -f x86/r8664*.inc x86_64
  699. regdatarm : arm/armreg.dat
  700. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkarmreg.pp
  701. cd arm && ..$(PATHSEP)utils$(PATHSEP)mkarmreg$(SRCEXEEXT)
  702. regdatsp : sparcgen/spreg.dat
  703. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkspreg.pp
  704. cd sparcgen && ..$(PATHSEP)utils$(PATHSEP)mkspreg$(SRCEXEEXT)
  705. mv -f sparcgen/rsp*.inc sparc
  706. regdatsp64 : sparcgen/spreg.dat
  707. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkspreg.pp
  708. cd sparcgen && ..$(PATHSEP)utils$(PATHSEP)mkspreg$(SRCEXEEXT) sparc64
  709. mv -f sparcgen/rsp*.inc sparc64
  710. regdatavr : avr/avrreg.dat
  711. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkavrreg.pp
  712. cd avr && ..$(PATHSEP)utils$(PATHSEP)mkavrreg$(SRCEXEEXT)
  713. regdataarch64 : aarch64/a64reg.dat
  714. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mka64reg.pp
  715. cd aarch64 && ..$(PATHSEP)utils$(PATHSEP)mka64reg$(SRCEXEEXT)
  716. regdatmips : mips/mipsreg.dat
  717. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkmpsreg.pp
  718. cd mips && ..$(PATHSEP)utils$(PATHSEP)mkmpsreg$(SRCEXEEXT)
  719. regdatz80 : z80/z80reg.dat
  720. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkz80reg.pp
  721. cd z80 && ..$(PATHSEP)utils$(PATHSEP)mkz80reg$(SRCEXEEXT)
  722. regdatwasm : wasm32/wasmreg.dat
  723. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkwasmreg.pp
  724. cd wasm32 && ..$(PATHSEP)utils$(PATHSEP)mkwasmreg$(SRCEXEEXT)
  725. regdatrv32 : riscv/rvreg.dat
  726. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkrvreg.pp
  727. cd riscv && ..$(PATHSEP)utils$(PATHSEP)mkrvreg$(SRCEXEEXT) riscv32
  728. mv -f riscv/rrv32*.inc riscv32
  729. regdatrv64 : riscv/rvreg.dat
  730. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkrvreg.pp
  731. cd riscv && ..$(PATHSEP)utils$(PATHSEP)mkrvreg$(SRCEXEEXT) riscv64
  732. mv -f riscv/rrv64*.inc riscv64
  733. regdatloongarch64 : loongarch64/loongarchreg.dat
  734. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkloongarch64reg.pp
  735. cd loongarch64 && ..$(PATHSEP)utils$(PATHSEP)mkloongarch64reg$(SRCEXEEXT)
  736. regdat : regdatx86 regdatarm regdatsp regdatavr regdataarch64 regdatmips regdatsp64 regdatz80 regdatwasm regdatrv32 regdatrv64 regdatloongarch64
  737. intrdatx86 : x86/x86intr.dat
  738. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkx86inl.pp
  739. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86inl$(SRCEXEEXT)
  740. cp -f x86/cpummprocs.inc ../rtl/x86_64
  741. cp -f x86/cpumminnr.inc ../rtl/x86_64
  742. cp -f x86/cpummprocs.inc ../rtl/i386
  743. cp -f x86/cpumminnr.inc ../rtl/i386
  744. intrdat : intrdatx86
  745. # revision.inc rule
  746. revision.inc :
  747. ifneq ($(REVSTR),)
  748. ifdef USEZIPWRAPPER
  749. ifneq ($(ECHOREDIR),echo)
  750. $(ECHOREDIR) "'$(REVSTR)'" > revision.inc
  751. else
  752. $(ECHOREDIR) '$(REVSTR)' > revision.inc
  753. endif
  754. else
  755. $(ECHOREDIR) "'$(REVSTR)'" > revision.inc
  756. endif
  757. else
  758. $(MAKE) revision.inc REVINC=force
  759. endif
  760. ifeq ($(COMPILEREXENAME),)
  761. COMPILEREXENAME:=$(EXENAME)
  762. endif
  763. .PHONY : revision
  764. revision :
  765. $(DEL) revision.inc
  766. $(MAKE) revision.inc
  767. # Make only the compiler
  768. # ECHOREDIR sometimes does not remove double quotes
  769. $(EXENAME) : $(wildcard *.pas) $(wildcard *.inc) msg \
  770. $(wildcard systems/*.pas) $(wilcard systems/*.inc) \
  771. $(wildcard $(CPC_TARGET)/*.pas) $(wildcard $(CPC_TARGET)/*.inc) \
  772. $(COMPILER_UNITTARGETDIR) $(COMPILER_TARGETDIR)
  773. ifneq ($(REVSTR),)
  774. ifdef USEZIPWRAPPER
  775. ifneq ($(ECHOREDIR),echo)
  776. $(ECHOREDIR) "'$(REVSTR)'" > revision.inc
  777. else
  778. $(ECHOREDIR) '$(REVSTR)' > revision.inc
  779. endif
  780. else
  781. $(ECHOREDIR) "'$(REVSTR)'" > revision.inc
  782. endif
  783. $(COMPILER) version.pas
  784. endif
  785. $(COMPILER) -o$(BASEDIR)/$(COMPILEREXENAME) pp.pas
  786. $(EXECPPAS)
  787. #####################################################################
  788. # Cycle targets
  789. #
  790. # 1. Source CPU = Target CPU and Source OS = Target OS
  791. # Normal cycle
  792. #
  793. # 2. Source CPU = Target CPU and Source OS <> Target OS
  794. # First source native compiler
  795. # Second target native compiler (skipped for cross installation)
  796. #
  797. # 3. Source CPU <> Target CPU
  798. # First source native compiler
  799. # Second cross compiler
  800. # Third target native compiler (skipped for cross installation)
  801. #
  802. #####################################################################
  803. .PHONY: cycle full full_targets fullcycle wpocycle
  804. ifeq ($(CPU_SOURCE),$(PPC_TARGET))
  805. ifeq ($(OS_SOURCE),$(OS_TARGET))
  806. ##########################
  807. # Normal cycle
  808. #
  809. ifndef NOWPOCYCLE
  810. ifdef RELEASE
  811. DOWPOCYCLE=1
  812. endif
  813. endif
  814. ifdef DOWPOCYCLE
  815. # Two WPO cycles in case of RELEASE=1
  816. wpocycle:
  817. # don't use cycle_clean, it will delete the compiler utilities again
  818. $(RM) $(EXENAME)
  819. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3PREFIX)$(TEMPNAME3)' 'OPT=$(strip $(LOCALOPT) $(OPTWPOCOLLECT) $(OPTNEW))' compiler
  820. $(RM) $(EXENAME)
  821. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3PREFIX)$(TEMPNAME3)' 'OPT=$(strip $(RTLOPT) $(OPTWPOPERFORM) $(OPTNEW))' rtlclean
  822. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3PREFIX)$(TEMPNAME3)' 'OPT=$(strip $(RTLOPT) $(OPTWPOPERFORM) $(OPTNEW))' rtl
  823. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3PREFIX)$(TEMPNAME3)' 'OPT=$(strip $(LOCALOPT) $(OPTNEW) $(OPTWPOPERFORM) $(subst pp1.wpo,pp2.wpo,$(OPTWPOCOLLECT)))' $(addsuffix _clean,$(ALLTARGETS))
  824. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3PREFIX)$(TEMPNAME3)' 'OPT=$(strip $(LOCALOPT) $(OPTNEW) $(OPTWPOPERFORM) $(subst pp1.wpo,pp2.wpo,$(OPTWPOCOLLECT)))' 'COMPILEREXENAME=$(TEMPWPONAME1PREFIX)$(TEMPWPONAME1)' compiler
  825. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPWPONAME1PREFIX)$(TEMPWPONAME1)' 'OPT=$(strip $(RTLOPT) $(OPTNEW) $(subst pp1.wpo,pp2.wpo,$(OPTWPOPERFORM)))' rtlclean
  826. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPWPONAME1PREFIX)$(TEMPWPONAME1)' 'OPT=$(strip $(RTLOPT) $(OPTNEW) $(subst pp1.wpo,pp2.wpo,$(OPTWPOPERFORM)))' rtl
  827. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPWPONAME1PREFIX)$(TEMPWPONAME1)' 'OPT=$(strip $(LOCALOPT) $(OPTNEW) $(subst pp1.wpo,pp2.wpo,$(OPTWPOPERFORM)))' $(addsuffix _clean,$(ALLTARGETS))
  828. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPWPONAME1PREFIX)$(TEMPWPONAME1)' 'OPT=$(strip $(LOCALOPT) $(OPTNEW) $(subst pp1.wpo,pp2.wpo,$(OPTWPOPERFORM)))' 'COMPILEREXENAME=$(EXENAME)' compiler
  829. else
  830. wpocycle:
  831. endif
  832. # Used to avoid unnecessary steps
  833. ifdef DIFF
  834. ifdef OLDFPC
  835. ifneq ($(OS_TARGET),darwin)
  836. DIFFRESULT:=$(shell $(DIFF) $(OLDFPC) $(FPC))
  837. else
  838. ifneq ($(CODESIGN),)
  839. DIFFRESULT:=$(shell $(COPY) $(OLDFPC) $(OLDFPC).tmp; $(COPY) $(FPC) $(FPC).tmp; strip -no_uuid $(OLDFPC).tmp; strip -no_uuid $(FPC).tmp; $(CODESIGN) --remove-signature $(OLDFPC).tmp; $(CODESIGN) --remove-signature $(FPC).tmp; $(DIFF) $(OLDFPC).tmp $(FPC).tmp; $(RMPROG) $(OLDFPC).tmp $(FPC).tmp)
  840. else
  841. DIFFRESULT:=$(shell $(COPY) $(OLDFPC) $(OLDFPC).tmp; $(COPY) $(FPC) $(FPC).tmp; strip -no_uuid $(OLDFPC).tmp; strip -no_uuid $(FPC).tmp; $(DIFF) $(OLDFPC).tmp $(FPC).tmp; $(RMPROG) $(OLDFPC).tmp $(FPC).tmp)
  842. endif
  843. endif
  844. else
  845. DIFFRESULT=Not equal
  846. endif
  847. else
  848. DIFFRESULT=No diff program
  849. endif
  850. ifndef DIFFRESULT
  851. next :
  852. @echo $(OLDFPC) and $(FPC) are equal
  853. $(COPY) $(FPC) $(EXENAME)
  854. else
  855. next :
  856. $(MAKE) rtlclean
  857. $(MAKE) rtl
  858. $(MAKE) cycleclean
  859. $(MAKE) compiler
  860. $(MAKE) echotime
  861. endif
  862. $(TEMPNAME1) :
  863. $(MAKE) 'OLDFPC=' next CYCLELEVEL=1 'COMPILEREXENAME=$(TEMPNAME1PREFIX)$(TEMPNAME1)'
  864. $(TEMPNAME2) : $(TEMPNAME1)
  865. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME1PREFIX)$(TEMPNAME1)' 'OLDFPC=' next CYCLELEVEL=2 'COMPILEREXENAME=$(TEMPNAME2REFIX)$(TEMPNAME2)'
  866. $(TEMPNAME3) : $(TEMPNAME2)
  867. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME2PREFIX)$(TEMPNAME2)' 'OLDFPC=$(BASEDIR)/$(TEMPNAME1)' next CYCLELEVEL=3
  868. -$(DEL) $(TEMPNAME3)
  869. $(MOVE) $(EXENAME) $(TEMPNAME3)
  870. cycle:
  871. ifdef NEED_G_COMPILERS
  872. $(MAKE) fpcmade.generate_g_compilers
  873. endif
  874. $(MAKE) tempclean
  875. $(MAKE) $(TEMPNAME3)
  876. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3PREFIX)$(TEMPNAME3)' 'OLDFPC=$(BASEDIR)/$(TEMPNAME2)' next CYCLELEVEL=4
  877. ifneq ($(OS_TARGET), darwin)
  878. $(DIFF) $(TEMPNAME3) $(EXENAME)
  879. else
  880. $(COPY) $(TEMPNAME3) $(TEMPNAME3).tmp
  881. $(COPY) $(EXENAME) $(EXENAME).tmp
  882. strip -no_uuid $(TEMPNAME3).tmp
  883. strip -no_uuid $(EXENAME).tmp
  884. ifneq ($(CODESIGN),)
  885. $(CODESIGN) --remove-signature $(TEMPNAME3).tmp
  886. $(CODESIGN) --remove-signature $(EXENAME).tmp
  887. endif
  888. $(DIFF) $(TEMPNAME3).tmp $(EXENAME).tmp
  889. rm $(TEMPNAME3).tmp $(EXENAME).tmp
  890. endif
  891. $(MAKE) $(addsuffix _all,$(TARGET_DIRS)) 'FPC=$(BASEDIR)/$(EXENAMEPREFIX)$(EXENAME)'
  892. $(MAKE) wpocycle
  893. $(MAKE) echotime
  894. else
  895. ##########################
  896. # Cross Target cycle
  897. #
  898. cycle:
  899. ifdef NEED_G_COMPILERS
  900. $(MAKE) fpcmade.generate_g_compilers
  901. endif
  902. # ppc (source native)
  903. $(MAKE) OS_TARGET=$(OS_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=1 rtlclean
  904. $(MAKE) OS_TARGET=$(OS_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=1 rtl
  905. $(MAKE) OS_TARGET=$(OS_SOURCE) EXENAME=$(TEMPNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=1 cycleclean
  906. $(MAKE) OS_TARGET=$(OS_SOURCE) EXENAME=$(TEMPNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=1 compiler
  907. # ppcross<ARCH> (source native)
  908. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAMEPREFIX)$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=2 rtlclean
  909. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAMEPREFIX)$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=2 rtl
  910. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAMEPREFIX)$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) EXENAME=$(PPCROSSNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=2 cycleclean
  911. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAMEPREFIX)$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) EXENAME=$(PPCROSSNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=2 compiler
  912. # ppc<ARCH> (target native)
  913. ifndef CROSSINSTALL
  914. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAMEPREFIX)$(PPCROSSNAME)' CYCLELEVEL=3 rtlclean
  915. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAMEPREFIX)$(PPCROSSNAME)' CYCLELEVEL=3 rtl
  916. ifndef NoNativeBinaries
  917. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAMEPREFIX)$(PPCROSSNAME)' CYCLELEVEL=3 cycleclean
  918. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAMEPREFIX)$(PPCROSSNAME)' CYCLELEVEL=3 compiler
  919. endif
  920. endif
  921. endif
  922. else
  923. ##########################
  924. # Cross CPU cycle
  925. #
  926. # ppc1 = native
  927. # ppc2 = cross running on this platform
  928. # ppc3/ppcXXX = native (skipped for cross installation)
  929. #
  930. cycle: override FPC=
  931. cycle:
  932. ifdef NEED_G_COMPILERS
  933. $(MAKE) fpcmade.generate_g_compilers
  934. endif
  935. # ppc (source native)
  936. # Clear detected compiler binary, because it can be existing crosscompiler binary, but we need native compiler here
  937. $(MAKE) OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=1 rtlclean
  938. $(MAKE) OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=1 rtl
  939. $(MAKE) OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) EXENAME=$(TEMPNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=1 cycleclean
  940. $(MAKE) OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) EXENAME=$(TEMPNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=1 compiler
  941. # ppcross<ARCH> (source native)
  942. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAMEPREFIX)$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=2 rtlclean
  943. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAMEPREFIX)$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=2 rtl
  944. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAMEPREFIX)$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) PPC_TARGET=$(CPU_TARGET) EXENAME=$(PPCROSSNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=2 cycleclean
  945. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAMEPREFIX)$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) PPC_TARGET=$(CPU_TARGET) EXENAME=$(PPCROSSNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 CYCLELEVEL=2 compiler
  946. # ppc<ARCH> (target native)
  947. ifndef CROSSINSTALL
  948. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAMEPREFIX)$(PPCROSSNAME)' 'OPT=$(RTLOPT) $(CROSSOPT)' CYCLELEVEL=3 rtlclean
  949. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAMEPREFIX)$(PPCROSSNAME)' 'OPT=$(RTLOPT) $(CROSSOPT)' CYCLELEVEL=3 rtl
  950. ifndef NoNativeBinaries
  951. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAMEPREFIX)$(PPCROSSNAME)' 'OPT=$(strip $(LOCALOPT) $(CROSSOPT))' CYCLELEVEL=3 cycleclean
  952. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAMEPREFIX)$(PPCROSSNAME)' 'OPT=$(strip $(LOCALOPT) $(CROSSOPT))' CYCLELEVEL=3 compiler
  953. endif
  954. endif
  955. endif
  956. cycledep:
  957. $(MAKE) cycle USEDEPEND=1
  958. # extcycle should still work, but generates
  959. # lots of warnings, so ALLOW_WARNINGS=1 is required
  960. extcycle:
  961. $(MAKE) cycle RTLOPT="$(RTLOPT) -n -glttt -CRriot -dEXTDEBUG" LOCALOPT="$(LOCALOPT) -n -glttt -CRriot -dEXTDEBUG" ALLOW_WARNINGS=1
  962. extoptcycle:
  963. $(MAKE) cycle RTLOPT="$(RTLOPT) -n -glttt -CRriot -dEXTDEBUG -dDEBUG_ALL_OPT" LOCALOPT="$(LOCALOPT) -n -glttt -CRriot -dEXTDEBUG -dDEBUG_ALL_OPT" ALLOW_WARNINGS=1
  964. cvstest:
  965. $(MAKE) cycle 'LOCALOPT=-n -Se' 'RTLOPT=-n -Se'
  966. ##########################
  967. # Full cycle
  968. #
  969. # 1. build a compiler using cycle
  970. # 2. remove all .ppufiles
  971. # 3. clean and recompile rtl if DOWPOCYCLE is set
  972. # 4. build all supported cross compilers except the
  973. # current PPC_TARGET which was already build
  974. # unless FPC_SUPPORT_X87_TYPES_ON_WIN64 is set,
  975. # win64 cannot compile i386 or i8086 compiler
  976. # This is also the case for other CPUs that don't support
  977. # 80bit real type, unless -dFPC_SOFT_FPUX80
  978. # option is used.
  979. ifeq ($(findstring -dFPC_SOFT_FPUX80,$(LOCALOPT)),)
  980. ifeq ($(OS_SOURCE),win64)
  981. EXCLUDE_80BIT_TARGETS=1
  982. endif
  983. ifneq ($(findstring $(CPU_SOURCE),aarch64 arm avr jvm m68k mips mipsel mips64 mips64el powerpc powerpc64 sparc sparc64 riscv32 riscv64 xtensa loongarch64),)
  984. EXCLUDE_80BIT_TARGETS=1
  985. endif
  986. endif
  987. ifndef EXCLUDE_80BIT_TARGETS
  988. FULL_TARGETS=$(filter-out $(PPC_TARGET),$(CYCLETARGETS))
  989. else
  990. FULL_TARGETS=$(filter-out x86_64,$(filter-out i8086,$(filter-out i386,$(filter-out $(PPC_TARGET),$(CYCLETARGETS)))))
  991. endif
  992. full: fullcycle
  993. fullcycle:
  994. $(MAKE) distclean
  995. $(MAKE) cycle
  996. $(MAKE) ppuclean
  997. ifdef DOWPOCYCLE
  998. $(MAKE) rtlclean
  999. $(MAKE) rtl 'FPC=$(BASEDIR)/$(EXENAMEPREFIX)$(EXENAME)'
  1000. endif
  1001. $(MAKE) $(FULL_TARGETS) 'FPC=$(BASEDIR)/$(EXENAMEPREFIX)$(EXENAME)'
  1002. full_targets:
  1003. $(MAKE) $(FULL_TARGETS)
  1004. #####################################################################
  1005. # Docs
  1006. #####################################################################
  1007. htmldocs:
  1008. $(PASDOC) -p -h -o html$(PATHSEP)$(PPC_TARGET) -d fpc -d gdb -d $(PPC_TARGET) -u $(PPC_TARGET) $(PPC_TARGET)$(PATHSEP)*.pas systems$(PATHSEP)*.pas *.pas
  1009. #####################################################################
  1010. # Installation
  1011. #####################################################################
  1012. .PHONY: quickinstall exeinstall install installsymlink fullinstall fullinstallsymlink
  1013. MSGINSTALLDIR=$(INSTALL_BASEDIR)/msg
  1014. override PPEXEFILE:=$(wildcard $(EXENAME))
  1015. ifdef UNIXHier
  1016. PPCCPULOCATION=$(INSTALL_BASEDIR)
  1017. else
  1018. PPCCPULOCATION=$(INSTALL_BINDIR)
  1019. endif
  1020. ifndef NoNativeBinaries
  1021. quickinstall: quickinstall_withutils
  1022. else
  1023. quickinstall: exeinstall
  1024. endif
  1025. # This will only install the ppcXXX executable, not the message files etc.
  1026. quickinstall_withutils: $(addsuffix _install,$(TARGET_DIRS)) exeinstall
  1027. # Install ppcXXX executable, for a cross installation we install
  1028. # the ppcrossXXX as ppcXXX. The target native build ppcXXX is not used
  1029. # for this installation type
  1030. exeinstall:
  1031. ifneq ($(INSTALLEXEFILE),)
  1032. ifdef UPXPROG
  1033. -$(UPXPROG) $(INSTALLEXEFILE)
  1034. endif
  1035. $(MKDIR) $(PPCCPULOCATION)
  1036. $(INSTALLEXE) $(INSTALLEXEFILE) $(PPCCPULOCATION)/$(INSTALLEXEFILE)
  1037. endif
  1038. fullinstall:
  1039. $(MAKE) $(addsuffix _exe_install,$(FULL_TARGETS))
  1040. $(MAKE) $(addsuffix _all,$(TARGET_DIRS))
  1041. $(MAKE) $(addsuffix _install,$(TARGET_DIRS))
  1042. auxfilesinstall:
  1043. ifndef CROSSINSTALL
  1044. ifdef UNIXHier
  1045. $(MKDIR) $(INSTALL_BASEDIR)
  1046. $(INSTALLEXE) $(COMPILERUTILSDIR)/samplecfg $(INSTALL_BASEDIR)/samplecfg
  1047. endif
  1048. $(MKDIR) $(MSGINSTALLDIR)
  1049. $(INSTALL) $(MSGFILES) $(MSGINSTALLDIR)
  1050. endif
  1051. install:
  1052. # if no FPC is passed, use that one we assume, we just build
  1053. ifndef FPC
  1054. $(MAKE) quickinstall auxfilesinstall FPC=$(BASEDIR)/$(INSTALLEXEFILE)
  1055. else
  1056. $(MAKE) quickinstall auxfilesinstall
  1057. endif
  1058. # This also installs a link from bin to the actual executable.
  1059. # The .deb does that later.
  1060. installsymlink: exeinstall
  1061. ifneq ($(PPCCPULOCATION),$(INSTALL_BINDIR))
  1062. $(MKDIR) $(INSTALL_BINDIR)
  1063. ln -sf $(INSTALL_BASEDIR)/$(EXENAME) $(INSTALL_BINDIR)/$(EXENAME)
  1064. endif
  1065. fullinstallsymlink:
  1066. $(MAKE) $(addsuffix _symlink_install,$(FULL_TARGETS))
  1067. #####################################################################
  1068. # RTL
  1069. #####################################################################
  1070. .PHONY: rtl rtlclean rtlinstall
  1071. rtl:
  1072. $(MAKE) -C $(PACKAGEDIR_RTL) 'OPT=$(RTLOPT)' all
  1073. rtlclean:
  1074. $(MAKE) -C $(PACKAGEDIR_RTL) clean
  1075. rtlinstall:
  1076. $(MAKE) -C $(PACKAGEDIR_RTL) install
  1077. #####################################################################
  1078. # PPU testing targets
  1079. #####################################################################
  1080. PPUDIR=$(COMPILER_UNITTARGETDIR)
  1081. ALLPPUDIR=$(CPU_TARGET)/units/*
  1082. PPULIST=$(wildcard $(PPUDIR)/*.ppu)
  1083. PPULOGLIST=$(subst .ppu,.log-ppu,$(PPULIST))
  1084. RTLPPUDIR=../rtl/units/$(TARGETSUFFIX)
  1085. RTLPPULIST=$(wildcard $(RTLPPUDIR)/*.ppu)
  1086. RTLPPULOGLIST=$(subst .ppu,.log-ppu,$(RTLPPULIST))
  1087. .PHONY : ppulogs cleanppulogs rtlppulogs cleanrtlppulogs testppudump
  1088. ppulogs : $(PPULOGLIST)
  1089. rtlppulogs : $(RTLPPULOGLIST)
  1090. vpath %.ppu $(PPUDIR) $(RTLPPUDIR) $(ALLPPUDIR)
  1091. vpath %.log-ppu $(PPUDIR) $(RTLPPUDIR) $(ALLPPUDIR)
  1092. # Use installed ppudump
  1093. %.log-ppu : %.ppu
  1094. $(PPUDUMP) -VA -M $< > $@
  1095. ./utils/ppudump$(EXEEXT):
  1096. $(MAKE) -C $(COMPILERUTILSDIR) ppudump$(EXEEXT)
  1097. ppuinfo :
  1098. echo PPU list is "$(PPULIST)"
  1099. echo PPULOG list is "$(PPULOGLIST)"
  1100. echo RTLPPUDIR is "$(RTLPPUDIR)"
  1101. echo RTLPPU list is "$(RTLPPULIST)"
  1102. cleanppulogs :
  1103. -$(RMPROG) $(PPULOGLIST)
  1104. cleanrtlppulogs :
  1105. -$(RMPROG) $(RTLPPULOGLIST)
  1106. testppudump :
  1107. $(MAKE) cleanrtlppulogs cleanppulogs
  1108. $(MAKE) ppulogs rtlppulogs
  1109. #####################################################################
  1110. # local user configurable file
  1111. # in makefile.loc you can add any desired target
  1112. #####################################################################
  1113. localmake:=$(strip $(wildcard makefile.loc))
  1114. ifdef localmake
  1115. include ./$(localmake)
  1116. endif