Makefile.fpc 12 KB

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