Makefile.fpc 20 KB

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