Makefile 23 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148
  1. #
  2. # Makefile generated by fpcmake v0.99.13 [2000/01/13]
  3. #
  4. defaultrule: all
  5. #####################################################################
  6. # Autodetect OS (Linux or Dos or Windows NT)
  7. # define inlinux when running under linux
  8. # define inWinNT when running under WinNT
  9. #####################################################################
  10. # We need only / in the path
  11. override PATH:=$(subst \,/,$(PATH))
  12. # Search for PWD and determine also if we are under linux
  13. PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
  14. ifeq ($(PWD),)
  15. PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
  16. ifeq ($(PWD),)
  17. nopwd:
  18. @echo You need the GNU utils package to use this Makefile!
  19. @echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
  20. @exit
  21. else
  22. inlinux=1
  23. endif
  24. else
  25. PWD:=$(firstword $(PWD))
  26. endif
  27. # Detect NT - NT sets OS to Windows_NT
  28. ifndef inlinux
  29. ifeq ($(OS),Windows_NT)
  30. inWinNT=1
  31. endif
  32. endif
  33. # Detect OS/2 - OS/2 has OS2_SHELL defined
  34. ifndef inlinux
  35. ifndef inWinNT
  36. ifdef OS2_SHELL
  37. inOS2=1
  38. endif
  39. endif
  40. endif
  41. # The extension of executables
  42. ifdef inlinux
  43. EXEEXT=
  44. else
  45. EXEEXT=.exe
  46. endif
  47. # The path which is searched separated by spaces
  48. ifdef inlinux
  49. SEARCHPATH=$(subst :, ,$(PATH))
  50. else
  51. SEARCHPATH=$(subst ;, ,$(PATH))
  52. endif
  53. # Base dir
  54. ifdef PWD
  55. BASEDIR:=$(shell $(PWD))
  56. else
  57. BASEDIR=.
  58. endif
  59. #####################################################################
  60. # FPC version/target Detection
  61. #####################################################################
  62. # What compiler to use ?
  63. ifndef FPC
  64. # Compatibility with old makefiles
  65. ifdef PP
  66. FPC=$(PP)
  67. else
  68. ifdef inOS2
  69. FPC=ppos2$(EXEEXT)
  70. else
  71. FPC=ppc386$(EXEEXT)
  72. endif
  73. endif
  74. endif
  75. # Target OS
  76. ifndef OS_TARGET
  77. OS_TARGET:=$(shell $(FPC) -iTO)
  78. endif
  79. # Source OS
  80. ifndef OS_SOURCE
  81. OS_SOURCE:=$(shell $(FPC) -iSO)
  82. endif
  83. # Target CPU
  84. ifndef CPU_TARGET
  85. CPU_TARGET:=$(shell $(FPC) -iTP)
  86. endif
  87. # Source CPU
  88. ifndef CPU_SOURCE
  89. CPU_SOURCE:=$(shell $(FPC) -iSP)
  90. endif
  91. # FPC version
  92. ifndef FPC_VERSION
  93. FPC_VERSION:=$(shell $(FPC) -iV)
  94. endif
  95. export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION
  96. #####################################################################
  97. # FPCDIR Setting
  98. #####################################################################
  99. # Test FPCDIR to look if the RTL dir exists
  100. ifdef FPCDIR
  101. override FPCDIR:=$(subst \,/,$(FPCDIR))
  102. ifeq ($(wildcard $(FPCDIR)/rtl),)
  103. override FPCDIR=wrong
  104. endif
  105. else
  106. override FPCDIR=wrong
  107. endif
  108. # Default FPCDIR
  109. ifeq ($(FPCDIR),wrong)
  110. override FPCDIR=../../..
  111. ifeq ($(wildcard $(FPCDIR)/rtl),)
  112. override FPCDIR=wrong
  113. endif
  114. endif
  115. # Detect FPCDIR
  116. ifeq ($(FPCDIR),wrong)
  117. ifdef inlinux
  118. override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
  119. else
  120. override FPCDIR:=$(subst /$(FPC)$(EXEEXT),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC)$(EXEEXT),$(SEARCHPATH))))))
  121. endif
  122. endif
  123. ifndef PACKAGESDIR
  124. PACKAGESDIR=$(FPCDIR)/packages
  125. endif
  126. ifndef TOOLKITSDIR
  127. TOOLKITSDIR=
  128. endif
  129. ifndef COMPONENTSDIR
  130. COMPONENTSDIR=
  131. endif
  132. # Create units dir
  133. ifneq ($(FPCDIR),.)
  134. UNITSDIR=$(FPCDIR)/units/$(OS_TARGET)
  135. endif
  136. #####################################################################
  137. # User Settings
  138. #####################################################################
  139. # Targets
  140. override EXEOBJECTS+=glutdemo
  141. # Clean
  142. # Install
  143. ZIPTARGET=install
  144. # Defaults
  145. # Directories
  146. # Packages
  147. override PACKAGES+=rtl opengl x11
  148. # Libraries
  149. override NEEDOTHERLIB=1
  150. # Info
  151. INFOTARGET=fpc_infocfg fpc_infoobjects fpc_infoinstall
  152. #####################################################################
  153. # Shell tools
  154. #####################################################################
  155. # echo
  156. ifndef ECHO
  157. ECHO:=$(strip $(wildcard $(addsuffix /gecho$(EXEEXT),$(SEARCHPATH))))
  158. ifeq ($(ECHO),)
  159. ECHO:=$(strip $(wildcard $(addsuffix /echo$(EXEEXT),$(SEARCHPATH))))
  160. ifeq ($(ECHO),)
  161. ECHO:=echo
  162. else
  163. ECHO:=$(firstword $(ECHO))
  164. endif
  165. else
  166. ECHO:=$(firstword $(ECHO))
  167. endif
  168. endif
  169. # To copy pograms
  170. ifndef COPY
  171. COPY:=cp -fp
  172. endif
  173. # Copy a whole tree
  174. ifndef COPYTREE
  175. COPYTREE:=cp -rfp
  176. endif
  177. # To move pograms
  178. ifndef MOVE
  179. MOVE:=mv -f
  180. endif
  181. # Check delete program
  182. ifndef DEL
  183. DEL:=rm -f
  184. endif
  185. # Check deltree program
  186. ifndef DELTREE
  187. DELTREE:=rm -rf
  188. endif
  189. # To install files
  190. ifndef INSTALL
  191. ifdef inlinux
  192. INSTALL:=install -m 644
  193. else
  194. INSTALL:=$(COPY)
  195. endif
  196. endif
  197. # To install programs
  198. ifndef INSTALLEXE
  199. ifdef inlinux
  200. INSTALLEXE:=install -m 755
  201. else
  202. INSTALLEXE:=$(COPY)
  203. endif
  204. endif
  205. # To make a directory.
  206. ifndef MKDIR
  207. ifdef inlinux
  208. MKDIR:=install -m 755 -d
  209. else
  210. MKDIR:=ginstall -m 755 -d
  211. endif
  212. endif
  213. export ECHO COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
  214. #####################################################################
  215. # Default Tools
  216. #####################################################################
  217. # assembler, redefine it if cross compiling
  218. ifndef AS
  219. AS=as
  220. endif
  221. # linker, but probably not used
  222. ifndef LD
  223. LD=ld
  224. endif
  225. # ppas.bat / ppas.sh
  226. ifdef inlinux
  227. PPAS=ppas.sh
  228. else
  229. ifdef inOS2
  230. PPAS=ppas.cmd
  231. else
  232. PPAS=ppas.bat
  233. endif
  234. endif
  235. # also call ppas if with command option -s
  236. ifeq (,$(findstring -s ,$(COMPILER)))
  237. EXECPPAS=
  238. else
  239. EXECPPAS:=@$(PPAS)
  240. endif
  241. # ldconfig to rebuild .so cache
  242. ifdef inlinux
  243. LDCONFIG=ldconfig
  244. else
  245. LDCONFIG=
  246. endif
  247. # ppdep
  248. ifndef PPDEP
  249. PPDEP:=$(strip $(wildcard $(addsuffix /ppdep$(EXEEXT),$(SEARCHPATH))))
  250. ifeq ($(PPDEP),)
  251. PPDEP=
  252. else
  253. PPDEP:=$(firstword $(PPDEP))
  254. endif
  255. endif
  256. export PPDEP
  257. # ppumove
  258. ifndef PPUMOVE
  259. PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(EXEEXT),$(SEARCHPATH))))
  260. ifeq ($(PPUMOVE),)
  261. PPUMOVE=
  262. else
  263. PPUMOVE:=$(firstword $(PPUMOVE))
  264. endif
  265. endif
  266. export PPUMOVE
  267. # ppufiles
  268. ifndef PPUFILES
  269. PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(EXEEXT),$(SEARCHPATH))))
  270. ifeq ($(PPUFILES),)
  271. PPUFILES=
  272. else
  273. PPUFILES:=$(firstword $(PPUFILES))
  274. endif
  275. endif
  276. export PPUFILES
  277. # Look if UPX is found for go32v2 and win32. We can't use $UPX becuase
  278. # upx uses that one itself (PFV)
  279. ifndef UPXPROG
  280. ifeq ($(OS_TARGET),go32v2)
  281. UPXPROG:=1
  282. endif
  283. ifeq ($(OS_TARGET),win32)
  284. UPXPROG:=1
  285. endif
  286. ifdef UPXPROG
  287. UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(EXEEXT),$(SEARCHPATH))))
  288. ifeq ($(UPXPROG),)
  289. UPXPROG=
  290. else
  291. UPXPROG:=$(firstword $(UPXPROG))
  292. endif
  293. else
  294. UPXPROG=
  295. endif
  296. endif
  297. export UPXPROG
  298. # gdate/date
  299. ifndef DATE
  300. DATE:=$(strip $(wildcard $(addsuffix /date$(EXEEXT),$(SEARCHPATH))))
  301. ifeq ($(DATE),)
  302. DATE:=$(strip $(wildcard $(addsuffix /gdate$(EXEEXT),$(SEACHPATH))))
  303. ifeq ($(DATE),)
  304. DATE=
  305. else
  306. DATE:=$(firstword $(DATE))
  307. endif
  308. else
  309. DATE:=$(firstword $(DATE))
  310. endif
  311. endif
  312. export DATE
  313. ifdef DATE
  314. DATESTR:=$(shell $(DATE) +%Y%m%d)
  315. else
  316. DATESTR=
  317. endif
  318. # ZipProg, you can't use Zip as the var name (PFV)
  319. ifndef ZIPPROG
  320. ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(EXEEXT),$(SEARCHPATH))))
  321. ifeq ($(ZIPPROG),)
  322. ZIPPROG=
  323. else
  324. ZIPPROG:=$(firstword $(ZIPPROG)) -D9 -r
  325. endif
  326. endif
  327. export ZIPPROG
  328. ifndef ZIPEXT
  329. ZIPEXT=.zip
  330. endif
  331. #####################################################################
  332. # Default extensions
  333. #####################################################################
  334. # Default needed extensions (Go32v2,Linux)
  335. LOADEREXT=.as
  336. PPLEXT=.ppl
  337. PPUEXT=.ppu
  338. OEXT=.o
  339. ASMEXT=.s
  340. SMARTEXT=.sl
  341. STATICLIBEXT=.a
  342. SHAREDLIBEXT=.so
  343. RSTEXT=.rst
  344. PACKAGESUFFIX=
  345. FPCMADE=fpcmade
  346. # Go32v1
  347. ifeq ($(OS_TARGET),go32v1)
  348. PPUEXT=.pp1
  349. OEXT=.o1
  350. ASMEXT=.s1
  351. SMARTEXT=.sl1
  352. STATICLIBEXT=.a1
  353. SHAREDLIBEXT=.so1
  354. PACKAGESUFFIX=v1
  355. FPCMADE=fpcmade.v1
  356. endif
  357. # Go32v2
  358. ifeq ($(OS_TARGET),go32v2)
  359. PACKAGESUFFIX=go32
  360. FPCMADE=fpcmade.dos
  361. endif
  362. # Linux
  363. ifeq ($(OS_TARGET),linux)
  364. PACKAGESUFFIX=linux
  365. FPCMADE=fpcmade.lnx
  366. endif
  367. # Win32
  368. ifeq ($(OS_TARGET),win32)
  369. PPUEXT=.ppw
  370. OEXT=.ow
  371. ASMEXT=.sw
  372. SMARTEXT=.slw
  373. STATICLIBEXT=.aw
  374. SHAREDLIBEXT=.dll
  375. PACKAGESUFFIX=w32
  376. FPCMADE=fpcmade.w32
  377. endif
  378. # OS/2
  379. ifeq ($(OS_TARGET),os2)
  380. PPUEXT=.ppo
  381. ASMEXT=.so2
  382. OEXT=.oo2
  383. SMARTEXT=.so
  384. STATICLIBEXT=.ao2
  385. SHAREDLIBEXT=.dll
  386. PACKAGESUFFIX=os2
  387. FPCMADE=fpcmade.os2
  388. endif
  389. # library prefix
  390. LIBPREFIX=lib
  391. ifeq ($(OS_TARGET),go32v2)
  392. LIBPREFIX=
  393. endif
  394. ifeq ($(OS_TARGET),go32v1)
  395. LIBPREFIX=
  396. endif
  397. # determine which .pas extension is used
  398. ifndef PASEXT
  399. ifdef EXEOBJECTS
  400. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS)))))
  401. else
  402. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS)))))
  403. endif
  404. ifeq ($(TESTPAS),)
  405. PASEXT=.pp
  406. else
  407. PASEXT=.pas
  408. endif
  409. endif
  410. # Check if the dirs really exists, else turn it off
  411. ifeq ($(wildcard $(UNITSDIR)),)
  412. UNITSDIR=
  413. endif
  414. ifeq ($(wildcard $(TOOLKITSDIR)),)
  415. TOOLKITSDIR=
  416. endif
  417. ifeq ($(wildcard $(PACKAGESDIR)),)
  418. PACKAGESDIR=
  419. endif
  420. ifeq ($(wildcard $(COMPONENTSDIR)),)
  421. COMPONENTSDIR=
  422. endif
  423. # PACKAGESDIR packages
  424. PACKAGERTL=1
  425. PACKAGEOPENGL=1
  426. PACKAGEX11=1
  427. ifdef PACKAGERTL
  428. ifneq ($(wildcard $(FPCDIR)/rtl),)
  429. ifneq ($(wildcard $(FPCDIR)/rtl/$(OS_TARGET)),)
  430. PACKAGEDIR_RTL=$(FPCDIR)/rtl/$(OS_TARGET)
  431. else
  432. PACKAGEDIR_RTL=$(FPCDIR)/rtl
  433. endif
  434. ifeq ($(wildcard $(PACKAGEDIR_RTL)/$(FPCMADE)),)
  435. override COMPILEPACKAGES+=package_rtl
  436. package_rtl:
  437. $(MAKE) -C $(PACKAGEDIR_RTL) all
  438. endif
  439. UNITDIR_RTL=$(PACKAGEDIR_RTL)
  440. else
  441. PACKAGEDIR_RTL=
  442. ifneq ($(wildcard $(UNITSDIR)/rtl),)
  443. ifneq ($(wildcard $(UNITSDIR)/rtl/$(OS_TARGET)),)
  444. UNITDIR_RTL=$(UNITSDIR)/rtl/$(OS_TARGET)
  445. else
  446. UNITDIR_RTL=$(UNITSDIR)/rtl
  447. endif
  448. else
  449. UNITDIR_RTL=
  450. endif
  451. endif
  452. ifdef UNITDIR_RTL
  453. override NEEDUNITDIR+=$(UNITDIR_RTL)
  454. endif
  455. endif
  456. ifdef PACKAGEOPENGL
  457. ifneq ($(wildcard $(PACKAGESDIR)/opengl),)
  458. ifneq ($(wildcard $(PACKAGESDIR)/opengl/$(OS_TARGET)),)
  459. PACKAGEDIR_OPENGL=$(PACKAGESDIR)/opengl/$(OS_TARGET)
  460. else
  461. PACKAGEDIR_OPENGL=$(PACKAGESDIR)/opengl
  462. endif
  463. ifeq ($(wildcard $(PACKAGEDIR_OPENGL)/$(FPCMADE)),)
  464. override COMPILEPACKAGES+=package_opengl
  465. package_opengl:
  466. $(MAKE) -C $(PACKAGEDIR_OPENGL) all
  467. endif
  468. UNITDIR_OPENGL=$(PACKAGEDIR_OPENGL)
  469. else
  470. PACKAGEDIR_OPENGL=
  471. ifneq ($(wildcard $(UNITSDIR)/opengl),)
  472. ifneq ($(wildcard $(UNITSDIR)/opengl/$(OS_TARGET)),)
  473. UNITDIR_OPENGL=$(UNITSDIR)/opengl/$(OS_TARGET)
  474. else
  475. UNITDIR_OPENGL=$(UNITSDIR)/opengl
  476. endif
  477. else
  478. UNITDIR_OPENGL=
  479. endif
  480. endif
  481. ifdef UNITDIR_OPENGL
  482. override NEEDUNITDIR+=$(UNITDIR_OPENGL)
  483. endif
  484. endif
  485. ifdef PACKAGEX11
  486. ifneq ($(wildcard $(PACKAGESDIR)/x11),)
  487. ifneq ($(wildcard $(PACKAGESDIR)/x11/$(OS_TARGET)),)
  488. PACKAGEDIR_X11=$(PACKAGESDIR)/x11/$(OS_TARGET)
  489. else
  490. PACKAGEDIR_X11=$(PACKAGESDIR)/x11
  491. endif
  492. ifeq ($(wildcard $(PACKAGEDIR_X11)/$(FPCMADE)),)
  493. override COMPILEPACKAGES+=package_x11
  494. package_x11:
  495. $(MAKE) -C $(PACKAGEDIR_X11) all
  496. endif
  497. UNITDIR_X11=$(PACKAGEDIR_X11)
  498. else
  499. PACKAGEDIR_X11=
  500. ifneq ($(wildcard $(UNITSDIR)/x11),)
  501. ifneq ($(wildcard $(UNITSDIR)/x11/$(OS_TARGET)),)
  502. UNITDIR_X11=$(UNITSDIR)/x11/$(OS_TARGET)
  503. else
  504. UNITDIR_X11=$(UNITSDIR)/x11
  505. endif
  506. else
  507. UNITDIR_X11=
  508. endif
  509. endif
  510. ifdef UNITDIR_X11
  511. override NEEDUNITDIR+=$(UNITDIR_X11)
  512. endif
  513. endif
  514. #####################################################################
  515. # Default Directories
  516. #####################################################################
  517. # set the prefix directory where to install everything
  518. ifndef PREFIXINSTALLDIR
  519. ifdef inlinux
  520. PREFIXINSTALLDIR=/usr
  521. else
  522. PREFIXINSTALLDIR=/pp
  523. endif
  524. endif
  525. export PREFIXINSTALLDIR
  526. # Where to find other libraries
  527. ifdef inlinux
  528. ifndef OTHERLIBDIR
  529. OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
  530. endif
  531. endif
  532. export OTHERLIBDIR
  533. #####################################################################
  534. # Install Directories
  535. #####################################################################
  536. # set the base directory where to install everything
  537. ifndef BASEINSTALLDIR
  538. ifdef inlinux
  539. BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION)
  540. else
  541. BASEINSTALLDIR=$(PREFIXINSTALLDIR)
  542. endif
  543. endif
  544. # set the directory where to install the binaries
  545. ifndef BININSTALLDIR
  546. ifdef inlinux
  547. BININSTALLDIR=$(PREFIXINSTALLDIR)/bin
  548. else
  549. BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET)
  550. endif
  551. endif
  552. # set the directory where to install the units.
  553. ifndef UNITINSTALLDIR
  554. UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET)
  555. ifdef UNITSUBDIR
  556. UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR)
  557. endif
  558. endif
  559. # Where to install shared libraries
  560. ifndef LIBINSTALLDIR
  561. ifdef inlinux
  562. LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib
  563. else
  564. LIBINSTALLDIR=$(UNITINSTALLDIR)
  565. endif
  566. endif
  567. # Where the source files will be stored
  568. ifndef SOURCEINSTALLDIR
  569. ifdef inlinux
  570. SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION)
  571. else
  572. SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source
  573. endif
  574. endif
  575. # Where the doc files will be stored
  576. ifndef DOCINSTALLDIR
  577. ifdef inlinux
  578. DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION)
  579. else
  580. DOCINSTALLDIR=$(BASEINSTALLDIR)/doc
  581. endif
  582. endif
  583. # Where the some extra (data)files will be stored
  584. ifndef DATAINSTALLDIR
  585. DATAINSTALLDIR=$(BASEINSTALLDIR)
  586. endif
  587. #####################################################################
  588. # Redirection
  589. #####################################################################
  590. # Release ? Then force OPT and don't use extra opts via commandline
  591. ifndef REDIRFILE
  592. REDIRFILE=log
  593. endif
  594. ifdef REDIR
  595. ifndef inlinux
  596. override FPC=redir -eo $(FPC)
  597. endif
  598. # set the verbosity to max
  599. override FPCOPT+=-va
  600. override REDIR:= >> $(REDIRFILE)
  601. endif
  602. #####################################################################
  603. # Compiler Command Line
  604. #####################################################################
  605. # Load commandline OPTDEF and add FPC_CPU define
  606. override FPCOPTDEF:=-d$(CPU_TARGET)
  607. # Load commandline OPT and add target and unit dir to be sure
  608. ifneq ($(OS_TARGET),$(OS_SOURCE))
  609. override FPCOPT+=-T$(OS_TARGET)
  610. endif
  611. ifdef NEEDUNITDIR
  612. override FPCOPT+=$(addprefix -Fu,$(NEEDUNITDIR))
  613. endif
  614. ifdef UNITSDIR
  615. override FPCOPT+=-Fu$(UNITSDIR)
  616. endif
  617. # Add Other dirs path if asked
  618. ifdef OTHERLIBDIR
  619. override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
  620. endif
  621. # Smartlinking
  622. ifdef SMARTLINK
  623. override FPCOPT+=-CX
  624. endif
  625. # Debug
  626. ifdef DEBUG
  627. override FPCOPT+=-g -dDEBUG
  628. endif
  629. # Release mode (strip, optimize and don't load ppc386.cfg)
  630. ifdef RELEASE
  631. override FPCOPT+=-Xs -OG2p3 -n
  632. endif
  633. # Verbose settings (warning,note,info)
  634. ifdef VERBOSE
  635. override FPCOPT+=-vwni
  636. endif
  637. # Add commandline options
  638. ifdef OPT
  639. override FPCOPT+=$(OPT)
  640. endif
  641. ifdef UNITDIR
  642. override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
  643. endif
  644. ifdef LIBDIR
  645. override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
  646. endif
  647. ifdef OBJDIR
  648. override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
  649. endif
  650. ifdef INCDIR
  651. override FPCOPT+=$(addprefix -Fi,$(INCDIR))
  652. endif
  653. # Add defines from FPCOPTDEF to FPCOPT
  654. ifdef FPCOPTDEF
  655. override FPCOPT+=$(FPCOPTDEF)
  656. endif
  657. # Error file ?
  658. ifdef ERRORFILE
  659. override FPCOPT+=-Fr$(ERRORFILE)
  660. endif
  661. # Was a config file specified ?
  662. ifdef CFGFILE
  663. override FPCOPT+=@$(CFGFILE)
  664. endif
  665. # For win32 the options are passed using the file fpcext.cmd
  666. ifndef FPCEXTCMD
  667. FPCEXTCMD=fpcext.cmd
  668. endif
  669. ifeq ($(OS_SOURCE),win32)
  670. override TMPVAR:=$(shell "$(DEL) $(FPCEXTCMD)")
  671. override TMPVAR:=$(foreach A,$(FPCOPT),$(shell "$(ECHO) $(A) >> $(FPCEXTCMD)"))
  672. override FPCOPT:=@$(FPCEXTCMD)
  673. endif
  674. # Compiler commandline
  675. override COMPILER:=$(FPC) $(FPCOPT)
  676. #####################################################################
  677. # Standard rules
  678. #####################################################################
  679. all: fpc_all
  680. debug: fpc_debug
  681. smart: fpc_smart
  682. shared: fpc_shared
  683. showinstall: fpc_showinstall
  684. install: fpc_install
  685. sourceinstall: fpc_sourceinstall
  686. zipinstall: fpc_zipinstall
  687. zipinstalladd: fpc_zipinstalladd
  688. clean: fpc_clean
  689. cleanall: fpc_cleanall
  690. info: fpc_info
  691. .PHONY: all debug smart shared showinstall install sourceinstall zipinstall zipinstalladd clean cleanall info
  692. #####################################################################
  693. # Exes
  694. #####################################################################
  695. .PHONY: fpc_exes
  696. override EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS))
  697. override EXEOFILES=$(addsuffix $(OEXT),$(EXEOBJECTS))
  698. override ALLTARGET+=fpc_exes
  699. override INSTALLEXEFILES+=$(EXEFILES)
  700. override CLEANEXEFILES+=$(EXEFILES) $(EXEOFILES)
  701. fpc_exes: $(EXEFILES)
  702. #####################################################################
  703. # General compile rules
  704. #####################################################################
  705. .PHONY: fpc_packages fpc_all fpc_debug
  706. $(FPCMADE): $(ALLTARGET)
  707. @$(ECHO) Compiled > $(FPCMADE)
  708. fpc_packages: $(COMPILEPACKAGES)
  709. fpc_all: fpc_packages $(FPCMADE)
  710. fpc_debug:
  711. $(MAKE) all DEBUG=1
  712. # General compile rules, available for both possible PASEXT
  713. .SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp
  714. %$(PPUEXT): %.pp
  715. $(COMPILER) $< $(REDIR)
  716. $(EXECPASS)
  717. %$(PPUEXT): %.pas
  718. $(COMPILER) $< $(REDIR)
  719. $(EXECPASS)
  720. %$(EXEEXT): %.pp
  721. $(COMPILER) $< $(REDIR)
  722. $(EXECPASS)
  723. %$(EXEEXT): %.pas
  724. $(COMPILER) $< $(REDIR)
  725. $(EXECPASS)
  726. #####################################################################
  727. # Library
  728. #####################################################################
  729. .PHONY: fpc_smart fpc_shared
  730. # Default sharedlib units are all unit objects
  731. ifndef SHAREDLIBUNITOBJECTS
  732. SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS)
  733. endif
  734. fpc_smart:
  735. $(MAKE) all SMARTLINK=1
  736. fpc_shared: all
  737. ifdef inlinux
  738. ifndef LIBNAME
  739. @$(ECHO) "LIBNAME not set"
  740. else
  741. $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBNAME)
  742. endif
  743. else
  744. @$(ECHO) "Shared Libraries not supported"
  745. endif
  746. #####################################################################
  747. # Install rules
  748. #####################################################################
  749. .PHONY: fpc_showinstall fpc_install
  750. ifdef EXTRAINSTALLUNITS
  751. override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))
  752. endif
  753. ifdef INSTALLPPUFILES
  754. ifdef PPUFILES
  755. ifdef inlinux
  756. INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES))
  757. INSTALLPPULIBFILES:=$(shell $(PPUFILES) -L $(INSTALLPPUFILES))
  758. else
  759. INSTALLPPULINKFILES:=$(shell $(PPUFILES) $(INSTALLPPUFILES))
  760. endif
  761. else
  762. INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)))
  763. endif
  764. endif
  765. fpc_showinstall: $(SHOWINSTALLTARGET)
  766. ifdef INSTALLEXEFILES
  767. @$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES))
  768. endif
  769. ifdef INSTALLPPUFILES
  770. @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES))
  771. ifneq ($(INSTALLPPULINKFILES),)
  772. @$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES))
  773. endif
  774. ifneq ($(INSTALLPPULIBFILES),)
  775. @$(ECHO) -e $(addprefix "\n"$(LIBINSTALLDIR)/,$(INSTALLPPULIBFILES))
  776. endif
  777. endif
  778. ifdef EXTRAINSTALLFILES
  779. @$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(EXTRAINSTALLFILES))
  780. endif
  781. fpc_install: $(INSTALLTARGET)
  782. # Create UnitInstallFiles
  783. ifdef INSTALLEXEFILES
  784. $(MKDIR) $(BININSTALLDIR)
  785. # Compress the exes if upx is defined
  786. ifdef UPXPROG
  787. -$(UPXPROG) $(INSTALLEXEFILES)
  788. endif
  789. $(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR)
  790. endif
  791. ifdef INSTALLPPUFILES
  792. $(MKDIR) $(UNITINSTALLDIR)
  793. $(INSTALL) $(INSTALLPPUFILES) $(UNITINSTALLDIR)
  794. ifneq ($(INSTALLPPULINKFILES),)
  795. $(INSTALL) $(INSTALLPPULINKFILES) $(UNITINSTALLDIR)
  796. endif
  797. ifneq ($(INSTALLPPULIBFILES),)
  798. $(MKDIR) $(LIBINSTALLDIR)
  799. $(INSTALL) $(INSTALLPPULIBFILES) $(LIBINSTALLDIR)
  800. endif
  801. endif
  802. ifdef EXTRAINSTALLFILES
  803. $(MKDIR) $(DATAINSTALLDIR)
  804. $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR)
  805. endif
  806. #####################################################################
  807. # Source install rules
  808. #####################################################################
  809. .PHONY: fpc_sourceinstall
  810. fpc_sourceinstall: clean
  811. $(MKDIR) $(SOURCEINSTALLDIR)
  812. $(COPYTREE) $(BASEDIR) $(SOURCEINSTALLDIR)
  813. #####################################################################
  814. # Zip
  815. #####################################################################
  816. .PHONY: fpc_zipinstall fpc_zipinstalladd
  817. # Temporary path to pack a file
  818. ifndef PACKDIR
  819. ifndef inlinux
  820. PACKDIR=$(BASEDIR)/pack_tmp
  821. else
  822. PACKDIR=/tmp/fpc-pack
  823. endif
  824. endif
  825. # Test dir if none specified
  826. ifndef DESTZIPDIR
  827. DESTZIPDIR:=$(BASEDIR)
  828. endif
  829. # Maybe create default zipname from packagename
  830. ifndef ZIPNAME
  831. ifdef PACKAGENAME
  832. ZIPNAME=$(PACKAGENAME)$(PACKAGESUFFIX)
  833. endif
  834. endif
  835. # Add .zip/.tar.gz extension
  836. ifdef ZIPNAME
  837. ifndef inlinux
  838. override ZIPNAME:=$(ZIPNAME)$(ZIPEXT)
  839. endif
  840. endif
  841. # Note: This will not remove the zipfile first
  842. fpc_zipinstalladd:
  843. ifndef ZIPNAME
  844. @$(ECHO) "Please specify ZIPNAME!"
  845. @exit 1
  846. else
  847. $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
  848. ifdef inlinux
  849. gzip -d $(DESTZIPDIR)/$(ZIPNAME).tar.gz
  850. cd $(PACKDIR) ; tar rv --file $(DESTZIPDIR)/$(ZIPNAME).tar * ; cd $(BASEDIR)
  851. gzip $(DESTZIPDIR)/$(ZIPNAME).tar
  852. else
  853. cd $(PACKDIR) ; $(ZIPPROG) $(DESTZIPDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
  854. endif
  855. $(DELTREE) $(PACKDIR)
  856. endif
  857. # First remove the zip and then install
  858. fpc_zipinstall:
  859. ifndef ZIPNAME
  860. @$(ECHO) "Please specify ZIPNAME!"
  861. @exit 1
  862. else
  863. $(DEL) $(DESTZIPDIR)/$(ZIPNAME)
  864. $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
  865. ifdef inlinux
  866. cd $(PACKDIR) ; tar cvz --file $(DESTZIPDIR)/$(ZIPNAME).tar.gz * ; cd $(BASEDIR)
  867. else
  868. cd $(PACKDIR) ; $(ZIPPROG) $(DESTZIPDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
  869. endif
  870. $(DELTREE) $(PACKDIR)
  871. endif
  872. #####################################################################
  873. # Clean rules
  874. #####################################################################
  875. .PHONY: fpc_clean fpc_cleanall
  876. ifdef EXTRACLEANUNITS
  877. override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS))
  878. endif
  879. ifdef CLEANPPUFILES
  880. ifdef PPUFILES
  881. CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES))
  882. else
  883. CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)))
  884. endif
  885. endif
  886. fpc_clean: $(CLEANTARGET)
  887. ifdef CLEANEXEFILES
  888. -$(DEL) $(CLEANEXEFILES)
  889. endif
  890. ifdef CLEANPPUFILES
  891. -$(DEL) $(CLEANPPUFILES)
  892. endif
  893. ifneq ($(CLEANPPULINKFILES),)
  894. -$(DEL) $(CLEANPPULINKFILES)
  895. endif
  896. ifdef CLEANRSTFILES
  897. -$(DEL) $(CLEANRSTFILES)
  898. endif
  899. ifdef EXTRACLEANFILES
  900. -$(DEL) $(EXTRACLEANFILES)
  901. endif
  902. -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTCMD) $(REDIRFILE)
  903. fpc_cleanall: $(CLEANTARGET)
  904. ifdef CLEANEXEFILES
  905. -$(DEL) $(CLEANEXEFILES)
  906. endif
  907. -$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  908. -$(DELTREE) *$(SMARTEXT)
  909. -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTCMD) $(REDIRFILE)
  910. #####################################################################
  911. # Info rules
  912. #####################################################################
  913. .PHONY: fpc_info fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo \
  914. fpc_dirinfo
  915. fpc_info: $(INFOTARGET)
  916. fpc_infocfg:
  917. @$(ECHO)
  918. @$(ECHO) == Configuration info ==
  919. @$(ECHO)
  920. @$(ECHO) FPC....... $(FPC)
  921. @$(ECHO) Version... $(FPC_VERSION)
  922. @$(ECHO) CPU....... $(CPU_TARGET)
  923. @$(ECHO) Source.... $(OS_SOURCE)
  924. @$(ECHO) Target.... $(OS_TARGET)
  925. @$(ECHO)
  926. fpc_infoobjects:
  927. @$(ECHO)
  928. @$(ECHO) == Object info ==
  929. @$(ECHO)
  930. @$(ECHO) LoaderObjects..... $(LOADEROBJECTS)
  931. @$(ECHO) UnitObjects....... $(UNITOBJECTS)
  932. @$(ECHO) ExeObjects........ $(EXEOBJECTS)
  933. @$(ECHO)
  934. @$(ECHO) ExtraCleanUnits... $(EXTRACLEANUNITS)
  935. @$(ECHO) ExtraCleanFiles... $(EXTRACLEANFILES)
  936. @$(ECHO)
  937. @$(ECHO) ExtraInstallUnits. $(EXTRAINSTALLUNITS)
  938. @$(ECHO) ExtraInstallFiles. $(EXTRAINSTALLFILES)
  939. @$(ECHO)
  940. fpc_infoinstall:
  941. @$(ECHO)
  942. @$(ECHO) == Install info ==
  943. @$(ECHO)
  944. ifdef DATE
  945. @$(ECHO) DateStr.............. $(DATESTR)
  946. endif
  947. ifdef PACKAGENAME
  948. @$(ECHO) PackageName.......... $(PACKAGENAME)
  949. endif
  950. @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX)
  951. @$(ECHO)
  952. @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR)
  953. @$(ECHO) BinInstallDir........ $(BININSTALLDIR)
  954. @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR)
  955. @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR)
  956. @$(ECHO) SourceInstallDir..... $(SOURCEINSTALLDIR)
  957. @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR)
  958. @$(ECHO) DataInstallDir....... $(DATAINSTALLDIR)
  959. @$(ECHO)
  960. @$(ECHO) DestZipDir........... $(DESTZIPDIR)
  961. @$(ECHO) ZipName.............. $(ZIPNAME)
  962. @$(ECHO)
  963. #####################################################################
  964. # Local Makefile
  965. #####################################################################
  966. ifneq ($(wildcard fpcmake.loc),)
  967. include fpcmake.loc
  968. endif