Makefile.fpc 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. #
  2. # Makefile.fpc for Free Pascal Compiler
  3. #
  4. [package]
  5. name=compiler
  6. version=3.2.0rc1
  7. [target]
  8. programs=pp
  9. dirs=utils
  10. [compiler]
  11. targetdir=.
  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
  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. # Default is to generate a compiler for the same
  76. # platform as CPU_TARGET (a native compiler)
  77. ifndef PPC_TARGET
  78. PPC_TARGET=$(CPU_TARGET)
  79. endif
  80. ifeq ($(PPC_TARGET),armeb)
  81. CPC_TARGET=arm
  82. else
  83. CPC_TARGET=$(PPC_TARGET)
  84. endif
  85. # Default is to generate a compiler for the same
  86. # target as OS_TARGET (a native compiler)
  87. ifndef PPC_OS
  88. PPC_OS=$(OS_TARGET)
  89. endif
  90. # Where to place the unit files.
  91. CPU_UNITDIR=$(CPC_TARGET)
  92. # RTL
  93. UTILSDIR=../utils
  94. # Directories containing compiler sources
  95. COMPILERSOURCEDIR=$(CPC_TARGET) systems
  96. # Utils used by compiler development/installation
  97. COMPILERUTILSDIR=utils
  98. # Default language for the compiler
  99. ifndef FPCLANG
  100. FPCLANG=e
  101. endif
  102. # Local options for the compiler only
  103. ifndef LOCALOPT
  104. LOCALOPT:=$(OPT)
  105. endif
  106. # Options for the RTL only when cycling
  107. ifndef RTLOPT
  108. RTLOPT:=$(OPT)
  109. endif
  110. ifdef CYCLELEVEL
  111. ifeq ($(CYCLELEVEL),1)
  112. override LOCALOPT+=$(OPTLEVEL1)
  113. override RTLOPT+=$(OPTLEVEL1)
  114. override LOCALOPT+=$(LOCALOPTLEVEL1)
  115. override RTLOPT+=$(RTLOPTLEVEL1)
  116. endif
  117. ifeq ($(CYCLELEVEL),2)
  118. override LOCALOPT+=$(OPTLEVEL2)
  119. override RTLOPT+=$(OPTLEVEL2)
  120. override LOCALOPT+=$(LOCALOPTLEVEL2)
  121. override RTLOPT+=$(RTLOPTLEVEL2)
  122. override LOCALOPT+=$(OPTNEW)
  123. override RTLOPT+=$(OPTNEW)
  124. endif
  125. ifeq ($(CYCLELEVEL),3)
  126. override LOCALOPT+=$(OPTLEVEL3)
  127. override RTLOPT+=$(OPTLEVEL3)
  128. override LOCALOPT+=$(LOCALOPTLEVEL3)
  129. override RTLOPT+=$(RTLOPTLEVEL3)
  130. override LOCALOPT+=$(OPTNEW)
  131. override RTLOPT+=$(OPTNEW)
  132. endif
  133. ifeq ($(CYCLELEVEL),4)
  134. override LOCALOPT+=$(OPTLEVEL4)
  135. override RTLOPT+=$(OPTLEVEL4)
  136. override LOCALOPT+=$(LOCALOPTLEVEL4)
  137. override RTLOPT+=$(RTLOPTLEVEL4)
  138. override LOCALOPT+=$(OPTNEW)
  139. override RTLOPT+=$(OPTNEW)
  140. endif
  141. endif
  142. # Make OPT empty. It is copied to LOCALOPT and RTLOPT
  143. override OPT=
  144. # Message files
  145. MSGFILES=$(wildcard msg/error*.msg)
  146. # ppcSUFFIX
  147. ifeq ($(CPC_TARGET),i386)
  148. CPUSUF=386
  149. endif
  150. ifeq ($(CPC_TARGET),m68k)
  151. CPUSUF=68k
  152. ALLOW_WARNINGS=1
  153. endif
  154. ifeq ($(CPC_TARGET),powerpc)
  155. CPUSUF=ppc
  156. endif
  157. ifeq ($(CPC_TARGET),powerpc64)
  158. CPUSUF=ppc64
  159. endif
  160. ifeq ($(CPC_TARGET),sparc)
  161. CPUSUF=sparc
  162. endif
  163. ifeq ($(CPC_TARGET),sparc64)
  164. CPUSUF=sparc64
  165. endif
  166. ifeq ($(CPC_TARGET),x86_64)
  167. CPUSUF=x64
  168. endif
  169. ifeq ($(CPC_TARGET),arm)
  170. CPUSUF=arm
  171. endif
  172. ifeq ($(CPC_TARGET),mips)
  173. CPUSUF=mips
  174. endif
  175. ifeq ($(CPC_TARGET),mipsel)
  176. CPUSUF=mipsel
  177. endif
  178. ifeq ($(CPC_TARGET),avr)
  179. CPUSUF=avr
  180. ALLOW_WARNINGS=1
  181. endif
  182. ifeq ($(CPC_TARGET),jvm)
  183. CPUSUF=jvm
  184. endif
  185. ifeq ($(CPC_TARGET),i8086)
  186. CPUSUF=8086
  187. endif
  188. ifeq ($(CPC_TARGET),aarch64)
  189. CPUSUF=a64
  190. endif
  191. # Do not define the default -d$(CPU_TARGET) because that
  192. # will conflict with our -d$(CPC_TARGET)
  193. NOCPUDEF=1
  194. # Default message file
  195. MSGFILE=msg/error$(FPCLANG).msg
  196. SVNVERSION:=$(firstword $(wildcard $(addsuffix /svnversion$(SRCEXEEXT),$(SEARCHPATH))))
  197. # Check if revision.inc is present
  198. REVINC:=$(wildcard revision.inc)
  199. ifneq ($(REVINC),)
  200. # File revision.inc is present
  201. #Use it to compile version.pas unit
  202. override LOCALOPT+=-dREVINC
  203. # Automatically update revision.inc if
  204. # svnversion executable is available
  205. ifeq ($(REVSTR),)
  206. ifneq ($(SVNVERSION),)
  207. REVSTR:=$(subst r,,$(subst r1:,,r$(subst exported,,$(shell $(SVNVERSION) -c .))))
  208. export REVSTR
  209. else
  210. ifeq ($(REVINC),force)
  211. REVSTR:=exported
  212. export REVSTR
  213. endif
  214. endif
  215. endif
  216. endif
  217. # set correct defines (-d$(CPU_TARGET) is automatically added in makefile.fpc)
  218. override LOCALOPT+=-d$(CPC_TARGET) -dGDB -dBROWSERLOG
  219. #include LLVM define/directory if requested
  220. ifdef LLVM
  221. ifeq ($(findstring $(PPC_TARGET),x86_64),)
  222. $(error The $(PPC_TARGET) architecture is not (yet) support by the FPC/LLVM code generator)
  223. endif
  224. ifeq ($(findstring $(OS_TARGET),darwin iphonesim linux),)
  225. $(error The $(PPC_TARGET) target OS is not (yet) support by the FPC/LLVM code generator)
  226. endif
  227. override LOCALOPT+=-dllvm -Fullvm
  228. endif
  229. # i386 specific
  230. ifeq ($(PPC_TARGET),i386)
  231. override LOCALOPT+=-Fux86
  232. endif
  233. # x86_64 specific
  234. ifeq ($(PPC_TARGET),x86_64)
  235. override LOCALOPT+=-Fux86
  236. endif
  237. # PowerPC specific
  238. ifeq ($(PPC_TARGET),powerpc)
  239. override LOCALOPT+=-Fuppcgen
  240. endif
  241. # PowerPC64 specific
  242. ifeq ($(PPC_TARGET),powerpc64)
  243. override LOCALOPT+=-Fuppcgen
  244. endif
  245. # m68k specific
  246. ifeq ($(PPC_TARGET),m68k)
  247. override LOCALOPT+=
  248. endif
  249. # Sparc specific
  250. ifeq ($(PPC_TARGET),sparc)
  251. override LOCALOPT+=-Fusparcgen -Fisparcgen
  252. endif
  253. # Sparc specific
  254. ifeq ($(PPC_TARGET),sparc64)
  255. override LOCALOPT+=-Fusparcgen -Fisparcgen
  256. endif
  257. # ARM specific
  258. ifeq ($(PPC_TARGET),arm)
  259. override LOCALOPT+=
  260. endif
  261. # mipsel specific
  262. ifeq ($(PPC_TARGET),mipsel)
  263. override LOCALOPT+=-Fumips
  264. endif
  265. # jvm specific
  266. ifeq ($(PPC_TARGET),jvm)
  267. override LOCALOPT+=-Fujvm
  268. endif
  269. # i8086 specific
  270. ifeq ($(PPC_TARGET),i8086)
  271. override LOCALOPT+=-Fux86
  272. endif
  273. OPTWPOCOLLECT=-OWdevirtcalls,optvmts -FW$(BASEDIR)/pp1.wpo
  274. OPTWPOPERFORM=-Owdevirtcalls,optvmts -Fw$(BASEDIR)/pp1.wpo
  275. # symbol liveness WPO requires nm, smart linking and no stripping (the latter
  276. # is forced by the Makefile when necessary)
  277. ifneq ($(findstring $(OS_TARGET),darwin linux dragonfly freebsd solaris),)
  278. ifdef LINKSMART
  279. ifdef CREATESMART
  280. OPTWPOCOLLECT+=-OWsymbolliveness -Xs-
  281. OPTWPOPERFORM+=-Owsymbolliveness
  282. endif
  283. endif
  284. endif
  285. # Don't compile a native compiler & utilities for JVM and embedded
  286. # targets
  287. ifeq ($(CPU_TARGET),jvm)
  288. NoNativeBinaries=1
  289. endif
  290. ifeq ($(OS_TARGET),embedded)
  291. NoNativeBinaries=1
  292. endif
  293. ifeq ($(OS_TARGET),gba)
  294. NoNativeBinaries=1
  295. endif
  296. ifeq ($(OS_TARGET),msdos)
  297. NoNativeBinaries=1
  298. endif
  299. ifeq ($(OS_TARGET),nds)
  300. NoNativeBinaries=1
  301. endif
  302. ifeq ($(OS_TARGET),win16)
  303. NoNativeBinaries=1
  304. endif
  305. ifeq ($(OS_TARGET),macos)
  306. NoNativeBinaries=1
  307. endif
  308. # Allow install for jvm
  309. ifeq ($(NoNativeBinaries),1)
  310. override EXEEXT=$(SRCEXEEXT)
  311. # In those cases, installation in a cross-installation
  312. CROSSINSTALL=1
  313. endif
  314. [rules]
  315. #####################################################################
  316. # Setup Targets
  317. #####################################################################
  318. ifneq ($(findstring $(OS_TARGET),win32 win64 aix),)
  319. USE_CMP_FOR_DIFF=1
  320. endif
  321. ifdef USE_CMP_FOR_DIFF
  322. ifdef CMP
  323. override DIFF:=$(CMP) -i218
  324. endif
  325. endif
  326. # Use -Sew option by default
  327. # Allow disabling by setting ALLOW_WARNINGS=1
  328. ifeq ($(findstring 2.4.,$(FPC_VERSION)),)
  329. ifndef ALLOW_WARNINGS
  330. override LOCALOPT+=-Sew
  331. endif
  332. endif
  333. # Add Local options
  334. override COMPILER+=$(LOCALOPT)
  335. #####################################################################
  336. # PASDoc
  337. #####################################################################
  338. PASDOC:=$(strip $(wildcard $(addsuffix /pasdoc.exe,$(SEARCHPATH))))
  339. ifeq ($(PASDOC),)
  340. PASDOC:=$(strip $(wildcard $(addsuffix /pasdoc,$(SEARCHPATH))))
  341. endif
  342. ifeq ($(PASDOC),)
  343. PASDOC:=../projects/pasdoc/bin/pasdoc
  344. else
  345. PASDOC:=$(firstword $(PASDOC))
  346. endif
  347. #####################################################################
  348. # Setup os-independent filenames
  349. #####################################################################
  350. ifndef EXENAME
  351. EXENAME=ppc$(CPUSUF)$(EXEEXT)
  352. endif
  353. PPEXENAME=pp$(EXEEXT)
  354. TEMPNAME=ppc$(SRCEXEEXT)
  355. ifneq ($(CPUSUF),jvm)
  356. PPCROSSNAME=ppcross$(CPUSUF)$(SRCEXEEXT)
  357. else
  358. PPCROSSNAME=ppc$(CPUSUF)$(SRCEXEEXT)
  359. endif
  360. TEMPNAME1=ppc1$(EXEEXT)
  361. TEMPNAME2=ppc2$(EXEEXT)
  362. TEMPNAME3=ppc3$(EXEEXT)
  363. TEMPWPONAME1=ppcwpo1$(EXEEXT)
  364. TEMPWPONAME2=ppcwpo2$(EXEEXT)
  365. MAKEDEP=ppdep$(EXEEXT)
  366. MSG2INC=./msg2inc$(EXEEXT)
  367. ifdef CROSSINSTALL
  368. INSTALLEXEFILE=$(PPCROSSNAME)
  369. else
  370. INSTALLEXEFILE=$(EXENAME)
  371. endif
  372. #####################################################################
  373. # CPU targets
  374. #####################################################################
  375. PPC_TARGETS=i386 m68k powerpc sparc arm armeb x86_64 powerpc64 mips mipsel avr jvm i8086 aarch64 sparc64
  376. PPC_SUFFIXES=386 68k ppc sparc arm armeb x64 ppc64 mips mipsel avr jvm 8086 a64 sparc64
  377. INSTALL_TARGETS=$(addsuffix _exe_install,$(sort $(CYCLETARGETS) $(PPC_TARGETS)))
  378. SYMLINKINSTALL_TARGETS=$(addsuffix _symlink_install,$(sort $(CYCLETARGETS) $(PPC_TARGETS)))
  379. .PHONY: $(PPC_TARGETS) $(INSTALL_TARGETS)$(SYMLINKINSTALL_TARGETS)
  380. $(PPC_TARGETS):
  381. $(MAKE) PPC_TARGET=$@ CPU_UNITDIR=$@ all
  382. $(INSTALL_TARGETS):
  383. $(MAKE) all install PPC_TARGET=$(subst _exe_install,,$@) CPU_UNITDIR=$(subst _exe_install,,$@)
  384. $(SYMLINKINSTALL_TARGETS):
  385. $(MAKE) all installsymlink PPC_TARGET=$(subst _symlink_install,,$@) CPU_UNITDIR=$(subst _symlink_install,,$@)
  386. alltargets: $(ALLTARGETS)
  387. #####################################################################
  388. # Default makefile
  389. #####################################################################
  390. .NOTPARALLEL:
  391. .PHONY: all compiler echotime ppuclean execlean clean distclean
  392. all: compiler $(addsuffix _all,$(TARGET_DIRS))
  393. compiler: $(COMPILER_UNITTARGETDIR) $(COMPILER_TARGETDIR) $(EXENAME)
  394. ifeq ($(MAKELEVEL),0)
  395. ifndef STARTTIME
  396. ifdef DATE
  397. STARTTIME:=$(shell $(DATE) +%T)
  398. else
  399. STARTTIME:=unknown
  400. endif
  401. endif
  402. endif
  403. export STARTTIME
  404. ifdef DATE
  405. ENDTIME=$(shell $(DATE) +%T)
  406. else
  407. ENDTIME:=unknown
  408. endif
  409. echotime:
  410. @echo Start $(STARTTIME) now $(ENDTIME)
  411. ppuclean:
  412. -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  413. -$(DEL) $(addsuffix /*$(PPUEXT),$(COMPILERSOURCEDIR))
  414. tempclean:
  415. -$(DEL) $(PPCROSSNAME) $(TEMPNAME) $(TEMPNAME1) $(TEMPNAME2) $(TEMPNAME3) $(MSG2INC) pp1.wpo pp2.wpo
  416. execlean :
  417. -$(DEL) $(addsuffix $(EXEEXT), $(addprefix ppc, $(PPC_SUFFIXES)))
  418. -$(DEL) $(addsuffix $(EXEEXT), $(addprefix ppcross, $(PPC_SUFFIXES)))
  419. -$(DEL) $(EXENAME) $(TEMPWPONAME1) $(TEMPWPONAME2)
  420. $(addsuffix _clean,$(ALLTARGETS)):
  421. -$(DELTREE) $(addprefix $(subst _clean,,$@),/units)
  422. -$(DELTREE) $(addprefix $(subst _clean,,$@),/bin)
  423. -$(DEL) $(addprefix $(subst _clean,,$@)/,*$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT))
  424. -$(DEL) $(addprefix $(subst _clean,,$@)/ppc,$(addsuffix $(EXEEXT), $(PPC_SUFFIXES)))
  425. cycleclean: cleanall $(addsuffix _clean,$(CPC_TARGET))
  426. -$(DEL) $(EXENAME)
  427. clean: tempclean execlean cleanall $(addsuffix _clean,$(CPC_TARGET)) $(addsuffix _clean,$(TARGET_DIRS))
  428. distclean: tempclean execlean cleanall $(addsuffix _clean,$(ALLTARGETS)) $(addsuffix _distclean,$(TARGET_DIRS))
  429. #####################################################################
  430. # Make targets
  431. #####################################################################
  432. $(MSG2INC): $(COMPILER_TARGETDIR) $(COMPILER_UNITTARGETDIR) $(COMPILERUTILSDIR)/msg2inc.pp
  433. $(COMPILER) -FE. $(COMPILERUTILSDIR)/msg2inc.pp
  434. # The msgtxt.inc only depends on the error?.msg file, not on msg2inc,
  435. # because that one will be new almost everytime
  436. msgtxt.inc: $(MSGFILE)
  437. $(MAKE) $(MSG2INC)
  438. $(MSG2INC) $(MSGFILE) msg msg
  439. msg: msgtxt.inc
  440. insdatx86 : $(COMPILER_UNITTARGETDIR) x86/x86ins.dat
  441. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkx86ins.pp
  442. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86ins$(SRCEXEEXT) i8086 && mv -f *.inc ../i8086
  443. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86ins$(SRCEXEEXT) && mv -f *.inc ../i386
  444. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86ins$(SRCEXEEXT) x86_64 && mv -f *.inc ../x86_64
  445. insdatarm : arm/armins.dat
  446. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkarmins.pp
  447. cd arm && ..$(PATHSEP)utils$(PATHSEP)mkarmins$(SRCEXEEXT)
  448. insdataarch64 : aarch64/a64ins.dat
  449. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mka64ins.pp
  450. cd aarch64 && ..$(PATHSEP)utils$(PATHSEP)mka64ins$(SRCEXEEXT)
  451. insdat: insdatx86 insdatarm insdataarch64
  452. regdatx86 : x86/x86reg.dat
  453. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkx86reg.pp
  454. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86reg$(SRCEXEEXT) i8086
  455. mv -f x86/r8086*.inc i8086
  456. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86reg$(SRCEXEEXT)
  457. mv -f x86/r386*.inc i386
  458. cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86reg$(SRCEXEEXT) x86_64
  459. mv -f x86/r8664*.inc x86_64
  460. regdatarm : arm/armreg.dat
  461. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkarmreg.pp
  462. cd arm && ..$(PATHSEP)utils$(PATHSEP)mkarmreg$(SRCEXEEXT)
  463. regdatsp : sparcgen/spreg.dat
  464. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkspreg.pp
  465. cd sparcgen && ..$(PATHSEP)utils$(PATHSEP)mkspreg$(SRCEXEEXT)
  466. mv -f sparcgen/rsp*.inc sparc
  467. regdatsp64 : sparcgen/spreg.dat
  468. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkspreg.pp
  469. cd sparcgen && ..$(PATHSEP)utils$(PATHSEP)mkspreg$(SRCEXEEXT) sparc64
  470. mv -f sparcgen/rsp*.inc sparc64
  471. regdatavr : avr/avrreg.dat
  472. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkavrreg.pp
  473. cd avr && ..$(PATHSEP)utils$(PATHSEP)mkavrreg$(SRCEXEEXT)
  474. regdataarch64 : aarch64/a64reg.dat
  475. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mka64reg.pp
  476. cd aarch64 && ..$(PATHSEP)utils$(PATHSEP)mka64reg$(SRCEXEEXT)
  477. regdatmips : mips/mipsreg.dat
  478. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkmpsreg.pp
  479. cd mips && ..$(PATHSEP)utils$(PATHSEP)mkmpsreg$(SRCEXEEXT)
  480. regdat : regdatx86 regdatarm regdatsp regdatavr regdataarch64 regdatmips regdatsp64
  481. # revision.inc rule
  482. revision.inc :
  483. ifneq ($(REVSTR),)
  484. ifdef USEZIPWRAPPER
  485. ifneq ($(ECHOREDIR),echo)
  486. $(ECHOREDIR) "'$(REVSTR)'" > revision.inc
  487. else
  488. $(ECHOREDIR) '$(REVSTR)' > revision.inc
  489. endif
  490. else
  491. $(ECHOREDIR) "'$(REVSTR)'" > revision.inc
  492. endif
  493. else
  494. $(MAKE) revision.inc REVINC=force
  495. endif
  496. .PHONY : revision
  497. revision :
  498. $(DEL) revision.inc
  499. $(MAKE) revision.inc
  500. # Make only the compiler
  501. # ECHOREDIR sometimes does not remove double quotes
  502. $(EXENAME) : $(wildcard *.pas) $(wildcard *.inc) msg \
  503. $(wildcard systems/*.pas) $(wilcard systems/*.inc) \
  504. $(wildcard $(CPC_TARGET)/*.pas) $(wildcard $(CPC_TARGET)/*.inc) \
  505. $(COMPILER_UNITTARGETDIR) $(COMPILER_TARGETDIR)
  506. ifneq ($(REVSTR),)
  507. ifdef USEZIPWRAPPER
  508. ifneq ($(ECHOREDIR),echo)
  509. $(ECHOREDIR) "'$(REVSTR)'" > revision.inc
  510. else
  511. $(ECHOREDIR) '$(REVSTR)' > revision.inc
  512. endif
  513. else
  514. $(ECHOREDIR) "'$(REVSTR)'" > revision.inc
  515. endif
  516. $(COMPILER) version.pas
  517. endif
  518. $(COMPILER) pp.pas
  519. $(EXECPPAS)
  520. $(MOVE) $(COMPILER_TARGETDIR)/$(PPEXENAME) $(EXENAME)
  521. #####################################################################
  522. # Cycle targets
  523. #
  524. # 1. Source CPU = Target CPU and Source OS = Target OS
  525. # Normal cycle
  526. #
  527. # 2. Source CPU = Target CPU and Source OS <> Target OS
  528. # First source native compiler
  529. # Second target native compiler (skipped for cross installation)
  530. #
  531. # 3. Source CPU <> Target CPU
  532. # First source native compiler
  533. # Second cross compiler
  534. # Third target native compiler (skipped for cross installation)
  535. #
  536. #####################################################################
  537. .PHONY: cycle fullcycle wpocycle
  538. ifeq ($(CPU_SOURCE),$(PPC_TARGET))
  539. ifeq ($(OS_SOURCE),$(OS_TARGET))
  540. ##########################
  541. # Normal cycle
  542. #
  543. ifndef NOWPOCYCLE
  544. ifdef RELEASE
  545. DOWPOCYCLE=1
  546. # Two WPO cycles in case of RELEASE=1
  547. wpocycle:
  548. # don't use cycle_clean, it will delete the compiler utilities again
  549. $(RM) $(EXENAME)
  550. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3)' 'OPT=$(strip $(LOCALOPT) $(OPTWPOCOLLECT) $(OPTNEW))' compiler
  551. $(RM) $(EXENAME)
  552. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3)' 'OPT=$(strip $(RTLOPT) $(OPTWPOPERFORM) $(OPTNEW))' rtlclean rtl
  553. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3)' 'OPT=$(strip $(LOCALOPT) $(OPTNEW) $(OPTWPOPERFORM) $(subst pp1.wpo,pp2.wpo,$(OPTWPOCOLLECT)))' $(addsuffix _clean,$(ALLTARGETS)) compiler
  554. $(MOVE) $(EXENAME) $(TEMPWPONAME1)
  555. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPWPONAME1)' 'OPT=$(strip $(RTLOPT) $(OPTNEW) $(subst pp1.wpo,pp2.wpo,$(OPTWPOPERFORM)))' rtlclean rtl
  556. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPWPONAME1)' 'OPT=$(strip $(LOCALOPT) $(OPTNEW) $(subst pp1.wpo,pp2.wpo,$(OPTWPOPERFORM)))' $(addsuffix _clean,$(ALLTARGETS)) compiler
  557. $(COPY) $(EXENAME) $(TEMPWPONAME2)
  558. endif
  559. endif
  560. ifndef DOWPOCYCLE
  561. wpocycle:
  562. endif
  563. # Used to avoid unnecessary steps
  564. ifdef DIFF
  565. ifdef OLDFPC
  566. ifneq ($(OS_TARGET),darwin)
  567. DIFFRESULT:=$(shell $(DIFF) $(OLDFPC) $(FPC))
  568. else
  569. 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)
  570. endif
  571. else
  572. DIFFRESULT=Not equal
  573. endif
  574. else
  575. DIFFRESULT=No diff program
  576. endif
  577. ifndef DIFFRESULT
  578. next :
  579. @echo $(OLDFPC) and $(FPC) are equal
  580. $(COPY) $(FPC) $(EXENAME)
  581. else
  582. next :
  583. $(MAKE) rtlclean rtl
  584. $(MAKE) cycleclean compiler
  585. $(MAKE) echotime
  586. endif
  587. $(TEMPNAME1) :
  588. $(MAKE) 'OLDFPC=' next CYCLELEVEL=1
  589. -$(DEL) $(TEMPNAME1)
  590. $(MOVE) $(EXENAME) $(TEMPNAME1)
  591. $(TEMPNAME2) : $(TEMPNAME1)
  592. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME1)' 'OLDFPC=' next CYCLELEVEL=2
  593. -$(DEL) $(TEMPNAME2)
  594. $(MOVE) $(EXENAME) $(TEMPNAME2)
  595. $(TEMPNAME3) : $(TEMPNAME2)
  596. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME2)' 'OLDFPC=$(BASEDIR)/$(TEMPNAME1)' next CYCLELEVEL=3
  597. -$(DEL) $(TEMPNAME3)
  598. $(MOVE) $(EXENAME) $(TEMPNAME3)
  599. cycle:
  600. $(MAKE) tempclean $(TEMPNAME3)
  601. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3)' 'OLDFPC=$(BASEDIR)/$(TEMPNAME2)' next CYCLELEVEL=4
  602. $(DIFF) $(TEMPNAME3) $(EXENAME)
  603. $(MAKE) $(addsuffix _all,$(TARGET_DIRS)) 'FPC=$(BASEDIR)/$(EXENAME)'
  604. $(MAKE) wpocycle
  605. $(MAKE) echotime
  606. else
  607. ##########################
  608. # Cross Target cycle
  609. #
  610. cycle:
  611. # ppc (source native)
  612. $(MAKE) OS_TARGET=$(OS_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 rtlclean rtl CYCLELEVEL=1
  613. $(MAKE) OS_TARGET=$(OS_SOURCE) EXENAME=$(TEMPNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 cycleclean compiler CYCLELEVEL=1
  614. # ppcross<ARCH> (source native)
  615. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 rtlclean rtl CYCLELEVEL=2
  616. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) EXENAME=$(PPCROSSNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 cycleclean compiler CYCLELEVEL=2
  617. # ppc<ARCH> (target native)
  618. ifndef CROSSINSTALL
  619. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAME)' rtlclean rtl CYCLELEVEL=3
  620. ifndef NoNativeBinaries
  621. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAME)' cycleclean compiler CYCLELEVEL=3
  622. endif
  623. endif
  624. endif
  625. else
  626. ##########################
  627. # Cross CPU cycle
  628. #
  629. # ppc1 = native
  630. # ppc2 = cross running on this platform
  631. # ppc3/ppcXXX = native (skipped for cross installation)
  632. #
  633. cycle: override FPC=
  634. cycle:
  635. # ppc (source native)
  636. # Clear detected compiler binary, because it can be existing crosscompiler binary, but we need native compiler here
  637. $(MAKE) OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 rtlclean rtl CYCLELEVEL=1
  638. $(MAKE) OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) EXENAME=$(TEMPNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 cycleclean compiler CYCLELEVEL=1
  639. # ppcross<ARCH> (source native)
  640. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 rtlclean rtl CYCLELEVEL=2
  641. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) PPC_TARGET=$(CPU_TARGET) EXENAME=$(PPCROSSNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 cycleclean compiler CYCLELEVEL=2
  642. # ppc<ARCH> (target native)
  643. ifndef CROSSINSTALL
  644. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAME)' 'OPT=$(RTLOPT) $(CROSSOPT)' rtlclean rtl CYCLELEVEL=3
  645. ifndef NoNativeBinaries
  646. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAME)' 'OPT=$(strip $(LOCALOPT) $(CROSSOPT))' cycleclean compiler CYCLELEVEL=3
  647. endif
  648. endif
  649. endif
  650. cycledep:
  651. $(MAKE) cycle USEDEPEND=1
  652. # extcycle should still work, but generates
  653. # lots of warnings, so ALLOW_WARNINGS=1 is required
  654. extcycle:
  655. $(MAKE) cycle OPT="$(OPT) -n -OG2p3 -glttt -CRriot -dEXTDEBUG" ALLOW_WARNINGS=1
  656. cvstest:
  657. $(MAKE) cycle 'LOCALOPT=-n -Se' 'RTLOPT=-n -Se'
  658. ##########################
  659. # Full cycle
  660. #
  661. # 1. build a compiler using cycle
  662. # 2. remove all .ppufiles
  663. # 3. clean and recompile rtl if DOWPOCYCLE is set
  664. # 4. build all supported cross compilers except the
  665. # current PPC_TARGET which was already build
  666. # unless FPC_SUPPORT_X87_TYPES_ON_WIN64 is set,
  667. # win64 cannot compile i386 or i8086 compiler
  668. # This is also the case for other CPUs that don't support
  669. # 80bit real type.
  670. ifeq ($(OS_SOURCE),win64)
  671. EXCLUDE_80BIT_TARGETS=1
  672. endif
  673. ifneq ($(findstring $(CPU_SOURCE),aarch64 arm avr jvm m68k mips mipsel powerpc powerpc64 sparc sparc64),)
  674. EXCLUDE_80BIT_TARGETS=1
  675. endif
  676. full: fullcycle
  677. fullcycle:
  678. $(MAKE) cycle
  679. $(MAKE) ppuclean
  680. ifdef DOWPOCYCLE
  681. $(MAKE) rtlclean
  682. $(MAKE) rtl 'FPC=$(BASEDIR)/$(EXENAME)'
  683. endif
  684. ifndef EXCLUDE_80BIT_TARGETS
  685. $(MAKE) $(filter-out $(PPC_TARGET),$(CYCLETARGETS)) 'FPC=$(BASEDIR)/$(EXENAME)'
  686. else
  687. $(MAKE) $(filter-out i8086,$(filter-out i386,$(filter-out $(PPC_TARGET),$(CYCLETARGETS)))) 'FPC=$(BASEDIR)/$(EXENAME)'
  688. endif
  689. #####################################################################
  690. # Docs
  691. #####################################################################
  692. htmldocs:
  693. $(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
  694. #####################################################################
  695. # Installation
  696. #####################################################################
  697. .PHONY: quickinstall exeinstall install installsymlink fullinstall fullinstallsymlink
  698. MSGINSTALLDIR=$(INSTALL_BASEDIR)/msg
  699. override PPEXEFILE:=$(wildcard $(EXENAME))
  700. ifdef UNIXHier
  701. PPCCPULOCATION=$(INSTALL_BASEDIR)
  702. else
  703. PPCCPULOCATION=$(INSTALL_BINDIR)
  704. endif
  705. ifndef NoNativeBinaries
  706. quickinstall: quickinstall_withutils
  707. else
  708. quickinstall: exeinstall
  709. endif
  710. # This will only install the ppcXXX executable, not the message files etc.
  711. quickinstall_withutils: $(addsuffix _install,$(TARGET_DIRS)) exeinstall
  712. # Install ppcXXX executable, for a cross installation we install
  713. # the ppcrossXXX as ppcXXX. The target native build ppcXXX is not used
  714. # for this installation type
  715. exeinstall:
  716. ifneq ($(INSTALLEXEFILE),)
  717. ifdef UPXPROG
  718. -$(UPXPROG) $(INSTALLEXEFILE)
  719. endif
  720. $(MKDIR) $(PPCCPULOCATION)
  721. $(INSTALLEXE) $(INSTALLEXEFILE) $(PPCCPULOCATION)/$(INSTALLEXEFILE)
  722. endif
  723. fullinstall:
  724. ifndef EXCLUDE_80BIT_TARGETS
  725. $(MAKE) $(addsuffix _exe_install,$(filter-out $(PPC_TARGET),$(CYCLETARGETS)))
  726. else
  727. $(MAKE) $(addsuffix _exe_install,$(filter-out i8086,$(filter-out i386,$(filter-out $(PPC_TARGET),$(CYCLETARGETS)))))
  728. endif
  729. install: quickinstall
  730. ifndef CROSSINSTALL
  731. ifdef UNIXHier
  732. $(MKDIR) $(INSTALL_BASEDIR)
  733. $(INSTALLEXE) $(COMPILERUTILSDIR)/samplecfg $(INSTALL_BASEDIR)/samplecfg
  734. endif
  735. $(MKDIR) $(MSGINSTALLDIR)
  736. $(INSTALL) $(MSGFILES) $(MSGINSTALLDIR)
  737. endif
  738. # This also installs a link from bin to the actual executable.
  739. # The .deb does that later.
  740. installsymlink: install
  741. ifneq ($(PPCCPULOCATION),$(INSTALL_BINDIR))
  742. $(MKDIR) $(INSTALL_BINDIR)
  743. ln -sf $(INSTALL_BASEDIR)/$(EXENAME) $(INSTALL_BINDIR)/$(EXENAME)
  744. endif
  745. fullinstallsymlink: fullinstall
  746. ifndef EXCLUDE_80BIT_TARGETS
  747. $(MAKE) $(addsuffix _symlink_install,$(filter-out $(PPC_TARGET),$(CYCLETARGETS)))
  748. else
  749. $(MAKE) $(addsuffix _symlink_install,$(filter-out i8086,$(filter-out i386,$(filter-out $(PPC_TARGET),$(CYCLETARGETS)))))
  750. endif
  751. #####################################################################
  752. # RTL
  753. #####################################################################
  754. .PHONY: rtl rtlclean rtlinstall
  755. rtl:
  756. $(MAKE) -C $(PACKAGEDIR_RTL) 'OPT=$(RTLOPT)' all
  757. rtlclean:
  758. $(MAKE) -C $(PACKAGEDIR_RTL) clean
  759. rtlinstall:
  760. $(MAKE) -C $(PACKAGEDIR_RTL) install
  761. #####################################################################
  762. # PPU testing targets
  763. #####################################################################
  764. PPUDIR=$(COMPILER_UNITTARGETDIR)
  765. ALLPPUDIR=$(CPU_TARGET)/units/*
  766. PPULIST=$(wildcard $(PPUDIR)/*.ppu)
  767. PPULOGLIST=$(subst .ppu,.log-ppu,$(PPULIST))
  768. RTLPPUDIR=../rtl/units/$(TARGETSUFFIX)
  769. RTLPPULIST=$(wildcard $(RTLPPUDIR)/*.ppu)
  770. RTLPPULOGLIST=$(subst .ppu,.log-ppu,$(RTLPPULIST))
  771. .PHONY : ppulogs cleanppulogs rtlppulogs cleanrtlppulogs testppudump
  772. ppulogs : $(PPULOGLIST)
  773. rtlppulogs : $(RTLPPULOGLIST)
  774. vpath %.ppu $(PPUDIR) $(RTLPPUDIR) $(ALLPPUDIR)
  775. vpath %.log-ppu $(PPUDIR) $(RTLPPUDIR) $(ALLPPUDIR)
  776. # Use installed ppudump
  777. %.log-ppu : %.ppu
  778. ppudump -VA -M $< > $@
  779. ./utils/ppudump$(EXEEXT):
  780. $(MAKE) -C $(COMPILERUTILSDIR) ppudump$(EXEEXT)
  781. ppuinfo :
  782. echo PPU list is "$(PPULIST)"
  783. echo PPULOG list is "$(PPULOGLIST)"
  784. echo RTLPPUDIR is "$(RTLPPUDIR)"
  785. echo RTLPPU list is "$(RTLPPULIST)"
  786. cleanppulogs :
  787. -$(RMPROG) $(PPULOGLIST)
  788. cleanrtlppulogs :
  789. -$(RMPROG) $(RTLPPULOGLIST)
  790. testppudump :
  791. $(MAKE) cleanrtlppulogs cleanppulogs ppulogs rtlppulogs
  792. #####################################################################
  793. # local user configurable file
  794. # in makefile.loc you can add any desired target
  795. #####################################################################
  796. localmake:=$(strip $(wildcard makefile.loc))
  797. ifdef localmake
  798. include ./$(localmake)
  799. endif