Makefile.fpc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. #
  2. # Makefile.fpc for Free Pascal Source Tree
  3. #
  4. [package]
  5. name=fpc
  6. version=1.0.5
  7. [target]
  8. dirs=compiler rtl utils fcl fv packages ide
  9. [install]
  10. fpcpackage=y
  11. [default]
  12. fpcdir=.
  13. rule=help
  14. [prerules]
  15. # make versions < 3.77 (OS2 version) are buggy
  16. ifndef inOS2
  17. override FPCDIR:=$(BASEDIR)
  18. export FPCDIR
  19. endif
  20. # New ppc386
  21. PPNEW=$(BASEDIR)/compiler/ppc386$(SRCEXEEXT)
  22. # Check if there is already a ppc386 binary in compiler, then
  23. # we will use that version for target and version info
  24. ifneq ($(wildcard $(PPNEW)),)
  25. override FPC_VERSION:=$(shell $(PPNEW) -iV)
  26. override OS_TARGET:=$(shell $(PPNEW) -iTO)
  27. override CPU_TARGET:=$(shell $(PPNEW) -iTP)
  28. export FPC_VERSION OS_TARGET CPU_TARGET
  29. endif
  30. # Check if install/ subdir is available
  31. ifneq ($(wildcard install),)
  32. CVSINSTALL=install
  33. else
  34. CVSINSTALL=.
  35. endif
  36. # Install target
  37. ifdef SNAPSHOT
  38. INSTALLTARGET=install
  39. else
  40. INSTALLTARGET=distinstall
  41. endif
  42. # All target
  43. ifdef SNAPSHOT
  44. ALLTARGET=all
  45. else
  46. ifndef ALLTARGET
  47. ifeq ($(OS_TARGET),win32)
  48. ALLTARGET=smart
  49. else
  50. ifeq ($(OS_TARGET),go32v2)
  51. ALLTARGET=smart
  52. else
  53. ifeq ($(OS_TARGET),linux)
  54. ALLTARGET=smart
  55. else
  56. ifeq ($(OS_TARGET),freebsd)
  57. ALLTARGET=smart
  58. else
  59. ALLTARGET=all
  60. endif
  61. endif
  62. endif
  63. endif
  64. endif
  65. endif
  66. # Stop with an error?
  67. ifdef SNAPSHOT
  68. NOSTOP=-
  69. else
  70. NOSTOP=
  71. endif
  72. # Prefix for units
  73. ifeq ($(OS_TARGET),linux)
  74. PKGPRE=units
  75. else
  76. ifeq ($(OS_TARGET),freebsd)
  77. PKGPRE=units
  78. else
  79. PKGPRE=u
  80. endif
  81. endif
  82. # Always compile for release
  83. override RELEASE=1
  84. export RELEASE
  85. # We want to have the resulting .zips in the current dir
  86. ifndef DIST_DESTDIR
  87. export DIST_DESTDIR:=$(BASEDIR)
  88. endif
  89. # Temporary path to pack a file
  90. BASEPACKDIR=$(BASEDIR)/basepack
  91. # Newly created fpcmake
  92. FPCMAKENEW=$(BASEDIR)/utils/fpcm/fpcmake$(EXEEXT)
  93. # Build/install options
  94. BUILDOPTS=FPC=$(PPNEW) RELEASE=1
  95. INSTALLOPTS=FPC=$(PPNEW) ZIPDESTDIR=$(BASEDIR) FPCMAKE=$(FPCMAKENEW)
  96. # Compile also IDE (check for ide and fv dir)
  97. ifneq ($(wildcard ide),)
  98. ifneq ($(wildcard fv),)
  99. ifeq ($(OS_TARGET),go32v2)
  100. IDE=1
  101. endif
  102. ifeq ($(OS_TARGET),win32)
  103. IDE=1
  104. endif
  105. ifeq ($(OS_TARGET),linux)
  106. IDE=1
  107. endif
  108. endif
  109. endif
  110. [rules]
  111. # These values can change
  112. unexport FPC_VERSION OS_SOURCE
  113. # Only process directories that really exists
  114. override TARGET_DIRS:=$(wildcard $(TARGET_DIRS))
  115. #####################################################################
  116. # Main targets
  117. #####################################################################
  118. .PHONY: help checkfpcdir
  119. help:
  120. @$(ECHO)
  121. @$(ECHO) Directory targets:
  122. @$(ECHO)
  123. @$(ECHO) $(TARGET_DIRS)
  124. @$(ECHO)
  125. @$(ECHO) Packing targets are:
  126. @$(ECHO)
  127. @$(ECHO) go32v2zip,win32zip,linuxzip,freebsdzip,sourcezip,os2zip
  128. @$(ECHO)
  129. @exit
  130. #####################################################################
  131. # Dependencies
  132. #####################################################################
  133. #######################################
  134. # Compiler
  135. #######################################
  136. .PHONY: compiler_cycle
  137. compiler_cycle:
  138. $(MAKE) -C compiler cycle
  139. #######################################
  140. # Install targets
  141. #######################################
  142. demo_install:
  143. $(MAKE) -C $(CVSINSTALL)/demo sourceinstall
  144. man_install:
  145. $(MAKE) -C $(CVSINSTALL)/man installman
  146. doc_install:
  147. $(MAKE) -C $(CVSINSTALL)/doc installdoc
  148. #######################################
  149. # Packaging targets
  150. #######################################
  151. optzips: optcompinstall optcompzip
  152. optcompinstall:
  153. $(MAKE) compiler_cycle OPT=-dNEWOPTIMIZATIONS
  154. $(MAKE) compiler_install
  155. $(MAKE) rtl_install
  156. optcompzip:
  157. $(MAKE) fpc_zipinstall PACKAGENAME=optcomp ZIPTARGET=optcompinstall
  158. ##########################################################################
  159. # Install
  160. ##########################################################################
  161. .PHONY: installer installersrc
  162. INSTALLERBUILDDIR=fpinst
  163. installer:
  164. $(COPYTREE) $(CVSINSTALL)/fpinst $(INSTALLERBUILDDIR)
  165. $(MAKE) -C $(INSTALLERBUILDDIR) all RELEASE=1
  166. $(MOVE) $(INSTALLERBUILDDIR)/install.exe .
  167. ifdef UPXPROG
  168. -$(UPXPROG) install.exe
  169. endif
  170. $(DELTREE) $(INSTALLERBUILDDIR)
  171. installersrc:
  172. $(COPYTREE) $(CVSINSTALL)/fpinst $(INSTALLERBUILDDIR)
  173. $(MAKE) -C $(INSTALLERBUILDDIR) zipsourceinstall
  174. $(DELTREE) $(INSTALLERBUILDDIR)
  175. ##########################################################################
  176. # Packaging
  177. ##########################################################################
  178. .PHONY: all clean distclean build install installbase zipinstall zipinstallbase zipinstallfcl \
  179. zipinstallpackages
  180. all: build
  181. clean: $(addsuffix _distclean,$(TARGET_DIRS))
  182. $(DEL) build-stamp.$(OS_TARGET)
  183. distclean: clean
  184. build: build-stamp.$(OS_TARGET)
  185. build-stamp.$(OS_TARGET):
  186. # create new compiler
  187. $(MAKE) compiler_cycle
  188. # clean
  189. $(MAKE) rtl_clean
  190. $(MAKE) packages_clean
  191. $(MAKE) fcl_clean
  192. $(MAKE) utils_clean
  193. ifdef IDE
  194. $(MAKE) fv_clean
  195. $(MAKE) ide_clean
  196. endif
  197. # build everything
  198. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  199. $(MAKE) packages_$(ALLTARGET) $(BUILDOPTS)
  200. $(MAKE) fcl_$(ALLTARGET) $(BUILDOPTS)
  201. $(MAKE) utils_all $(BUILDOPTS)
  202. ifdef IDE
  203. $(MAKE) ide_all $(BUILDOPTS)
  204. endif
  205. $(ECHOREDIR) Build > build-stamp.$(OS_TARGET)
  206. installbase: build-stamp.$(OS_TARGET)
  207. # create dirs
  208. $(MKDIR) $(INSTALL_BASEDIR)
  209. $(MKDIR) $(INSTALL_DOCDIR)
  210. $(MKDIR) $(INSTALL_BINDIR)
  211. ifndef SNAPSHOT
  212. # readme & whatsnew and docs
  213. $(COPY) $(CVSINSTALL)/doc/*.txt $(CVSINSTALL)/doc/copying* $(CVSINSTALL)/doc/faq.* $(INSTALL_DOCDIR)
  214. # bingo32 (cwsdpmi,wmemu387.dxe)
  215. ifeq ($(OS_TARGET),go32v2)
  216. $(COPY) $(CVSINSTALL)/bingo32/* $(INSTALL_BINDIR)
  217. endif
  218. # binw32 (cygwin1.dll)
  219. ifeq ($(OS_TARGET),win32)
  220. $(COPY) $(CVSINSTALL)/binw32/* $(INSTALL_BINDIR)
  221. endif
  222. # manpages for linux
  223. ifeq ($(OS_TARGET),linux)
  224. $(MAKE) -C $(CVSINSTALL)/man installman
  225. endif
  226. ifeq ($(OS_TARGET),freebsd)
  227. $(MAKE) -C $(CVSINSTALL)/man installman
  228. endif
  229. endif
  230. # install generated things
  231. $(MAKE) compiler_$(INSTALLTARGET) $(INSTALLOPTS)
  232. $(MAKE) rtl_$(INSTALLTARGET) $(INSTALLOPTS)
  233. install: build-stamp.$(OS_TARGET)
  234. $(MAKE) installbase $(INSTALLOPTS)
  235. $(MAKE) packages_$(INSTALLTARGET) $(INSTALLOPTS)
  236. $(MAKE) fcl_$(INSTALLTARGET) $(INSTALLOPTS)
  237. $(MAKE) utils_$(INSTALLTARGET) $(INSTALLOPTS)
  238. ifdef IDE
  239. $(NOSTOP)$(MAKE) ide_$(INSTALLTARGET) $(BUILDOPTS)
  240. endif
  241. zipinstall: build-stamp.$(OS_TARGET)
  242. $(MAKE) fpc_zipinstall ZIPTARGET=installbase ZIPNAME=base$(ZIPSUFFIX) $(INSTALLOPTS)
  243. $(MAKE) packages_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPPREFIX=$(PKGPRE)
  244. $(MAKE) fcl_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPPREFIX=$(PKGPRE)
  245. $(MAKE) utils_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPNAME=util$(ZIPSUFFIX)
  246. ifdef IDE
  247. $(NOSTOP)$(MAKE) ide_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPNAME=ide$(ZIPSUFFIX)
  248. endif
  249. ##########################################################################
  250. # Docs
  251. ##########################################################################
  252. .PHONY: docspdf docs docsrcinstall docsrc
  253. docspdf:
  254. $(MAKE) -C docs pdfinstall
  255. docs:
  256. $(MAKE) fpc_zipinstall ZIPTARGET=docspdf ZIPNAME=docs
  257. docsrcinstall:
  258. $(MAKE) -C docs clean
  259. $(MKDIR) $(INSTALL_SOURCEDIR)
  260. $(COPYTREE) docs $(INSTALL_SOURCEDIR)
  261. docsrc:
  262. $(MAKE) fpc_zipinstall ZIPTARGET=docsrcinstall ZIPNAME=docsrc
  263. ##########################################################################
  264. # Demos
  265. ##########################################################################
  266. .PHONY: demozip
  267. demozip:
  268. $(MAKE) -C $(CVSINSTALL)/demo zipsourceinstall ZIPNAME=demo
  269. ##########################################################################
  270. # Source targets
  271. ##########################################################################
  272. .PHONY: sourcebase sourcezip
  273. sourcebase:
  274. # base Makefiles needed for sources
  275. $(MKDIR) $(INSTALL_SOURCEDIR)
  276. $(MKDIR) $(INSTALL_SOURCEDIR)/rtl
  277. $(MKDIR) $(INSTALL_SOURCEDIR)/packages
  278. $(COPY) Makefile* $(INSTALL_SOURCEDIR)
  279. $(COPY) rtl/Makefile* $(INSTALL_SOURCEDIR)/rtl
  280. $(COPY) packages/Makefile* $(INSTALL_SOURCEDIR)/packages
  281. sourcezip: distclean
  282. $(MAKE) fpc_zipinstall ZIPTARGET=sourcebase ZIPNAME=basesrc
  283. $(MAKE) compiler_zipsourceinstall
  284. $(MAKE) rtl_zipsourceinstall
  285. $(MAKE) packages_zipsourceinstall
  286. $(MAKE) fcl_zipsourceinstall
  287. $(MAKE) utils_zipsourceinstall
  288. $(MAKE) ide_zipsourceinstall
  289. # $(MAKE) installersrc
  290. # $(MAKE) docsrc
  291. ##########################################################################
  292. # OS targets
  293. ##########################################################################
  294. .PHONY: go32v2 win32 linux freebsd os2 go32v2zip win32zip linuxzip freebsdzip os2zip
  295. go32v2: checkfpcdir
  296. $(MAKE) install OS_TARGET=go32v2
  297. win32: checkfpcdir
  298. $(MAKE) install OS_TARGET=win32
  299. linux: checkfpcdir
  300. $(MAKE) install OS_TARGET=linux
  301. freebsd: checkfpcdir
  302. $(MAKE) install OS_TARGET=freebsd
  303. os2: checkfpcdir
  304. $(MAKE) install OS_TARGET=os2
  305. go32v2zip: checkfpcdir
  306. $(MAKE) zipinstall OS_TARGET=go32v2
  307. win32zip: checkfpcdir
  308. $(MAKE) zipinstall OS_TARGET=win32
  309. linuxzip: checkfpcdir
  310. $(MAKE) zipinstall OS_TARGET=linux
  311. freebsdzip : checkfpcdir
  312. $(MAKE) zipinstall OS_TARGET=freebsd
  313. os2zip: checkfpcdir
  314. $(MAKE) zipinstall OS_TARGET=os2
  315. ##########################################################################
  316. # Debian
  317. ##########################################################################
  318. ifdef inUnix
  319. ifneq ($(wildcard $(CVSINSTALL)/debian/changelog),)
  320. .PHONY: debcopy deb
  321. DEBPACKAGEVERSION:=$(shell head -n 1 $(CVSINSTALL)/debian/changelog | awk '{ print $$2 }' | tr -d '[()]')
  322. DEBFPCVERSION:=$(shell echo $(DEBPACKAGEVERSION) | awk -F '-' '{ print $$1 }')
  323. DEBSRCDIR:=/usr/src/fpc-$(DEBFPCVERSION)
  324. debcopy: distclean
  325. rm -rf $(DEBSRCDIR)
  326. install -d $(DEBSRCDIR)
  327. $(COPYTREE) compiler $(DEBSRCDIR)
  328. $(COPYTREE) rtl $(DEBSRCDIR)
  329. $(COPYTREE) fcl $(DEBSRCDIR)
  330. $(COPYTREE) packages $(DEBSRCDIR)
  331. $(COPYTREE) utils $(DEBSRCDIR)
  332. $(COPYTREE) demo $(DEBSRCDIR)
  333. $(COPYTREE) logs $(DEBSRCDIR)
  334. $(COPYTREE) docs $(DEBSRCDIR)
  335. $(COPYTREE) Makefile* $(DEBSRCDIR)
  336. $(COPYTREE) $(CVSINSTALL)/debian $(DEBSRCDIR)
  337. $(COPYTREE) $(CVSINSTALL)/man $(DEBSRCDIR)
  338. $(COPYTREE) $(CVSINSTALL)/doc $(DEBSRCDIR)
  339. find $(DEBSRCDIR) -name 'CVS*' | xargs -n1 rm -rf
  340. chmod 755 $(DEBSRCDIR)/debian/rules
  341. deb: checkfpcdir debcopy
  342. cd $(DEBSRCDIR) ; debian/rules binary
  343. endif # changelog found
  344. endif
  345. ##########################################################################
  346. # RPM
  347. ##########################################################################
  348. ifdef inUnix
  349. ifneq ($(wildcard $(CVSINSTALL)/fpc.spec),)
  350. .PHONY: rpmcopy rpm
  351. RPMFPCVERSION:=$(shell grep 'define fpcversion' $(CVSINSTALL)/fpc.spec | awk '{ print $$2 }')
  352. REDHATDIR=/usr/src/redhat
  353. RPMSOURCESDIR:=$(REDHATDIR)/SOURCES
  354. RPMSPECDIR:=$(REDHATDIR)/SPECS
  355. RPMSRCDIR:=$(RPMSOURCESDIR)/fpc
  356. DOCSRCDIR:=$(RPMSOURCESDIR)/fpcdoc
  357. rpmcopy: distclean
  358. install -d $(REDHATDIR)
  359. install -d $(RPMSPECDIR)
  360. install -d $(RPMSOURCESDIR)
  361. # fpc.rpm
  362. rm -rf $(RPMSRCDIR)
  363. cp $(CVSINSTALL)/fpc.spec $(RPMSPECDIR)/fpc-$(RPMFPCVERSION).spec
  364. install -d $(RPMSRCDIR)
  365. $(COPYTREE) compiler $(RPMSRCDIR)
  366. $(COPYTREE) rtl $(RPMSRCDIR)
  367. $(COPYTREE) fcl $(RPMSRCDIR)
  368. $(COPYTREE) packages $(RPMSRCDIR)
  369. $(COPYTREE) utils $(RPMSRCDIR)
  370. $(COPYTREE) demo $(RPMSRCDIR)
  371. $(COPYTREE) logs $(RPMSRCDIR)
  372. $(COPYTREE) Makefile* $(RPMSRCDIR)
  373. $(COPYTREE) $(CVSINSTALL)/man $(RPMSRCDIR)
  374. $(COPYTREE) $(CVSINSTALL)/doc $(RPMSRCDIR)
  375. find $(RPMSRCDIR) -name 'CVS*' | xargs -n1 rm -rf
  376. cd $(RPMSRCDIR) ; tar cvz * > $(RPMSOURCESDIR)/fpc-$(RPMFPCVERSION)-src.tar.gz
  377. # fpc-docs.rpm
  378. rm -rf $(DOCSRCDIR)
  379. cp $(CVSINSTALL)/fpc-docs.spec $(RPMSPECDIR)/fpc-docs-$(RPMFPCVERSION).spec
  380. install -d $(DOCSRCDIR)
  381. $(COPYTREE) docs $(DOCSRCDIR)
  382. find $(DOCSRCDIR) -name 'CVS*' | xargs -n1 rm -rf
  383. cd $(DOCSRCDIR) ; tar cvz * > $(RPMSOURCESDIR)/fpc-docs-$(RPMFPCVERSION)-src.tar.gz
  384. rpm: checkfpcdir rpmcopy
  385. cd $(RPMSPECDIR) ; rpm --nodeps -ba fpc-$(RPMFPCVERSION).spec
  386. cd $(RPMSPECDIR) ; rpm --nodeps -ba fpc-docs-$(RPMFPCVERSION).spec
  387. endif # spec found
  388. endif