makefile.fpc 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  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. fpc_installinfo:
  826. @$(ECHO)
  827. @$(ECHO) == Install info ==
  828. @$(ECHO)
  829. @$(ECHO) DateStr.............. $(DATESTR)
  830. @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX)
  831. @$(ECHO)
  832. @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR)
  833. @$(ECHO) BinInstallDir........ $(BININSTALLDIR)
  834. @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR)
  835. @$(ECHO) StaticUnitInstallDir. $(STATIC_UNITINSTALLDIR)
  836. @$(ECHO) SharedUnitInstallDir. $(SHARED_UNITINSTALLDIR)
  837. @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR)
  838. @$(ECHO) StaticLibInstallDir.. $(STATIC_LIBINSTALLDIR)
  839. @$(ECHO) SharedLibInstallDir.. $(SHARED_LIBINSTALLDIR)
  840. @$(ECHO) MsgInstallDir........ $(MSGINSTALLDIR)
  841. @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR)
  842. @$(ECHO)
  843. # try to get the files in the currentdir
  844. PASFILES:=$(wildcard *.pas)
  845. PPFILES:=$(wildcard *.pp)
  846. INCFILES:=$(wildcard *.inc)
  847. MSGFILES:=$(wildcard *.msg)
  848. ASFILES:=$(wildcard *.as)
  849. fpc_filesinfo:
  850. @$(ECHO)
  851. @$(ECHO) == Files info ==
  852. @$(ECHO)
  853. ifdef PASFILES
  854. @$(ECHO) Pas files are $(PASFILES)
  855. endif
  856. ifdef PPFILES
  857. @$(ECHO) PP files are $(PPFILES)
  858. endif
  859. ifdef INCFILES
  860. @$(ECHO) Inc files are $(INCFILES)
  861. endif
  862. ifdef MSGFILES
  863. @$(ECHO) Msg files are $(MSGFILES)
  864. endif
  865. ifdef ASFILES
  866. @$(ECHO) As files are $(ASFILES)
  867. endif
  868. #
  869. # $Log$
  870. # Revision 1.36 1999-07-01 18:20:01 jonas
  871. # * changed RELEASE=1 processor option from -Op2 to -Op3
  872. #
  873. # Revision 1.35 1999/06/18 11:03:08 peter
  874. # * merged
  875. #
  876. # Revision 1.34 1999/06/18 10:11:18 peter
  877. # * merged
  878. #
  879. # Revision 1.33 1999/06/13 22:43:23 peter
  880. # * merged from fixes
  881. #
  882. # Revision 1.32 1999/06/11 13:31:14 hajny
  883. # * fixes for OS/2
  884. #
  885. # Revision 1.31.2.3 1999/06/18 10:55:31 peter
  886. # * version fixes
  887. # * EXTRAUNITS to set extra units that are build and needs to be cleaned
  888. #
  889. # Revision 1.31.2.2 1999/06/18 10:07:27 peter
  890. # * rtl/linux and units/linux also for linux installs
  891. #
  892. # Revision 1.31.2.1 1999/06/13 22:36:38 peter
  893. # * install msg files in msg/ instead of bin for not linux
  894. #
  895. # Revision 1.31 1999/06/10 15:02:08 peter
  896. # * last fixes for 0.99.12 release
  897. #
  898. # Revision 1.30 1999/06/03 09:36:31 peter
  899. # * first things for sharedlib to work again
  900. #
  901. # Revision 1.29 1999/06/01 13:27:24 peter
  902. # * updates for linux
  903. #
  904. # Revision 1.28 1999/05/30 11:33:04 peter
  905. # * releasever removed, fpc_version will be used
  906. #
  907. # Revision 1.27 1999/05/16 02:37:30 peter
  908. # + fpc_showinstallfiles to show which files will be added to the system
  909. #
  910. # Revision 1.26 1999/05/14 22:46:21 peter
  911. # * patch for comments in ld.so.conf
  912. #
  913. # Revision 1.25 1999/05/12 16:17:07 peter
  914. # + utils_X targets
  915. # * missing export of prefixinstalldir
  916. #
  917. # Revision 1.24 1999/05/11 00:48:12 peter
  918. # * fixed some typos
  919. #
  920. # Revision 1.23 1999/05/10 15:18:43 peter
  921. # * NEEDOTHERLIB define to load ld.so.conf for linux
  922. #
  923. # Revision 1.22 1999/05/04 23:20:42 pierre
  924. # + FPC_VERSION (with shell $(PP) -iV)
  925. #
  926. # Revision 1.21 1999/05/03 22:38:10 peter
  927. # * typo with -TP which should be -iTP
  928. #
  929. # Revision 1.20 1999/05/03 22:29:04 peter
  930. # * os_source,os_target depends now on the compiler
  931. # * cpu depends on the compiler
  932. # * datestr y2k proof
  933. #
  934. # Revision 1.19 1999/05/03 18:04:58 peter
  935. # + sourceinstalldir
  936. #
  937. # Revision 1.18 1999/04/29 15:52:38 peter
  938. # * better gcclib dir detection
  939. #
  940. # Revision 1.17 1999/04/20 12:33:32 michael
  941. # + Fixed GCCLIB detection. Added fpc_dirinfo target
  942. #
  943. # Revision 1.16 1999/04/20 12:07:49 michael
  944. # Added autodetect of gcc lib for linux
  945. #
  946. # Revision 1.15 1999/04/16 20:12:35 michael
  947. # + install target now correctly takes the BASEINSTALLDIR on linux
  948. #
  949. # Revision 1.14 1999/04/08 10:16:17 peter
  950. # * zipinstall for linux with .tar.gz
  951. #
  952. # Revision 1.13 1999/04/01 22:52:28 peter
  953. # * don't override pasext if set
  954. #
  955. # Revision 1.12 1999/03/29 16:04:58 peter
  956. # * place -T as the first parameter on the commandline so a OPT=-A can
  957. # overwrite it
  958. #
  959. # Revision 1.11 1999/03/16 00:46:55 peter
  960. # * makefile.fpc targets start with fpc_
  961. # * small updates for install scripts
  962. #
  963. # Revision 1.10 1999/03/12 21:01:30 michael
  964. # + Changed clean and libsclean to fpc_target
  965. #
  966. # Revision 1.9 1999/03/11 17:54:00 peter
  967. # * better check for makefile.fpc
  968. # * check if cmp exists
  969. #
  970. # Revision 1.8 1999/03/09 01:35:47 peter
  971. # * makefile.fpc updates and defaultfpcdir var
  972. #
  973. #