Makefile.fpc 20 KB

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