makefile.fpc 22 KB

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