Makefile.fpc 12 KB

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