Makefile.fpc 36 KB

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