Makefile 22 KB

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