Makefile.fpc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. #
  2. # Makefile.fpc for Free Pascal Compiler
  3. #
  4. [package]
  5. name=compiler
  6. version=2.5.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
  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 automaticly 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. ifdef CMP
  217. override DIFF:=$(CMP) -i218
  218. endif
  219. endif
  220. # Add Local options
  221. override COMPILER+=$(LOCALOPT)
  222. #####################################################################
  223. # PASDoc
  224. #####################################################################
  225. PASDOC:=$(strip $(wildcard $(addsuffix /pasdoc.exe,$(SEARCHPATH))))
  226. ifeq ($(PASDOC),)
  227. PASDOC:=$(strip $(wildcard $(addsuffix /pasdoc,$(SEARCHPATH))))
  228. endif
  229. ifeq ($(PASDOC),)
  230. PASDOC:=../projects/pasdoc/bin/pasdoc
  231. else
  232. PASDOC:=$(firstword $(PASDOC))
  233. endif
  234. #####################################################################
  235. # Setup os-independent filenames
  236. #####################################################################
  237. ifndef EXENAME
  238. EXENAME=ppc$(CPUSUF)$(EXEEXT)
  239. endif
  240. PPEXENAME=pp$(EXEEXT)
  241. TEMPNAME=ppc$(SRCEXEEXT)
  242. PPCROSSNAME=ppcross$(CPUSUF)$(SRCEXEEXT)
  243. TEMPNAME1=ppc1$(EXEEXT)
  244. TEMPNAME2=ppc2$(EXEEXT)
  245. TEMPNAME3=ppc3$(EXEEXT)
  246. TEMPWPONAME1=ppcwpo1$(EXEEXT)
  247. TEMPWPONAME2=ppcwpo2$(EXEEXT)
  248. MAKEDEP=ppdep$(EXEEXT)
  249. MSG2INC=./msg2inc$(EXEEXT)
  250. ifdef CROSSINSTALL
  251. INSTALLEXEFILE=$(PPCROSSNAME)
  252. else
  253. INSTALLEXEFILE=$(EXENAME)
  254. endif
  255. #####################################################################
  256. # CPU targets
  257. #####################################################################
  258. PPC_TARGETS=i386 m68k powerpc sparc arm armeb x86_64 powerpc64 alpha vis ia64 mips mipsel
  259. .PHONY: $(PPC_TARGETS)
  260. $(PPC_TARGETS):
  261. $(MAKE) PPC_TARGET=$@ CPU_UNITDIR=$@ all
  262. alltargets: $(ALLTARGETS)
  263. #####################################################################
  264. # Default makefile
  265. #####################################################################
  266. .NOTPARALLEL:
  267. .PHONY: all compiler echotime ppuclean execlean clean distclean
  268. all: compiler $(addsuffix _all,$(TARGET_DIRS))
  269. compiler: $(COMPILER_UNITTARGETDIR) $(COMPILER_TARGETDIR) $(EXENAME)
  270. ifeq ($(MAKELEVEL),0)
  271. ifndef STARTTIME
  272. ifdef DATE
  273. STARTTIME:=$(shell $(DATE) +%T)
  274. else
  275. STARTTIME:=unknown
  276. endif
  277. endif
  278. endif
  279. export STARTTIME
  280. ifdef DATE
  281. ENDTIME=$(shell $(DATE) +%T)
  282. else
  283. ENDTIME:=unknown
  284. endif
  285. echotime:
  286. @echo Start $(STARTTIME) now $(ENDTIME)
  287. ppuclean:
  288. -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  289. -$(DEL) $(addsuffix /*$(PPUEXT),$(COMPILERSOURCEDIR))
  290. tempclean:
  291. -$(DEL) $(PPCROSSNAME) $(TEMPNAME) $(TEMPNAME1) $(TEMPNAME2) $(TEMPNAME3) $(MSG2INC) pp1.wpo pp2.wpo
  292. execlean :
  293. -$(DEL) ppc386$(EXEEXT) ppcaxp$(EXEEXT) ppc68k$(EXEEXT) ppcx64$(EXEEXT) ppcppc$(EXEEXT) ppcsparc$(EXEEXT) $(EXENAME) $(TEMPWPONAME1) $(TEMPWPONAME2)
  294. $(addsuffix _clean,$(ALLTARGETS)):
  295. -$(DELTREE) $(addprefix $(subst _clean,,$@),/units)
  296. -$(DEL) $(addprefix $(subst _clean,,$@)/,*$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT))
  297. -$(DEL) $(addprefix $(subst _clean,,$@)/,ppc386$(EXEEXT) ppcaxp$(EXEEXT) ppc68k$(EXEEXT) ppcx64$(EXEEXT) ppcppc$(EXEEXT) ppcppc$(EXEEXT) $(EXENAME))
  298. cycleclean: cleanall $(addsuffix _clean,$(CPC_TARGET))
  299. -$(DEL) $(EXENAME)
  300. clean: tempclean execlean cleanall $(addsuffix _clean,$(CPC_TARGET)) $(addsuffix _clean,$(TARGET_DIRS))
  301. distclean: tempclean execlean cleanall $(addsuffix _clean,$(ALLTARGETS)) $(addsuffix _distclean,$(TARGET_DIRS))
  302. #####################################################################
  303. # Make targets
  304. #####################################################################
  305. $(MSG2INC): $(COMPILER_TARGETDIR) $(COMPILER_UNITTARGETDIR) $(COMPILERUTILSDIR)/msg2inc.pp
  306. $(COMPILER) -FE. $(COMPILERUTILSDIR)/msg2inc.pp
  307. # The msgtxt.inc only depends on the error?.msg file, not on msg2inc,
  308. # because that one will be new almost everytime
  309. msgtxt.inc: $(MSGFILE)
  310. $(MAKE) $(MSG2INC)
  311. $(MSG2INC) $(MSGFILE) msg msg
  312. msg: msgtxt.inc
  313. insdatx86 : $(COMPILER_UNITTARGETDIR) x86/x86ins.dat
  314. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkx86ins.pp
  315. cd x86 && ../utils/mkx86ins$(SRCEXEEXT) && mv -f *.inc ../i386
  316. cd x86 && ../utils/mkx86ins$(SRCEXEEXT) x86_64 && mv -f *.inc ../x86_64
  317. insdatarm : arm/armins.dat
  318. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkarmins.pp
  319. cd arm && ../utils/mkarmins$(SRCEXEEXT)
  320. insdat: insdatx86 insdatarm
  321. regdatarm : arm/armreg.dat
  322. $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkarmreg.pp
  323. cd arm && ../utils/mkarmreg$(SRCEXEEXT)
  324. # revision.inc rule
  325. revision.inc :
  326. ifneq ($(REVSTR),)
  327. ifdef USEZIPWRAPPER
  328. ifneq ($(ECHOREDIR),echo)
  329. $(ECHOREDIR) "'$(REVSTR)'" > revision.inc
  330. else
  331. $(ECHOREDIR) '$(REVSTR)' > revision.inc
  332. endif
  333. else
  334. $(ECHOREDIR) "'$(REVSTR)'" > revision.inc
  335. endif
  336. else
  337. $(MAKE) revision.inc REVINC=force
  338. endif
  339. .PHONY : revision
  340. revision :
  341. $(DEL) revision.inc
  342. $(MAKE) revision.inc
  343. # Make only the compiler
  344. # ECHOREDIR sometimes does not remove double quotes
  345. $(EXENAME) : $(wildcard *.pas) $(wildcard *.inc) msg \
  346. $(wildcard systems/*.pas) $(wilcard systems/*.inc) \
  347. $(wildcard $(CPC_TARGET)/*.pas) $(wildcard $(CPC_TARGET)/*.inc)
  348. ifneq ($(REVSTR),)
  349. ifdef USEZIPWRAPPER
  350. ifneq ($(ECHOREDIR),echo)
  351. $(ECHOREDIR) "'$(REVSTR)'" > revision.inc
  352. else
  353. $(ECHOREDIR) '$(REVSTR)' > revision.inc
  354. endif
  355. else
  356. $(ECHOREDIR) "'$(REVSTR)'" > revision.inc
  357. endif
  358. $(COMPILER) version.pas
  359. endif
  360. $(COMPILER) pp.pas
  361. $(EXECPPAS)
  362. $(MOVE) $(COMPILER_TARGETDIR)/$(PPEXENAME) $(EXENAME)
  363. #####################################################################
  364. # Cycle targets
  365. #
  366. # 1. Source CPU = Target CPU and Source OS = Target OS
  367. # Normal cycle
  368. #
  369. # 2. Source CPU = Target CPU and Source OS <> Target OS
  370. # First source native compiler
  371. # Second target native compiler (skipped for cross installation)
  372. #
  373. # 3. Source CPU <> Target CPU
  374. # First source native compiler
  375. # Second cross compiler
  376. # Third target native compiler (skipped for cross installation)
  377. #
  378. #####################################################################
  379. ifeq ($(CPU_SOURCE),$(PPC_TARGET))
  380. ifeq ($(OS_SOURCE),$(OS_TARGET))
  381. ##########################
  382. # Normal cycle
  383. #
  384. ifndef NOWPOCYCLE
  385. ifdef RELEASE
  386. DOWPOCYCLE=1
  387. # Two WPO cycles in case of RELEASE=1
  388. wpocycle:
  389. # don't use cycle_clean, it will delete the compiler utilities again
  390. $(RM) $(EXENAME)
  391. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3)' 'OPT=$(LOCALOPT) $(OPTWPOCOLLECT)' compiler
  392. $(RM) $(EXENAME)
  393. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3)' 'OPT=$(RTLOPT) $(OPTWPOPERFORM)' rtlclean rtl
  394. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3)' 'OPT=$(LOCALOPT) $(OPTWPOPERFORM) $(subst pp1.wpo,pp2.wpo,$(OPTWPOCOLLECT))' $(addsuffix _clean,$(ALLTARGETS)) compiler
  395. $(MOVE) $(EXENAME) $(TEMPWPONAME1)
  396. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPWPONAME1)' 'OPT=$(RTLOPT) $(subst pp1.wpo,pp2.wpo,$(OPTWPOPERFORM))' rtlclean rtl
  397. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPWPONAME1)' 'OPT=$(LOCALOPT) $(subst pp1.wpo,pp2.wpo,$(OPTWPOPERFORM))' $(addsuffix _clean,$(ALLTARGETS)) compiler
  398. $(COPY) $(EXENAME) $(TEMPWPONAME2)
  399. endif
  400. endif
  401. ifndef DOWPOCYCLE
  402. wpocycle:
  403. endif
  404. # Used to avoid unnecessary steps
  405. ifdef DIFF
  406. ifdef OLDFPC
  407. ifneq ($(OS_TARGET),darwin)
  408. DIFFRESULT:=$(shell $(DIFF) $(OLDFPC) $(FPC))
  409. else
  410. 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)
  411. endif
  412. else
  413. DIFFRESULT=Not equal
  414. endif
  415. else
  416. DIFFRESULT=No diff program
  417. endif
  418. ifndef DIFFRESULT
  419. next :
  420. @echo $(OLDFPC) and $(FPC) are equal
  421. $(COPY) $(FPC) $(EXENAME)
  422. else
  423. next :
  424. $(MAKE) rtlclean rtl
  425. $(MAKE) cycleclean compiler
  426. $(MAKE) echotime
  427. endif
  428. $(TEMPNAME1) :
  429. $(MAKE) 'OLDFPC=' next
  430. -$(DEL) $(TEMPNAME1)
  431. $(MOVE) $(EXENAME) $(TEMPNAME1)
  432. $(TEMPNAME2) : $(TEMPNAME1)
  433. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME1)' 'OLDFPC=' next
  434. -$(DEL) $(TEMPNAME2)
  435. $(MOVE) $(EXENAME) $(TEMPNAME2)
  436. $(TEMPNAME3) : $(TEMPNAME2)
  437. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME2)' 'OLDFPC=$(BASEDIR)/$(TEMPNAME1)' next
  438. -$(DEL) $(TEMPNAME3)
  439. $(MOVE) $(EXENAME) $(TEMPNAME3)
  440. cycle:
  441. $(MAKE) tempclean $(TEMPNAME3)
  442. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3)' 'OLDFPC=$(BASEDIR)/$(TEMPNAME2)' next
  443. $(DIFF) $(TEMPNAME3) $(EXENAME)
  444. $(MAKE) $(addsuffix _all,$(TARGET_DIRS)) 'FPC=$(BASEDIR)/$(EXENAME)'
  445. $(MAKE) wpocycle
  446. $(MAKE) echotime
  447. else
  448. ##########################
  449. # Cross Target cycle
  450. #
  451. cycle:
  452. # ppc (source native)
  453. $(MAKE) OS_TARGET=$(OS_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 rtlclean rtl
  454. $(MAKE) OS_TARGET=$(OS_SOURCE) EXENAME=$(TEMPNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 cycleclean compiler
  455. # ppcross<ARCH> (source native)
  456. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 rtlclean rtl
  457. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) EXENAME=$(PPCROSSNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 cycleclean compiler
  458. # ppc<ARCH> (target native)
  459. ifndef CROSSINSTALL
  460. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAME)' rtlclean rtl
  461. # building a native compiler for embedded targets is not possible
  462. ifneq ($(OS_TARGET),embedded)
  463. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAME)' cycleclean compiler
  464. endif
  465. endif
  466. endif
  467. else
  468. ##########################
  469. # Cross CPU cycle
  470. #
  471. # ppc1 = native
  472. # ppc2 = cross running on this platform
  473. # ppc3/ppcXXX = native (skipped for cross installation)
  474. #
  475. cycle:
  476. # ppc (source native)
  477. # Clear detected compiler binary, because it can be existing crosscompiler binary, but we need native compiler here
  478. override FPC=
  479. $(MAKE) OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 rtlclean rtl
  480. $(MAKE) OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) EXENAME=$(TEMPNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 cycleclean compiler
  481. # ppcross<ARCH> (source native)
  482. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 rtlclean rtl
  483. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) PPC_TARGET=$(CPU_TARGET) EXENAME=$(PPCROSSNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 cycleclean compiler
  484. # ppc<ARCH> (target native)
  485. ifndef CROSSINSTALL
  486. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAME)' 'OPT=$(OPT) $(CROSSOPT)' rtlclean rtl
  487. # building a native compiler for embedded targets is not possible
  488. ifneq ($(OS_TARGET),embedded)
  489. $(MAKE) 'FPC=$(BASEDIR)/$(PPCROSSNAME)' 'OPT=$(OPT) $(CROSSOPT)' cycleclean compiler
  490. endif
  491. endif
  492. endif
  493. cycledep:
  494. $(MAKE) cycle USEDEPEND=1
  495. extcycle:
  496. $(MAKE) cycle OPT='-n -OG2p3 -glttt -CRriot -dEXTDEBUG'
  497. cvstest:
  498. $(MAKE) cycle 'LOCALOPT=-n -Se' 'RTLOPT=-n -Se'
  499. ##########################
  500. # Full cycle
  501. #
  502. # 1. build a compiler using cycle
  503. # 2. remove all .ppufiles
  504. # 3. build all supported cross compilers except the
  505. # current PPC_TARGET which was already build
  506. #
  507. full: fullcycle
  508. fullcycle:
  509. $(MAKE) cycle
  510. $(MAKE) ppuclean
  511. $(MAKE) $(filter-out $(PPC_TARGET),$(CYCLETARGETS)) 'FPC=$(BASEDIR)/$(EXENAME)'
  512. #####################################################################
  513. # Docs
  514. #####################################################################
  515. htmldocs:
  516. $(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
  517. #####################################################################
  518. # Installation
  519. #####################################################################
  520. .PHONY: quickinstall install installsym
  521. MSGINSTALLDIR=$(INSTALL_BASEDIR)/msg
  522. override PPEXEFILE:=$(wildcard $(EXENAME))
  523. ifdef UNIXHier
  524. PPCCPULOCATION=$(INSTALL_BASEDIR)
  525. else
  526. PPCCPULOCATION=$(INSTALL_BINDIR)
  527. endif
  528. # This will only install the ppcXXX executable, not the message files etc.
  529. quickinstall: $(addsuffix _install,$(TARGET_DIRS))
  530. # Install ppcXXX executable, for a cross installation we install
  531. # the ppcrossXXX as ppcXXX. The target native build ppcXXX is not used
  532. # for this installation type
  533. ifneq ($(INSTALLEXEFILE),)
  534. ifdef UPXPROG
  535. -$(UPXPROG) $(INSTALLEXEFILE)
  536. endif
  537. $(MKDIR) $(PPCCPULOCATION)
  538. $(INSTALLEXE) $(INSTALLEXEFILE) $(PPCCPULOCATION)/$(INSTALLEXEFILE)
  539. endif
  540. install: quickinstall
  541. ifndef CROSSINSTALL
  542. ifdef UNIXHier
  543. $(MKDIR) $(INSTALL_BASEDIR)
  544. $(INSTALLEXE) $(COMPILERUTILSDIR)/samplecfg $(INSTALL_BASEDIR)/samplecfg
  545. endif
  546. $(MKDIR) $(MSGINSTALLDIR)
  547. $(INSTALL) $(MSGFILES) $(MSGINSTALLDIR)
  548. endif
  549. # This also installs a link from bin to the actual executable.
  550. # The .deb does that later.
  551. installsymlink: install
  552. ifneq ($(PPCCPULOCATION),$(INSTALL_BINDIR))
  553. $(MKDIR) $(INSTALL_BINDIR)
  554. ln -sf $(INSTALL_BASEDIR)/$(EXENAME) $(INSTALL_BINDIR)/$(EXENAME)
  555. endif
  556. #####################################################################
  557. # RTL
  558. #####################################################################
  559. .PHONY: rtl rtlclean rtlinstall
  560. rtl:
  561. $(MAKE) -C $(PACKAGEDIR_RTL) 'OPT=$(RTLOPT)' all
  562. rtlclean:
  563. $(MAKE) -C $(PACKAGEDIR_RTL) clean
  564. rtlinstall:
  565. $(MAKE) -C $(PACKAGEDIR_RTL) install
  566. #####################################################################
  567. # local user configurable file
  568. # in makefile.loc you can add any desired target
  569. #####################################################################
  570. localmake:=$(strip $(wildcard makefile.loc))
  571. ifdef localmake
  572. include ./$(localmake)
  573. endif