Makefile.fpc 33 KB

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