Makefile 23 KB

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