Makefile.fpc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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,os2zip
  139. @echo
  140. @exit
  141. #####################################################################
  142. # Dependencies
  143. #####################################################################
  144. #######################################
  145. # Compiler
  146. #######################################
  147. .PHONY: compiler_cycle compiler_fpcexe
  148. compiler_cycle:
  149. $(MAKE) -C compiler cycle
  150. compiler_fpcexe:
  151. $(MAKE) -C compiler fpcexe
  152. #######################################
  153. # IDE
  154. #######################################
  155. .PHONY: ide_comp ide_full
  156. ide_comp:
  157. $(MAKE) -C compiler ppuclean
  158. $(MAKE) -C ide full
  159. # Look if libgdb.a is available then use fullgdb
  160. ifneq ($(wildcard packages/gdbint/libgdb/$(OS_TARGET)/libgdb.a),)
  161. ide_full:
  162. $(MAKE) -C compiler ppuclean
  163. $(MAKE) -C ide fullgdb
  164. else
  165. ide_full:
  166. $(MAKE) -C compiler ppuclean
  167. $(MAKE) -C ide full
  168. endif
  169. #######################################
  170. # Install targets
  171. #######################################
  172. demo_install:
  173. $(MAKE) -C $(CVSINSTALL)/demo sourceinstall
  174. man_install:
  175. $(MAKE) -C $(CVSINSTALL)/man installman
  176. doc_install:
  177. $(MAKE) -C $(CVSINSTALL)/doc installdoc
  178. #######################################
  179. # Packaging targets
  180. #######################################
  181. idezips: ide_fullzip ide_fullgdbzip optcompinstall optcompzip
  182. ide_compzip:
  183. $(MAKE) compiler_clean
  184. $(MAKE) ide_clean
  185. $(MAKE) ide_full
  186. $(MAKE) -C ide/text zipinstall ZIPNAME=ide-comp-$(PACKAGESUFFIX)
  187. ide_fullgdbzip:
  188. $(MAKE) ide_clean
  189. $(MAKE) ide_fullgdb
  190. $(MAKE) -C ide/text zipinstall ZIPNAME=ide-full-$(PACKAGESUFFIX)
  191. optcompinstall:
  192. $(MAKE) compiler_cycle OPT=-dNEWOPTIMIZATIONS
  193. $(MAKE) compiler_install
  194. $(MAKE) rtl_install
  195. optcompzip:
  196. $(MAKE) fpc_zipinstall PACKAGENAME=optcomp ZIPTARGET=optcompinstall
  197. ##########################################################################
  198. # Install
  199. ##########################################################################
  200. .PHONY: installer installersrc
  201. INSTALLERBUILDDIR=fpinst
  202. installer:
  203. $(COPYTREE) $(CVSINSTALL)/fpinst $(INSTALLERBUILDDIR)
  204. $(MAKE) -C $(INSTALLERBUILDDIR) all RELEASE=1
  205. $(MOVE) $(INSTALLERBUILDDIR)/install.exe .
  206. ifdef UPXPROG
  207. -$(UPXPROG) install.exe
  208. endif
  209. $(DELTREE) $(INSTALLERBUILDDIR)
  210. installersrc:
  211. $(COPYTREE) $(CVSINSTALL)/fpinst $(INSTALLERBUILDDIR)
  212. $(MAKE) -C $(INSTALLERBUILDDIR) zipsourceinstall
  213. $(DELTREE) $(INSTALLERBUILDDIR)
  214. ##########################################################################
  215. # Packaging
  216. ##########################################################################
  217. .PHONY: all clean distclean build install installbase zipinstall zipinstallbase zipinstallfcl \
  218. zipinstallpackages
  219. export RELEASE DESTZIPDIR
  220. all: build
  221. clean: $(addsuffix _distclean,$(DIROBJECTS))
  222. $(DEL) build-stamp.$(OS_TARGET)
  223. distclean: clean
  224. build: build-stamp.$(OS_TARGET)
  225. build-stamp.$(OS_TARGET):
  226. # create new compiler
  227. ifeq ($(OS_TARGET),win32)
  228. -$(MAKE) compiler_cycle
  229. else
  230. $(MAKE) compiler_cycle
  231. endif
  232. # clean
  233. $(MAKE) rtl_clean
  234. $(MAKE) api_clean
  235. $(MAKE) fcl_clean
  236. $(MAKE) packages_clean
  237. $(MAKE) utils_clean
  238. ifdef IDE
  239. $(MAKE) fv_clean
  240. $(MAKE) ide_clean
  241. endif
  242. # build everything
  243. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  244. $(MAKE) api_$(ALLTARGET) $(BUILDOPTS)
  245. $(MAKE) fcl_$(ALLTARGET) $(BUILDOPTS)
  246. $(MAKE) packages_$(ALLTARGET) $(BUILDOPTS)
  247. $(MAKE) utils_all $(BUILDOPTS)
  248. $(MAKE) compiler_fpcexe $(BUILDOPTS)
  249. ifdef IDE
  250. $(MAKE) ide_full $(BUILDOPTS)
  251. endif
  252. $(ECHO) Build > build-stamp.$(OS_TARGET)
  253. installbase: build-stamp.$(OS_TARGET)
  254. # create dirs
  255. $(MKDIR) $(BASEINSTALLDIR)
  256. $(MKDIR) $(DOCINSTALLDIR)
  257. $(MKDIR) $(BININSTALLDIR)
  258. ifndef SNAPSHOT
  259. # readme & whatsnew and docs
  260. $(COPY) $(CVSINSTALL)/doc/*.txt $(CVSINSTALL)/doc/copying* $(CVSINSTALL)/doc/faq.* $(DOCINSTALLDIR)
  261. # bingo32 (cwsdpmi,wmemu387.dxe)
  262. ifeq ($(OS_TARGET),go32v2)
  263. $(COPY) $(CVSINSTALL)/bingo32/* $(BININSTALLDIR)
  264. endif
  265. # binw32 (cygwin1.dll)
  266. ifeq ($(OS_TARGET),win32)
  267. $(COPY) $(CVSINSTALL)/binw32/* $(BININSTALLDIR)
  268. endif
  269. # manpages for linux
  270. ifeq ($(OS_TARGET),linux)
  271. $(MAKE) -C $(CVSINSTALL)/man installman
  272. endif
  273. ifeq ($(OS_TARGET),freebsd)
  274. $(MAKE) -C $(CVSINSTALL)/man installman
  275. endif
  276. endif
  277. # install generated things
  278. $(MAKE) compiler_install $(INSTALLOPTS)
  279. $(MAKE) rtl_install $(INSTALLOPTS)
  280. install: build-stamp.$(OS_TARGET)
  281. $(MAKE) installbase $(INSTALLOPTS)
  282. $(MAKE) utils_install $(INSTALLOPTS)
  283. $(MAKE) api_install $(INSTALLOPTS)
  284. $(MAKE) fcl_install $(INSTALLOPTS)
  285. $(MAKE) packages_install $(INSTALLOPTS)
  286. ifdef IDE
  287. $(NOSTOP)$(MAKE) ide_install $(BUILDOPTS)
  288. endif
  289. # install examples
  290. ifndef SNAPSHOT
  291. $(MAKE) fcl_exampleinstall $(INSTALLOPTS)
  292. $(MAKE) api_exampleinstall $(INSTALLOPTS)
  293. $(MAKE) packages_exampleinstall $(INSTALLOPTS)
  294. endif
  295. zipinstall: build-stamp.$(OS_TARGET)
  296. $(MAKE) fpc_zipinstall ZIPTARGET=installbase PACKAGENAME=base $(INSTALLOPTS)
  297. $(MAKE) utils_zipinstall $(INSTALLOPTS)
  298. $(MAKE) api_zipinstall $(INSTALLOPTS) PACKAGEPREFIX=$(PKGPRE)
  299. $(MAKE) fcl_zipinstall $(INSTALLOPTS) PACKAGEPREFIX=$(PKGPRE)
  300. $(MAKE) packages_zipinstall $(INSTALLOPTS) PACKAGEPREFIX=$(PKGPRE)
  301. ifdef IDE
  302. $(NOSTOP)$(MAKE) ide_zipinstall $(INSTALLOPTS)
  303. endif
  304. ifndef SNAPSHOT
  305. $(MAKE) fcl_zipexampleinstall $(INSTALLOPTS) PACKAGEPREFIX=$(PKGPRE)
  306. $(MAKE) api_zipexampleinstall $(INSTALLOPTS) PACKAGEPREFIX=$(PKGPRE)
  307. $(MAKE) packages_zipexampleinstall $(INSTALLOPTS) PACKAGEPREFIX=$(PKGPRE)
  308. endif
  309. ##########################################################################
  310. # Docs
  311. ##########################################################################
  312. .PHONY: docspdf docs docsrcinstall docsrc
  313. docspdf:
  314. $(MAKE) -C docs pdfinstall
  315. docs:
  316. $(MAKE) fpc_zipinstall ZIPTARGET=docspdf ZIPNAME=docs
  317. docsrcinstall:
  318. $(MAKE) -C docs clean
  319. $(MKDIR) $(SOURCEINSTALLDIR)
  320. $(COPYTREE) docs $(SOURCEINSTALLDIR)
  321. docsrc:
  322. $(MAKE) fpc_zipinstall ZIPTARGET=docsrcinstall ZIPNAME=docsrc
  323. ##########################################################################
  324. # Demos
  325. ##########################################################################
  326. .PHONY: demozip
  327. demozip:
  328. $(MAKE) -C $(CVSINSTALL)/demo zipsourceinstall ZIPNAME=demo
  329. ##########################################################################
  330. # Source targets
  331. ##########################################################################
  332. .PHONY: sourcebase sourcezip
  333. sourcebase:
  334. # base Makefiles needed for sources
  335. $(MKDIR) $(SOURCEINSTALLDIR)
  336. $(MKDIR) $(SOURCEINSTALLDIR)/rtl
  337. $(MKDIR) $(SOURCEINSTALLDIR)/packages
  338. $(COPY) Makefile* $(SOURCEINSTALLDIR)
  339. $(COPY) rtl/Makefile* $(SOURCEINSTALLDIR)/rtl
  340. $(COPY) packages/Makefile* $(SOURCEINSTALLDIR)/packages
  341. sourcezip: distclean
  342. $(MAKE) fpc_zipinstall ZIPTARGET=sourcebase ZIPNAME=basesrc
  343. $(MAKE) compiler_zipsourceinstall
  344. $(MAKE) rtl_zipsourceinstall
  345. $(MAKE) api_zipsourceinstall
  346. $(MAKE) fcl_zipsourceinstall
  347. $(MAKE) packages_zipsourceinstall
  348. $(MAKE) utils_zipsourceinstall
  349. $(MAKE) ide_zipsourceinstall
  350. # $(MAKE) installersrc
  351. # $(MAKE) docsrc
  352. ##########################################################################
  353. # OS targets
  354. ##########################################################################
  355. .PHONY: go32v2 win32 linux freebsd os2 go32v2zip win32zip linuxzip freebsdzip os2zip
  356. go32v2: checkfpcdir
  357. $(MAKE) install OS_TARGET=go32v2
  358. win32: checkfpcdir
  359. $(MAKE) install OS_TARGET=win32
  360. linux: checkfpcdir
  361. $(MAKE) install OS_TARGET=linux
  362. freebsd: checkfpcdir
  363. $(MAKE) install OS_TARGET=freebsd
  364. os2: checkfpcdir
  365. $(MAKE) install OS_TARGET=os2
  366. go32v2zip: checkfpcdir
  367. $(MAKE) zipinstall OS_TARGET=go32v2
  368. win32zip: checkfpcdir
  369. $(MAKE) zipinstall OS_TARGET=win32
  370. linuxzip: checkfpcdir
  371. $(MAKE) zipinstall OS_TARGET=linux
  372. freebsdzip : checkfpcdir
  373. $(MAKE) zipinstall OS_TARGET=freebsd
  374. os2zip: checkfpcdir
  375. $(MAKE) zipinstall OS_TARGET=os2
  376. ##########################################################################
  377. # Debian / RPM
  378. ##########################################################################
  379. .PHONY: debcopy deb rpmcopy rpm
  380. DEBSRCDIR:=/usr/src/fpc-$(FPC_VERSION)
  381. debcopy: distclean
  382. rm -rf $(DEBSRCDIR)
  383. install -d $(DEBSRCDIR)
  384. $(COPYTREE) compiler $(DEBSRCDIR)
  385. $(COPYTREE) rtl $(DEBSRCDIR)
  386. $(COPYTREE) fcl $(DEBSRCDIR)
  387. $(COPYTREE) api $(DEBSRCDIR)
  388. $(COPYTREE) packages $(DEBSRCDIR)
  389. $(COPYTREE) utils $(DEBSRCDIR)
  390. $(COPYTREE) logs $(DEBSRCDIR)
  391. $(COPYTREE) docs $(DEBSRCDIR)
  392. $(COPYTREE) Makefile* $(DEBSRCDIR)
  393. $(COPYTREE) $(CVSINSTALL)/debian $(DEBSRCDIR)
  394. $(COPYTREE) $(CVSINSTALL)/man $(DEBSRCDIR)
  395. $(COPYTREE) $(CVSINSTALL)/doc $(DEBSRCDIR)
  396. $(COPYTREE) $(CVSINSTALL)/demo $(DEBSRCDIR)
  397. find $(DEBSRCDIR) -name 'CVS*' | xargs -n1 rm -rf
  398. chmod 755 $(DEBSRCDIR)/debian/rules
  399. deb: checkfpcdir debcopy
  400. cd $(DEBSRCDIR) ; debian/rules binary
  401. REDHATDIR=/usr/src/redhat
  402. RPMSOURCESDIR:=$(REDHATDIR)/SOURCES
  403. RPMSPECDIR:=$(REDHATDIR)/SPECS
  404. RPMSRCDIR:=$(RPMSOURCESDIR)/fpc
  405. DOCSRCDIR:=$(RPMSOURCESDIR)/fpcdoc
  406. rpmcopy: distclean
  407. install -d $(REDHATDIR)
  408. install -d $(RPMSPECDIR)
  409. install -d $(RPMSOURCESDIR)
  410. # fpc.rpm
  411. rm -rf $(RPMSRCDIR)
  412. cp $(CVSINSTALL)/fpc.spec $(RPMSPECDIR)/fpc-$(FPC_VERSION).spec
  413. install -d $(RPMSRCDIR)
  414. $(COPYTREE) compiler $(RPMSRCDIR)
  415. $(COPYTREE) rtl $(RPMSRCDIR)
  416. $(COPYTREE) fcl $(RPMSRCDIR)
  417. $(COPYTREE) api $(RPMSRCDIR)
  418. $(COPYTREE) packages $(RPMSRCDIR)
  419. $(COPYTREE) utils $(RPMSRCDIR)
  420. $(COPYTREE) logs $(RPMSRCDIR)
  421. $(COPYTREE) Makefile* $(RPMSRCDIR)
  422. $(COPYTREE) $(CVSINSTALL)/man $(RPMSRCDIR)
  423. $(COPYTREE) $(CVSINSTALL)/doc $(RPMSRCDIR)
  424. $(COPYTREE) $(CVSINSTALL)/demo $(RPMSRCDIR)
  425. find $(RPMSRCDIR) -name 'CVS*' | xargs -n1 rm -rf
  426. cd $(RPMSRCDIR) ; tar cvz * > $(RPMSOURCESDIR)/fpc-$(FPC_VERSION)-src.tar.gz
  427. # fpc-docs.rpm
  428. rm -rf $(DOCSRCDIR)
  429. cp $(CVSINSTALL)/fpc-docs.spec $(RPMSPECDIR)/fpc-docs-$(FPC_VERSION).spec
  430. install -d $(DOCSRCDIR)
  431. $(COPYTREE) docs $(DOCSRCDIR)
  432. find $(DOCSRCDIR) -name 'CVS*' | xargs -n1 rm -rf
  433. cd $(DOCSRCDIR) ; tar cvz * > $(RPMSOURCESDIR)/fpc-docs-$(FPC_VERSION)-src.tar.gz
  434. rpm: checkfpcdir rpmcopy
  435. cd $(RPMSPECDIR) ; rpm -ba fpc-$(FPC_VERSION).spec
  436. cd $(RPMSPECDIR) ; rpm -ba fpc-docs-$(FPC_VERSION).spec