Makefile.fpc 34 KB

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