Makefile.fpc 13 KB

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