makefile.fpc 24 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135
  1. #
  2. # $Id$
  3. # Copyright (c) 1999 by the Free Pascal Development Team
  4. #
  5. # Common makefile for Free Pascal
  6. #
  7. # See the file COPYING.FPC, included in this distribution,
  8. # for details about the copyright.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. #
  14. #####################################################################
  15. # Autodetect OS (Linux or Dos or Windows NT)
  16. # define inlinux when running under linux
  17. # define inWinNT when running under WinNT
  18. #####################################################################
  19. # We want only / in the path !
  20. override PATH:=$(subst \,/,$(PATH))
  21. # Search for PWD and determine also if we are under linux
  22. PWD=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
  23. ifeq ($(PWD),)
  24. PWD=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
  25. ifeq ($(PWD),)
  26. nopwd:
  27. @echo You need the GNU utils package to use this makefile!
  28. @echo Get ftp://tflily.fys.kuleuven.ac.be/pub/fpc/dist/go32v2/utilgo32.zip
  29. @exit
  30. else
  31. inlinux=1
  32. endif
  33. else
  34. PWD:=$(firstword $(PWD))
  35. endif
  36. # Detect NT - NT sets OS to Windows_NT
  37. ifndef inlinux
  38. ifeq ($(OS),Windows_NT)
  39. inWinNT=1
  40. endif
  41. endif
  42. # Detect OS/2 - OS/2 has OS2_SHELL defined
  43. ifndef inlinux
  44. ifndef inWinNT
  45. ifdef OS2_SHELL
  46. inOS2=1
  47. endif
  48. endif
  49. endif
  50. # The extension of executables
  51. ifdef inlinux
  52. EXEEXT=
  53. else
  54. EXEEXT=.exe
  55. endif
  56. #####################################################################
  57. # Check for FPCDIR environment
  58. #####################################################################
  59. ifndef FPCDIR
  60. nofpcdir:
  61. @echo You need to set the FPCDIR environment variable to use
  62. @echo this Makefile.
  63. @echo Example: SET FPCDIR=/pp
  64. @exit
  65. endif
  66. #####################################################################
  67. # Targets
  68. #####################################################################
  69. # What compiler to use ?
  70. ifndef PP
  71. ifdef inOS2
  72. PP=ppos2$(EXEEXT)
  73. else
  74. PP=ppc386$(EXEEXT)
  75. endif
  76. endif
  77. # Target OS
  78. ifndef OS_TARGET
  79. OS_TARGET=$(shell $(PP) -iTO)
  80. endif
  81. # Source OS
  82. ifndef OS_SOURCE
  83. OS_SOURCE=$(shell $(PP) -iSO)
  84. endif
  85. # CPU
  86. ifndef CPU
  87. CPU=$(shell $(PP) -iTP)
  88. endif
  89. # FPC version
  90. FPC_VERSION=$(shell $(PP) -iV)
  91. # Options
  92. ifndef OPT
  93. OPT=
  94. endif
  95. # assembler, redefine it if cross compiling
  96. ifndef AS
  97. AS=as
  98. endif
  99. # linker, but probably not used
  100. ifndef LD
  101. LD=ld
  102. endif
  103. # Release ? Then force OPT and don't use extra opts via commandline
  104. ifdef RELEASE
  105. override OPT:=-Xs -OG2p3 -n
  106. endif
  107. # Verbose settings (warning,note,info)
  108. ifdef VERBOSE
  109. override OPT+=-vwni
  110. endif
  111. #####################################################################
  112. # Shell commands
  113. #####################################################################
  114. # To copy pograms
  115. ifndef COPY
  116. COPY=cp -fp
  117. endif
  118. # To move pograms
  119. ifndef MOVE
  120. MOVE=mv -f
  121. endif
  122. # Check delete program
  123. ifndef DEL
  124. DEL=rm -f
  125. endif
  126. # Check deltree program
  127. ifndef DELTREE
  128. DELTREE=rm -rf
  129. endif
  130. # To install files
  131. ifndef INSTALL
  132. ifdef inlinux
  133. INSTALL=install -m 644
  134. else
  135. INSTALL=$(COPY)
  136. # ginstall has the strange thing to stubify all .o files !
  137. #INSTALL=ginstall -m 644
  138. endif
  139. endif
  140. # To install programs
  141. ifndef INSTALLEXE
  142. ifdef inlinux
  143. INSTALLEXE=install -m 755
  144. else
  145. INSTALLEXE=$(COPY)
  146. # ginstall has the strange thing to stubify all .o files !
  147. #INSTALLEXE=ginstall -m 755
  148. endif
  149. endif
  150. # To make a directory.
  151. ifndef MKDIR
  152. ifdef inlinux
  153. MKDIR=install -m 755 -d
  154. else
  155. MKDIR=ginstall -m 755 -d
  156. endif
  157. endif
  158. #####################################################################
  159. # Default Tools
  160. #####################################################################
  161. # ppas.bat / ppas.sh
  162. ifdef inlinux
  163. PPAS=ppas.sh
  164. else
  165. ifdef inOS2
  166. PPAS=ppas.cmd
  167. else
  168. PPAS=ppas.bat
  169. endif
  170. endif
  171. # The path which is search separated by spaces
  172. ifdef inlinux
  173. SEARCHPATH=$(subst :, ,$(PATH))
  174. else
  175. SEARCHPATH=$(subst ;, ,$(PATH))
  176. endif
  177. # ldconfig to rebuild .so cache
  178. ifdef inlinux
  179. LDCONFIG=ldconfig
  180. else
  181. LDCONFIG=
  182. endif
  183. # Where is the ppumove program ?
  184. ifndef PPUMOVE
  185. PPUMOVE=ppumove
  186. endif
  187. # diff
  188. ifndef DIFF
  189. DIFF=$(strip $(wildcard $(addsuffix /diff$(EXEEXT),$(SEARCHPATH))))
  190. ifeq ($(DIFF),)
  191. DIFF=
  192. else
  193. export DIFF:=$(firstword $(DIFF))
  194. endif
  195. endif
  196. # cmp
  197. ifndef CMP
  198. CMP=$(strip $(wildcard $(addsuffix /cmp$(EXEEXT),$(SEARCHPATH))))
  199. ifeq ($(CMP),)
  200. CMP=
  201. else
  202. export CMP:=$(firstword $(CMP))
  203. endif
  204. endif
  205. # echo
  206. ifndef ECHO
  207. ECHO=$(strip $(wildcard $(addsuffix /echo$(EXEEXT),$(SEARCHPATH))))
  208. ifeq ($(ECHO),)
  209. ECHO=@echo
  210. else
  211. export ECHO:=@$(firstword $(ECHO))
  212. endif
  213. endif
  214. # gdate/date
  215. ifndef DATE
  216. DATE=$(strip $(wildcard $(addsuffix /date$(EXEEXT),$(SEARCHPATH))))
  217. ifeq ($(DATE),)
  218. DATE=$(strip $(wildcard $(addsuffix /gdate$(EXEEXT),$(SEACHPATH))))
  219. ifeq ($(DATE),)
  220. DATE=
  221. else
  222. export DATE:=$(firstword $(DATE))
  223. endif
  224. else
  225. export DATE:=$(firstword $(DATE))
  226. endif
  227. endif
  228. # Sed
  229. ifndef SED
  230. SED=$(strip $(wildcard $(addsuffix /sed$(EXEEXT),$(SEARCHPATH))))
  231. ifeq ($(SED),)
  232. SED=
  233. else
  234. export SED:=$(firstword $(SED))
  235. endif
  236. endif
  237. # Look if UPX is found for go32v2 and win32
  238. ifndef UPX
  239. ifeq ($(OS_TARGET),go32v2)
  240. UPX=1
  241. endif
  242. ifeq ($(OS_TARGET),win32)
  243. UPX=1
  244. endif
  245. ifdef UPX
  246. UPX=$(strip $(wildcard $(addsuffix /upx$(EXEEXT),$(SEARCHPATH))))
  247. ifeq ($(UPX),)
  248. UPX=
  249. else
  250. export UPX:=$(firstword $(UPX))
  251. endif
  252. else
  253. UPX=
  254. endif
  255. endif
  256. # ZipProg, you can't use Zip as the var name (PFV)
  257. ifndef ZIPPROG
  258. ZIPPROG=$(strip $(wildcard $(addsuffix /zip$(EXEEXT),$(SEARCHPATH))))
  259. ifeq ($(ZIPPROG),)
  260. ZIPPROG=
  261. else
  262. export ZIPPROG:=$(firstword $(ZIPPROG)) -D9 -r
  263. endif
  264. endif
  265. ifndef ZIPEXT
  266. ZIPEXT=.zip
  267. endif
  268. #####################################################################
  269. # Default Directories
  270. #####################################################################
  271. # Base dir
  272. ifdef PWD
  273. BASEDIR:=$(shell $(PWD))
  274. else
  275. BASEDIR=.
  276. endif
  277. # set the directory to the rtl base
  278. ifndef RTLDIR
  279. ifdef RTL
  280. RTLDIR:=$(RTL)/$(OS_TARGET)
  281. else
  282. RTLDIR:=$(FPCDIR)/rtl/$(OS_TARGET)
  283. endif
  284. endif
  285. # specify where units are.
  286. ifndef UNITDIR
  287. ifdef UNITS
  288. UNITDIR=$(UNITS)/$(OS_TARGET)
  289. else
  290. UNITDIR=$(FPCDIR)/units/$(OS_TARGET)
  291. endif
  292. endif
  293. # set the prefix directory where to install everything
  294. ifndef PREFIXINSTALLDIR
  295. ifdef inlinux
  296. PREFIXINSTALLDIR=/usr
  297. else
  298. PREFIXINSTALLDIR=/pp
  299. endif
  300. endif
  301. # set the base directory where to install everything
  302. ifndef BASEINSTALLDIR
  303. ifdef inlinux
  304. BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION)
  305. else
  306. BASEINSTALLDIR=$(PREFIXINSTALLDIR)
  307. endif
  308. endif
  309. # On linux, try to find where libgcc.a is.
  310. ifdef inlinux
  311. ifndef GCCLIBDIR
  312. GCCLIBDIR:=$(shell dirname `(gcc -v 2>&1)| head -n 1| awk '{ print $$4 } '`)
  313. endif
  314. ifndef OTHERLIBDIR
  315. OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
  316. endif
  317. endif
  318. #####################################################################
  319. # Install Directories based on BASEINSTALLDIR
  320. #####################################################################
  321. # Linux binary really goes to baseinstalldir
  322. ifndef LIBINSTALLDIR
  323. ifdef inlinux
  324. LIBINSTALLDIR=$(BASEINSTALLDIR)
  325. else
  326. LIBINSTALLDIR=$(BASEINSTALLDIR)/lib
  327. endif
  328. endif
  329. # set the directory where to install the binaries
  330. ifndef BININSTALLDIR
  331. ifdef inlinux
  332. BININSTALLDIR=$(PREFIXINSTALLDIR)/bin
  333. else
  334. BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET)
  335. endif
  336. endif
  337. # Where the .msg files will be stored
  338. ifndef MSGINSTALLDIR
  339. MSGINSTALLDIR=$(BASEINSTALLDIR)/msg
  340. endif
  341. # Where the .msg files will be stored
  342. ifndef SOURCEINSTALLDIR
  343. SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source
  344. endif
  345. # Where the doc files will be stored
  346. ifndef DOCINSTALLDIR
  347. ifdef inlinux
  348. DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc/$(FPC_VERSION)
  349. else
  350. DOCINSTALLDIR=$(BASEINSTALLDIR)/doc
  351. endif
  352. endif
  353. ########################
  354. # Unit Directories
  355. ########################
  356. # this can be set to 'rtl' when the RTL units are installed
  357. ifndef UNITPREFIX
  358. UNITPREFIX=units
  359. endif
  360. # set the directory where to install the units.
  361. ifndef UNITINSTALLDIR
  362. UNITINSTALLDIR=$(BASEINSTALLDIR)/$(UNITPREFIX)/$(OS_TARGET)
  363. endif
  364. # set the directory where to install the units.
  365. ifndef STATIC_UNITINSTALLDIR
  366. STATIC_UNITINSTALLDIR=$(UNITINSTALLDIR)/static
  367. endif
  368. # set the directory where to install the units.
  369. ifndef SHARED_UNITINSTALLDIR
  370. SHARED_UNITINSTALLDIR=$(UNITINSTALLDIR)/shared
  371. endif
  372. # set the directory where to install the libs (must exist)
  373. ifndef STATIC_LIBINSTALLDIR
  374. STATIC_LIBINSTALLDIR=$(STATIC_UNITINSTALLDIR)
  375. endif
  376. # set the directory where to install the libs (must exist)
  377. ifndef SHARED_LIBINSTALLDIR
  378. ifdef inlinux
  379. SHARED_LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib
  380. else
  381. SHARED_LIBINSTALLDIR=$(SHARED_UNITINSTALLDIR)
  382. endif
  383. endif
  384. #####################################################################
  385. # Compiler Command Line
  386. #####################################################################
  387. # Load commandline OPTDEF and add CPU define
  388. override PPOPTDEF:=$(OPTDEF) -d$(CPU)
  389. # Load commandline OPT and add target and unit dir to be sure
  390. override PPOPT:=-T$(OS_TARGET) $(NEEDOPT) $(OPT)
  391. # RTL first and then Unit dir (a unit can override RTLunit)
  392. ifdef RTLDIR
  393. override PPOPT+=$(addprefix -Fu,$(RTLDIR))
  394. endif
  395. ifdef UNITDIR
  396. override PPOPT+=$(addprefix -Fu,$(UNITDIR))
  397. endif
  398. ifdef NEEDUNITDIR
  399. override PPOPT+=$(addprefix -Fu,$(NEEDUNITDIR))
  400. endif
  401. # Library dirs
  402. ifdef LIBDIR
  403. override PPOPT+=$(addprefix -Fl,$(LIBDIR))
  404. endif
  405. ifdef NEEDLIBDIR
  406. override PPOPT+=$(addprefix -Fl,$(NEEDLIBDIR))
  407. endif
  408. # Add GCC lib path if asked
  409. ifdef NEEDGCCLIB
  410. ifdef GCCLIBDIR
  411. override PPOPT+=-Fl$(GCCLIBDIR)
  412. endif
  413. endif
  414. # Add Other dirs path if asked
  415. ifdef NEEDOTHERLIB
  416. ifdef OTHERLIBDIR
  417. override PPOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
  418. endif
  419. endif
  420. # Object dirs
  421. ifdef OBJDIR
  422. override PPOPT+=$(addprefix -Fo,$(OBJDIR))
  423. endif
  424. ifdef NEEDOBJDIR
  425. override PPOPT+=$(addprefix -Fo,$(NEEDOBJDIR))
  426. endif
  427. # Add include dirs INC and PROCINC and OSINC
  428. ifdef INC
  429. override PPOPT+=$(addprefix -Fi,$(INC))
  430. endif
  431. ifdef PROCINC
  432. override PPOPT+=$(addprefix -Fi,$(PROCINC))
  433. endif
  434. ifdef OSINC
  435. override PPOPT+=$(addprefix -Fi,$(OSINC))
  436. endif
  437. # Target dirs
  438. ifdef TARGETDIR
  439. override PPOPT+=-FE$(TARGETDIR)
  440. endif
  441. ifdef UNITTARGETDIR
  442. override PPOPT+=-FU$(UNITTARGETDIR)
  443. endif
  444. # Smartlinking
  445. ifeq ($(SMARTLINK),YES)
  446. override PPOPT+=-Cx
  447. endif
  448. # Add defines from PPOPTDEF to PPOPT
  449. override PPOPT:=$(PPOPT) $(PPOPTDEF)
  450. # Was a config file specified ?
  451. ifdef CFGFILE
  452. override PPOPT:=$(PPOPT) @$(CFGFILE)
  453. endif
  454. override COMPILER=$(PP) $(PPOPT)
  455. #####################################################################
  456. # Default extensions
  457. #####################################################################
  458. # Default needed extensions (Go32v2,Linux)
  459. LOADEREXT=.as
  460. PPLEXT=.ppl
  461. PPUEXT=.ppu
  462. OEXT=.o
  463. ASMEXT=.s
  464. SMARTEXT=.sl
  465. STATICLIBEXT=.a
  466. SHAREDLIBEXT=.so
  467. PACKAGESUFFIX=
  468. # Go32v1
  469. ifeq ($(OS_TARGET),go32v1)
  470. PPUEXT=.pp1
  471. OEXT=.o1
  472. ASMEXT=.s1
  473. SMARTEXT=.sl1
  474. STATICLIBEXT=.a1
  475. SHAREDLIBEXT=.so1
  476. PACKAGESUFFIX=v1
  477. endif
  478. # Go32v2
  479. ifeq ($(OS_TARGET),go32v2)
  480. PACKAGESUFFIX=go32
  481. endif
  482. # Linux
  483. ifeq ($(OS_TARGET),linux)
  484. PACKAGESUFFIX=linux
  485. endif
  486. # Win32
  487. ifeq ($(OS_TARGET),win32)
  488. PPUEXT=.ppw
  489. OEXT=.ow
  490. ASMEXT=.sw
  491. SMARTEXT=.slw
  492. STATICLIBEXT=.aw
  493. SHAREDLIBEXT=.dll
  494. PACKAGESUFFIX=win32
  495. endif
  496. # OS/2
  497. ifeq ($(OS_TARGET),os2)
  498. PPUEXT=.ppo
  499. ASMEXT=.so2
  500. OEXT=.oo2
  501. SMARTEXT=.so
  502. STATICLIBEXT=.ao2
  503. SHAREDLIBEXT=.dll
  504. PACKAGESUFFIX=os2
  505. endif
  506. # library prefix
  507. LIBPREFIX=lib
  508. ifeq ($(OS_TARGET),go32v2)
  509. LIBPREFIX=
  510. endif
  511. ifeq ($(OS_TARGET),go32v1)
  512. LIBPREFIX=
  513. endif
  514. # determine which .pas extension is used
  515. ifndef PASEXT
  516. ifdef EXEOBJECTS
  517. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS)))))
  518. else
  519. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS)))))
  520. endif
  521. ifeq ($(TESTPAS),)
  522. PASEXT=.pp
  523. else
  524. PASEXT=.pas
  525. endif
  526. endif
  527. # also call ppas if with command option -s
  528. ifeq (,$(findstring -s ,$(COMPILER)))
  529. EXECPPAS=
  530. else
  531. EXECPPAS=@$(PPAS)
  532. endif
  533. ifdef DATE
  534. DATESTR=$(shell $(DATE) +%Y%m%d)
  535. else
  536. DATESTR=
  537. endif
  538. #####################################################################
  539. # Export commandline values, so nesting use the same values
  540. #####################################################################
  541. # Makefile
  542. export FPCDIR FPCMAKE
  543. # Compiler info
  544. export FPC_VERSION OS_SOURCE OS_TARGET CPU
  545. export OPT OPTDEF PP RELEASE VERBOSE SMARTLINK
  546. # Installation
  547. export PREFIXINSTALLDIR PACKAGESUFFIX
  548. # Directories
  549. export GCCLIBDIR OTHERLIBDIR
  550. #####################################################################
  551. # General compile rules
  552. #####################################################################
  553. # Create Filenames
  554. LOADEROFILES=$(addsuffix $(OEXT),$(LOADEROBJECTS))
  555. EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS))
  556. EXEOFILES=$(addsuffix $(OEXT),$(EXEOBJECTS))
  557. UNITFILES=$(addsuffix $(PPUEXT),$(UNITOBJECTS))
  558. UNITOFILES=$(addsuffix $(OEXT),$(UNITOBJECTS))
  559. UNITAFILES=$(addsuffix $(STATICLIBEXT),$(UNITOBJECTS))
  560. .PHONY : fpc_all fpc_units fpc_loaders fpc_exes \
  561. fpc_staticlib fpc_sharedlib \
  562. fpc_clean fpc_libsclean fpc_cleanall \
  563. fpc_install fpc_staticinstall fpc_sharedinstall fpc_libinstall \
  564. fpc_info fpc_cfginfo fpc_objectinfo fpc_installinfo fpc_filesinfo\
  565. fpc_dirinfo
  566. .SUFFIXES : $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp
  567. #####################################################################
  568. # Default
  569. #####################################################################
  570. ifdef DEFAULTUNITS
  571. fpc_all: fpc_loaders fpc_units
  572. else
  573. fpc_all: fpc_loaders fpc_units fpc_exes
  574. endif
  575. fpc_loaders: $(LOADEROFILES)
  576. fpc_units: $(UNITFILES)
  577. fpc_exes: $(EXEFILES)
  578. # General compile rules, available for both possible PASEXT
  579. %$(PPUEXT): %.pp
  580. $(COMPILER) $< $(REDIR)
  581. $(EXECPASS)
  582. %$(PPUEXT): %.pas
  583. $(COMPILER) $< $(REDIR)
  584. $(EXECPASS)
  585. %$(EXEEXT): %.pp
  586. $(COMPILER) $< $(REDIR)
  587. $(EXECPASS)
  588. %$(EXEEXT): %.pas
  589. $(COMPILER) $< $(REDIR)
  590. $(EXECPASS)
  591. %$(OEXT): %$(LOADEREXT)
  592. $(AS) -o $*$(OEXT) $<
  593. #####################################################################
  594. # Library
  595. #####################################################################
  596. # Default sharedlib units are all unit objects
  597. ifndef SHAREDLIBUNITOBJECTS
  598. SHAREDLIBUNITOBJECTS=UNITOBJECTS
  599. endif
  600. fpc_staticlib:
  601. $(MAKE) libsclean
  602. $(MAKE) all SMARTLINK=YES
  603. fpc_sharedlib:
  604. ifdef inlinux
  605. ifndef LIBNAME
  606. $(ECHO) LIBNAME not set
  607. else
  608. $(MAKE) libsclean
  609. $(MAKE) all
  610. $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBNAME)
  611. endif
  612. else
  613. @$(ECHO) Shared Libraries not supported
  614. endif
  615. #####################################################################
  616. # Install rules
  617. #####################################################################
  618. fpc_showinstallfiles : all
  619. ifndef DEFAULTUNITS
  620. ifdef EXEOBJECTS
  621. $(ECHO) $(addprefix "\n"$(BININSTALLDIR)/,$(EXEFILES))
  622. endif
  623. endif
  624. ifdef LOADEROBJECTS
  625. $(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(LOADEROFILES))
  626. endif
  627. ifdef UNITOBJECTS
  628. $(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(UNITFILES))
  629. $(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(UNITOFILES))
  630. endif
  631. fpc_install : all
  632. ifndef DEFAULTUNITS
  633. ifdef EXEOBJECTS
  634. $(MKDIR) $(BININSTALLDIR)
  635. # Compress the exes if upx is defined
  636. ifdef UPX
  637. -$(UPX) $(EXEFILES)
  638. endif
  639. $(INSTALLEXE) $(EXEFILES) $(BININSTALLDIR)
  640. endif
  641. endif
  642. ifdef LOADEROBJECTS
  643. $(MKDIR) $(UNITINSTALLDIR)
  644. $(INSTALL) $(LOADEROFILES) $(UNITINSTALLDIR)
  645. endif
  646. ifdef UNITOBJECTS
  647. $(MKDIR) $(UNITINSTALLDIR)
  648. $(INSTALL) $(UNITFILES) $(UNITINSTALLDIR)
  649. ifeq ($(SMARTLINK),YES)
  650. $(INSTALL) $(LIBPREFIX)$(LIBNAME)$(LIBEXT) $(UNITINSTALLDIR)
  651. else
  652. -$(INSTALL) $(UNITOFILES) $(UNITINSTALLDIR)
  653. endif
  654. endif
  655. # Target for the sharedlib install which is not avail for all targets
  656. ifdef inlinux
  657. SHAREDINSTALL=sharedinstall
  658. else
  659. SHAREDINSTALL=
  660. endif
  661. fpc_staticinstall: staticlib
  662. $(MKDIR) $(STATIC_UNITINSTALLDIR)
  663. $(INSTALL) $(UNITFILES) $(STATIC_UNITINSTALLDIR)
  664. $(MKDIR) $(STATIC_LIBINSTALLDIR)
  665. $(INSTALLEXE) *$(STATICLIBEXT) $(STATIC_LIBINSTALLDIR)
  666. fpc_sharedinstall: sharedlib
  667. $(MKDIR) $(SHARED_UNITINSTALLDIR)
  668. $(INSTALL) $(UNITFILES) $(SHARED_UNITINSTALLDIR)
  669. $(MKDIR) $(SHARED_LIBINSTALLDIR)
  670. $(INSTALLEXE) *$(SHAREDLIBEXT) $(SHARED_LIBINSTALLDIR)
  671. fpc_libinstall: staticinstall $(SHAREDINSTALL)
  672. #####################################################################
  673. # Zip
  674. #####################################################################
  675. # Temporary path to pack a file
  676. ifndef PACKDIR
  677. ifndef inlinux
  678. PACKDIR=pack_tmp
  679. else
  680. PACKDIR=/tmp/fpc-pack
  681. endif
  682. endif
  683. # Test dir if none specified
  684. ifndef PACKAGEDIR
  685. PACKAGEDIR=$(BASEDIR)
  686. endif
  687. # Add .zip/.tar.gz extension
  688. ifdef ZIPNAME
  689. ifndef inlinux
  690. override ZIPNAME:=$(ZIPNAME)$(ZIPEXT)
  691. endif
  692. endif
  693. # Default target which is call before zipping
  694. ifndef ZIPTARGET
  695. ZIPTARGET=install
  696. endif
  697. # Note: This will not remove the zipfile first
  698. fpc_zipinstalladd:
  699. ifndef ZIPNAME
  700. @$(ECHO) Please specify ZIPNAME!
  701. @exit
  702. else
  703. $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
  704. ifdef inlinux
  705. gzip -d $(PACKAGEDIR)/$(ZIPNAME).tar.gz
  706. cd $(PACKDIR) ; tar rv --file $(PACKAGEDIR)/$(ZIPNAME).tar * ; cd $(BASEDIR)
  707. gzip $(PACKAGEDIR)/$(ZIPNAME).tar
  708. else
  709. cd $(PACKDIR) ; $(ZIPPROG) $(PACKAGEDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
  710. endif
  711. $(DELTREE) $(PACKDIR)
  712. endif
  713. # First remove the zip and then install
  714. fpc_zipinstall:
  715. ifndef ZIPNAME
  716. @$(ECHO) Please specify ZIPNAME!
  717. @exit
  718. else
  719. $(DEL) $(PACKAGEDIR)/$(ZIPNAME)
  720. $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
  721. ifdef inlinux
  722. cd $(PACKDIR) ; tar cvz --file $(PACKAGEDIR)/$(ZIPNAME).tar.gz * ; cd $(BASEDIR)
  723. else
  724. cd $(PACKDIR) ; $(ZIPPROG) $(PACKAGEDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
  725. endif
  726. $(DELTREE) $(PACKDIR)
  727. endif
  728. #####################################################################
  729. # Clean rules
  730. #####################################################################
  731. fpc_clean:
  732. ifdef UNITOBJECTS
  733. -$(DEL) $(UNITOFILES) $(UNITAFILES) $(UNITFILES)
  734. endif
  735. ifdef EXEOBJECTS
  736. -$(DEL) $(EXEFILES) $(EXEOFILES)
  737. endif
  738. ifdef LOADEROBJECTS
  739. -$(DEL) $(LOADEROFILES)
  740. endif
  741. ifdef EXTRAUNITS
  742. -$(DEL) $(addsuffix $(OEXT),$(EXTRAUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAUNITS)) $(addsuffix $(PPUEXT),$(EXTRAUNITS))
  743. endif
  744. -$(DEL) $(PPAS) link.res log
  745. fpc_libsclean: clean
  746. -$(DEL) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  747. fpc_cleanall:
  748. ifdef EXEOBJECTS
  749. -$(DEL) $(EXEFILES)
  750. endif
  751. -$(DEL) *$(OEXT) *$(PPUEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  752. -$(DELTREE) *$(SMARTEXT)
  753. #####################################################################
  754. # Depend rules
  755. #####################################################################
  756. fpc_depend:
  757. makedep $(UNITOBJECTS)
  758. #####################################################################
  759. # Info rules
  760. #####################################################################
  761. fpc_info: fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo\
  762. fpc_dirinfo
  763. fpc_cfginfo:
  764. @$(ECHO)
  765. @$(ECHO) == Configuration info ==
  766. @$(ECHO)
  767. @$(ECHO) FPCDir.... $(FPCDIR)
  768. @$(ECHO) FPCMake... $(FPCMAKE)
  769. @$(ECHO)
  770. @$(ECHO) Version... $(FPC_VERSION)
  771. @$(ECHO) CPU....... $(CPU)
  772. @$(ECHO) Source.... $(OS_SOURCE)
  773. @$(ECHO) Target.... $(OS_TARGET)
  774. @$(ECHO)
  775. fpc_dirinfo:
  776. ifdef inlinux
  777. @$(ECHO)
  778. @$(ECHO) == Directory info ==
  779. @$(ECHO)
  780. ifdef NEEDGCCLIB
  781. @$(ECHO) GCC library is needed.
  782. endif
  783. ifdef NEEDOTHERLIB
  784. @$(ECHO) Other library is needed.
  785. endif
  786. @$(ECHO) Basedir......... $(BASEDIR)
  787. @$(ECHO)
  788. @$(ECHO) GCC library..... $(GCCLIBDIR)
  789. @$(ECHO) Other library... $(OTHERLIBDIR)
  790. @$(ECHO)
  791. endif
  792. fpc_toolsinfo:
  793. @$(ECHO)
  794. @$(ECHO) == Tools info ==
  795. @$(ECHO)
  796. @$(ECHO) Pwd....... $(PWD)
  797. @$(ECHO) Echo...... $(ECHO)
  798. ifdef SED
  799. @$(ECHO) Sed....... $(SED)
  800. endif
  801. ifdef DATE
  802. @$(ECHO) Date...... $(DATE)
  803. endif
  804. ifdef DIFF
  805. @$(ECHO) Diff...... $(DIFF)
  806. endif
  807. ifdef CMP
  808. @$(ECHO) Cmp....... $(CMP)
  809. endif
  810. ifdef UPX
  811. @$(ECHO) Upx....... $(UPX)
  812. endif
  813. ifdef ZIPPROG
  814. @$(ECHO) Zip....... $(ZIPPROG)
  815. endif
  816. @$(ECHO)
  817. fpc_objectinfo:
  818. @$(ECHO)
  819. @$(ECHO) == Object info ==
  820. @$(ECHO)
  821. @$(ECHO) LoaderObjects. $(LOADEROBJECTS)
  822. @$(ECHO) UnitObjects... $(UNITOBJECTS)
  823. @$(ECHO) ExeObjects.... $(EXEOBJECTS)
  824. @$(ECHO)
  825. @$(ECHO) ExtraUnits.... $(EXTRAUNITS)
  826. @$(ECHO)
  827. fpc_installinfo:
  828. @$(ECHO)
  829. @$(ECHO) == Install info ==
  830. @$(ECHO)
  831. @$(ECHO) DateStr.............. $(DATESTR)
  832. @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX)
  833. @$(ECHO)
  834. @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR)
  835. @$(ECHO) BinInstallDir........ $(BININSTALLDIR)
  836. @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR)
  837. @$(ECHO) StaticUnitInstallDir. $(STATIC_UNITINSTALLDIR)
  838. @$(ECHO) SharedUnitInstallDir. $(SHARED_UNITINSTALLDIR)
  839. @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR)
  840. @$(ECHO) StaticLibInstallDir.. $(STATIC_LIBINSTALLDIR)
  841. @$(ECHO) SharedLibInstallDir.. $(SHARED_LIBINSTALLDIR)
  842. @$(ECHO) MsgInstallDir........ $(MSGINSTALLDIR)
  843. @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR)
  844. @$(ECHO)
  845. # try to get the files in the currentdir
  846. PASFILES:=$(wildcard *.pas)
  847. PPFILES:=$(wildcard *.pp)
  848. INCFILES:=$(wildcard *.inc)
  849. MSGFILES:=$(wildcard *.msg)
  850. ASFILES:=$(wildcard *.as)
  851. fpc_filesinfo:
  852. @$(ECHO)
  853. @$(ECHO) == Files info ==
  854. @$(ECHO)
  855. ifdef PASFILES
  856. @$(ECHO) Pas files are $(PASFILES)
  857. endif
  858. ifdef PPFILES
  859. @$(ECHO) PP files are $(PPFILES)
  860. endif
  861. ifdef INCFILES
  862. @$(ECHO) Inc files are $(INCFILES)
  863. endif
  864. ifdef MSGFILES
  865. @$(ECHO) Msg files are $(MSGFILES)
  866. endif
  867. ifdef ASFILES
  868. @$(ECHO) As files are $(ASFILES)
  869. endif
  870. #
  871. # $Log$
  872. # Revision 1.37 1999-07-05 21:37:35 peter
  873. # * display extraunits in info
  874. #
  875. # Revision 1.36 1999/07/01 18:20:01 jonas
  876. # * changed RELEASE=1 processor option from -Op2 to -Op3
  877. #
  878. # Revision 1.35 1999/06/18 11:03:08 peter
  879. # * merged
  880. #
  881. # Revision 1.34 1999/06/18 10:11:18 peter
  882. # * merged
  883. #
  884. # Revision 1.33 1999/06/13 22:43:23 peter
  885. # * merged from fixes
  886. #
  887. # Revision 1.32 1999/06/11 13:31:14 hajny
  888. # * fixes for OS/2
  889. #
  890. # Revision 1.31.2.3 1999/06/18 10:55:31 peter
  891. # * version fixes
  892. # * EXTRAUNITS to set extra units that are build and needs to be cleaned
  893. #
  894. # Revision 1.31.2.2 1999/06/18 10:07:27 peter
  895. # * rtl/linux and units/linux also for linux installs
  896. #
  897. # Revision 1.31.2.1 1999/06/13 22:36:38 peter
  898. # * install msg files in msg/ instead of bin for not linux
  899. #
  900. # Revision 1.31 1999/06/10 15:02:08 peter
  901. # * last fixes for 0.99.12 release
  902. #
  903. # Revision 1.30 1999/06/03 09:36:31 peter
  904. # * first things for sharedlib to work again
  905. #
  906. # Revision 1.29 1999/06/01 13:27:24 peter
  907. # * updates for linux
  908. #
  909. # Revision 1.28 1999/05/30 11:33:04 peter
  910. # * releasever removed, fpc_version will be used
  911. #
  912. # Revision 1.27 1999/05/16 02:37:30 peter
  913. # + fpc_showinstallfiles to show which files will be added to the system
  914. #
  915. # Revision 1.26 1999/05/14 22:46:21 peter
  916. # * patch for comments in ld.so.conf
  917. #
  918. # Revision 1.25 1999/05/12 16:17:07 peter
  919. # + utils_X targets
  920. # * missing export of prefixinstalldir
  921. #
  922. # Revision 1.24 1999/05/11 00:48:12 peter
  923. # * fixed some typos
  924. #
  925. # Revision 1.23 1999/05/10 15:18:43 peter
  926. # * NEEDOTHERLIB define to load ld.so.conf for linux
  927. #
  928. # Revision 1.22 1999/05/04 23:20:42 pierre
  929. # + FPC_VERSION (with shell $(PP) -iV)
  930. #
  931. # Revision 1.21 1999/05/03 22:38:10 peter
  932. # * typo with -TP which should be -iTP
  933. #
  934. # Revision 1.20 1999/05/03 22:29:04 peter
  935. # * os_source,os_target depends now on the compiler
  936. # * cpu depends on the compiler
  937. # * datestr y2k proof
  938. #
  939. # Revision 1.19 1999/05/03 18:04:58 peter
  940. # + sourceinstalldir
  941. #
  942. # Revision 1.18 1999/04/29 15:52:38 peter
  943. # * better gcclib dir detection
  944. #
  945. # Revision 1.17 1999/04/20 12:33:32 michael
  946. # + Fixed GCCLIB detection. Added fpc_dirinfo target
  947. #
  948. # Revision 1.16 1999/04/20 12:07:49 michael
  949. # Added autodetect of gcc lib for linux
  950. #
  951. # Revision 1.15 1999/04/16 20:12:35 michael
  952. # + install target now correctly takes the BASEINSTALLDIR on linux
  953. #
  954. # Revision 1.14 1999/04/08 10:16:17 peter
  955. # * zipinstall for linux with .tar.gz
  956. #
  957. # Revision 1.13 1999/04/01 22:52:28 peter
  958. # * don't override pasext if set
  959. #
  960. # Revision 1.12 1999/03/29 16:04:58 peter
  961. # * place -T as the first parameter on the commandline so a OPT=-A can
  962. # overwrite it
  963. #
  964. # Revision 1.11 1999/03/16 00:46:55 peter
  965. # * makefile.fpc targets start with fpc_
  966. # * small updates for install scripts
  967. #
  968. # Revision 1.10 1999/03/12 21:01:30 michael
  969. # + Changed clean and libsclean to fpc_target
  970. #
  971. # Revision 1.9 1999/03/11 17:54:00 peter
  972. # * better check for makefile.fpc
  973. # * check if cmp exists
  974. #
  975. # Revision 1.8 1999/03/09 01:35:47 peter
  976. # * makefile.fpc updates and defaultfpcdir var
  977. #
  978. #