Makefile.fpc 21 KB

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