Makefile 23 KB

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