Makefile.fpc 24 KB

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