Makefile.fpc 12 KB

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