Makefile.fpc 13 KB

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