Makefile.fpc 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. #
  2. # Makefile.fpc for Free Pascal Compiler
  3. #
  4. [package]
  5. name=fpcompiler
  6. version=1.1
  7. [compiler]
  8. targetdir=.
  9. unitdir=$(OLDDIR)/$(CPU_TARGET)
  10. includedir=$(OLDDIR)/$(CPU_TARGET) $(OLDDIR)
  11. [require]
  12. packages=rtl
  13. tools=diff cmp
  14. [default]
  15. fpcdir=../..
  16. [prerules]
  17. # Don't export OS_SOURCE because it can change after the first compile
  18. unexport OS_SOURCE FPC_VERSION
  19. # Where is the 'old' compiler located
  20. OLDDIR=..
  21. # Allow ALPHA, POWERPC, M68K, I386 defines for target cpu
  22. ifdef ALPHA
  23. CPU_TARGET=alpha
  24. endif
  25. ifdef POWERPC
  26. CPU_TARGET=powerpc
  27. endif
  28. ifdef M68K
  29. CPU_TARGET=m68k
  30. endif
  31. ifdef I386
  32. CPU_TARGET=i386
  33. endif
  34. # RTL
  35. UTILSDIR=$(OLDDIR)/../utils
  36. # Utils used by compiler development/installation
  37. COMPILERUTILSDIR=$(OLDDIR)/utils
  38. # Default language for the compiler
  39. ifndef FPCLANG
  40. FPCLANG=e
  41. endif
  42. # Local defines for the compiler only
  43. ifndef LOCALDEF
  44. LOCALDEF=
  45. endif
  46. # Local options for the compiler only
  47. ifndef LOCALOPT
  48. LOCALOPT=$(OPT)
  49. endif
  50. # Options for the RTL only when cycling
  51. ifndef RTLOPTS
  52. RTLOPTS=$(OPT)
  53. endif
  54. # Message files
  55. MSGFILES=$(wildcard $(OLDDIR)/error*.msg)
  56. # ppcSUFFIX
  57. ifeq ($(CPU_TARGET),i386)
  58. CPUSUF=386
  59. endif
  60. ifeq ($(CPU_TARGET),alpha)
  61. CPUSUF=axp
  62. endif
  63. ifeq ($(CPU_TARGET),m68k)
  64. CPUSUF=68k
  65. endif
  66. ifeq ($(CPU_TARGET),powerpc)
  67. CPUSUF=ppc
  68. endif
  69. # Define Unix also for Linux
  70. ifeq ($(OS_TARGET),linux)
  71. ifneq ($(findstring 1.0.,$(FPC_VERSION)),)
  72. override LOCALDEF+=-dUNIX
  73. endif
  74. endif
  75. ifeq ($(OS_TARGET),freebsd)
  76. ifneq ($(findstring 1.0.,$(FPC_VERSION)),)
  77. override LOCALDEF+=-dUNIX
  78. endif
  79. endif
  80. # Default message file
  81. MSGFILE=$(OLDDIR)/error$(FPCLANG).msg
  82. # set correct defines (-d$(CPU_TARGET) is automaticly added in makefile.fpc)
  83. override LOCALDEF+=-dGDB -dBROWSERLOG -dNEWCG
  84. # i386 specific
  85. ifeq ($(CPU_TARGET),i386)
  86. # also insert MMX support
  87. override LOCALDEF+=-dSUPPORT_MMX
  88. endif
  89. override LOCALOPT+=$(LOCALDEF)
  90. override FPCOPT:=$(LOCALOPT)
  91. [rules]
  92. #####################################################################
  93. # Setup Targets
  94. #####################################################################
  95. ifeq ($(OS_TARGET),win32)
  96. ifdef CMP
  97. override DIFF:=$(CMP) -i138
  98. endif
  99. # force try to smartlink for windows unit
  100. override COMPILER+=-XX
  101. endif
  102. # Used to avoid unnecessary steps in remake3
  103. ifdef DIFF
  104. ifdef OLDFPC
  105. DIFFRESULT:=$(shell $(DIFF) $(OLDFPC) $(FPC))
  106. else
  107. DIFFRESULT=Not equal
  108. endif
  109. else
  110. DIFFRESULT=No diff program
  111. endif
  112. #####################################################################
  113. # Setup os-independent filenames
  114. #####################################################################
  115. FPCEXE=fpc$(EXEEXT)
  116. PPEXENAME=pp$(EXEEXT)
  117. EXENAME=ppc$(CPUSUF)$(EXEEXT)
  118. TEMPNAME=ppc$(EXEEXT)
  119. TEMPNAME1=ppc1$(EXEEXT)
  120. TEMPNAME2=ppc2$(EXEEXT)
  121. TEMPNAME3=ppc3$(EXEEXT)
  122. MAKEDEP=ppdep$(EXEEXT)
  123. MSG2INC=msg2inc$(EXEEXT)
  124. #####################################################################
  125. # CPU targets
  126. #####################################################################
  127. alpha:
  128. $(MAKE) ALPHA=1 all
  129. i386:
  130. $(MAKE) I386=1 all
  131. m68k:
  132. $(MAKE) M68K=1 all
  133. powerpc:
  134. $(MAKE) POWERPC=1 all
  135. #####################################################################
  136. # Default makefile
  137. #####################################################################
  138. all: $(EXENAME)
  139. fpcexe: $(FPCEXE)
  140. ifeq ($(MAKELEVEL),0)
  141. ifndef STARTTIME
  142. ifdef DATE
  143. STARTTIME:=$(shell $(DATE) +%T)
  144. else
  145. STARTTIME:=unknown
  146. endif
  147. endif
  148. endif
  149. export STARTTIME
  150. ifdef DATE
  151. ENDTIME=$(shell $(DATE) +%T)
  152. else
  153. ENDTIME:=unknown
  154. endif
  155. echotime:
  156. @echo Start $(STARTTIME) now $(ENDTIME)
  157. ifndef DIFFRESULT
  158. next :
  159. @echo $(OLDFPC) and $(FPC) are equal
  160. $(COPY) $(FPC) $(EXENAME)
  161. else
  162. next :
  163. $(MAKE) execlean
  164. $(MAKE) -C $(UNITDIR_RTL) clean
  165. $(MAKE) -C $(UNITDIR_RTL) 'FPC=$(FPC)' 'OPT=$(RTLOPTS)'
  166. $(MAKE) clean
  167. $(MAKE) $(EXENAME)
  168. $(MAKE) echotime
  169. endif
  170. clean : execlean fpc_cleanall
  171. ppuclean:
  172. -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  173. execlean :
  174. -$(DEL) fpc$(EXEEXT) ppc386$(EXEEXT) ppcaxp$(EXEEXT) ppc68k$(EXEEXT) ppcppc$(EXEEXT)
  175. distclean: clean
  176. -$(DEL) $(TEMPNAME) $(TEMPNAME1) $(TEMPNAME2) $(TEMPNAME3) $(MSG2INC)
  177. #####################################################################
  178. # Include depencies
  179. #####################################################################
  180. $(MAKEDEP): $(UTILSDIR)/ppdep.pp
  181. $(COMPILER) $(UTILSDIR)/ppdep.pp
  182. $(COPY) $(UTILSDIR)/$(MAKEDEP) $(MAKEDEP)
  183. dependencies : $(MAKEDEP)
  184. $(MAKEDEP) pp.pas $(FPCOPTDEF) $(LOCALDEF) '-F$$(COMPILER) $$(LOCALOPT)' > depend
  185. ifdef USEDEPEND
  186. include depend
  187. endif
  188. #####################################################################
  189. # Make targets
  190. #####################################################################
  191. $(MSG2INC): $(COMPILERUTILSDIR)/msg2inc.pp
  192. $(COMPILER) -FE. $(COMPILERUTILSDIR)/msg2inc.pp
  193. # The msgtxt.inc only depends on the error?.msg file, not on msg2inc,
  194. # because that one will be new almost everytime
  195. msgtxt.inc: $(MSGFILE)
  196. $(MAKE) $(MSG2INC)
  197. $(MSG2INC) $(MSGFILE) msg msg
  198. msg: msgtxt.inc
  199. # Make only the compiler
  200. ifndef COMPLETE
  201. $(EXENAME) : $(wildcard *.pas) $(wildcard *.inc) msg
  202. $(COMPILER) pp.pas
  203. $(EXECPPAS)
  204. $(MOVE) $(PPEXENAME) $(EXENAME)
  205. else
  206. $(EXENAME) : $(wildcard *.pas) $(wildcard *.inc) msg
  207. $(COMPILER) pp.pas
  208. $(EXECPPAS)
  209. $(COMPILER) pp.pas
  210. $(EXECPPAS)
  211. $(COMPILER) pp.pas
  212. $(EXECPPAS)
  213. $(MOVE) $(PPEXENAME) $(EXENAME)
  214. endif
  215. tokens.dat : $(wildcard *.pas) $(wildcard *.inc)
  216. $(COMPILER) tokendat.pas
  217. ./tokendat
  218. # This target remakes the units with the currently made version
  219. remake: $(EXENAME)
  220. $(MOVE) $(EXENAME) $(TEMPNAME)
  221. $(MAKE) execlean
  222. $(MAKE) -C $(UNITDIR_RTL) clean
  223. $(MAKE) clean
  224. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME)' all
  225. remake3: $(TEMPNAME3)
  226. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME3)' 'OLDFPC=$(BASEDIR)/$(TEMPNAME2)' next
  227. $(DIFF) $(TEMPNAME3) $(EXENAME)
  228. $(TEMPNAME1) : $(EXENAME)
  229. -$(DEL) $(TEMPNAME1)
  230. $(MOVE) $(EXENAME) $(TEMPNAME1)
  231. $(TEMPNAME2) : $(TEMPNAME1)
  232. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME1)' 'OLDFPC=' next
  233. -$(DEL) $(TEMPNAME2)
  234. $(MOVE) $(EXENAME) $(TEMPNAME2)
  235. $(TEMPNAME3) : $(TEMPNAME2)
  236. $(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME2)' 'OLDFPC=$(BASEDIR)/$(TEMPNAME1)' next
  237. -$(DEL) $(TEMPNAME3)
  238. $(MOVE) $(EXENAME) $(TEMPNAME3)
  239. cycle:
  240. $(MAKE) clean
  241. $(MAKE) -C $(UNITDIR_RTL) clean
  242. $(MAKE) -C $(UNITDIR_RTL) 'OPT=$(RTLOPTS)' all
  243. $(MAKE) remake3
  244. $(MAKE) echotime
  245. cycledep:
  246. $(MAKE) cycle USEDEPEND=1
  247. cvstest:
  248. $(MAKE) cycle 'LOCALOPT=-n -Se' 'RTLOPTS=-n -Se'
  249. #####################################################################
  250. # Installation
  251. #####################################################################
  252. .PHONY: quickinstall install installsym
  253. MSGINSTALLDIR=$(INSTALL_BASEDIR)/msg
  254. override FPCEXEFILE:=$(wildcard $(FPCEXE))
  255. override PPEXEFILE:=$(wildcard $(EXENAME))
  256. # This will only install the ppc386.exe, not the message files etc.
  257. quickinstall:
  258. # Install fpc.exe
  259. ifneq ($(FPCEXEFILE),)
  260. ifdef UPXPROG
  261. -$(UPXPROG) $(FPCEXEFILE)
  262. endif
  263. $(MKDIR) $(INSTALL_BINDIR)
  264. $(INSTALLEXE) $(FPCEXEFILE) $(INSTALL_BINDIR)
  265. endif
  266. # Install ppc386.exe
  267. ifneq ($(PPEXEFILE),)
  268. ifdef UPXPROG
  269. -$(UPXPROG) $(EXENAME)
  270. endif
  271. ifdef UNIXINSTALLDIR
  272. $(MKDIR) $(INSTALL_BASEDIR)
  273. $(INSTALLEXE) $(EXENAME) $(INSTALL_BASEDIR)
  274. else
  275. $(MKDIR) $(INSTALL_BINDIR)
  276. $(INSTALLEXE) $(EXENAME) $(INSTALL_BINDIR)
  277. endif
  278. endif
  279. install: quickinstall
  280. ifdef UNIXINSTALLDIR
  281. $(MKDIR) $(INSTALL_BASEDIR)
  282. $(INSTALLEXE) $(COMPILERUTILSDIR)/samplecfg $(INSTALL_BASEDIR)/samplecfg
  283. endif
  284. $(MKDIR) $(MSGINSTALLDIR)
  285. $(INSTALL) $(MSGFILES) $(MSGINSTALLDIR)
  286. # this also installs the link /usr/bin/ppc386. The .deb does that later
  287. installsymlink: install
  288. ifdef UNIXINSTALLDIR
  289. $(MKDIR) $(INSTALL_BINDIR)
  290. ln -sf $(INSTALL_BASEDIR)/ppc386 $(INSTALL_BINDIR)/ppc386
  291. endif
  292. #####################################################################
  293. # Misc
  294. #####################################################################
  295. .PHONY: rtl rtlclean rtlinstall
  296. rtl:
  297. $(MAKE) -C $(UNITDIR_RTL) all
  298. rtlclean:
  299. $(MAKE) -C $(UNITDIR_RTL) clean
  300. rtlinstall:
  301. $(MAKE) -C $(UNITDIR_RTL) install
  302. #####################################################################
  303. # local user configurable file
  304. # in makefile.loc you can add any desired target
  305. #####################################################################
  306. localmake:=$(strip $(wildcard makefile.loc))
  307. ifdef localmake
  308. include ./$(localmake)
  309. endif