Makefile 26 KB

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