makefile.fpc 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  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. export 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. We can't use $UPX becuase
  238. # upx uses that one itself (PFV)
  239. ifndef UPXPROG
  240. ifeq ($(OS_TARGET),go32v2)
  241. UPXPROG=1
  242. endif
  243. ifeq ($(OS_TARGET),win32)
  244. UPXPROG=1
  245. endif
  246. ifdef UPXPROG
  247. UPXPROG=$(strip $(wildcard $(addsuffix /upx$(EXEEXT),$(SEARCHPATH))))
  248. ifeq ($(UPX),)
  249. UPXPROG=
  250. else
  251. export UPXPROG:=$(firstword $(UPX))
  252. endif
  253. else
  254. UPXPROG=
  255. endif
  256. endif
  257. # ZipProg, you can't use Zip as the var name (PFV)
  258. ifndef ZIPPROG
  259. ZIPPROG=$(strip $(wildcard $(addsuffix /zip$(EXEEXT),$(SEARCHPATH))))
  260. ifeq ($(ZIPPROG),)
  261. ZIPPROG=
  262. else
  263. export ZIPPROG:=$(firstword $(ZIPPROG)) -D9 -r
  264. endif
  265. endif
  266. ifndef ZIPEXT
  267. ZIPEXT=.zip
  268. endif
  269. #####################################################################
  270. # Default Directories
  271. #####################################################################
  272. # Base dir
  273. ifdef PWD
  274. BASEDIR:=$(shell $(PWD))
  275. else
  276. BASEDIR=.
  277. endif
  278. # set the directory to the rtl base
  279. ifndef RTLDIR
  280. ifdef RTL
  281. RTLDIR:=$(RTL)/$(OS_TARGET)
  282. else
  283. RTLDIR:=$(FPCDIR)/rtl/$(OS_TARGET)
  284. endif
  285. endif
  286. # specify where units are.
  287. ifndef UNITDIR
  288. ifdef UNITS
  289. UNITDIR=$(UNITS)/$(OS_TARGET)
  290. else
  291. UNITDIR=$(FPCDIR)/units/$(OS_TARGET)
  292. endif
  293. endif
  294. ifeq ($(strip $(wildcard $(UNITDIR)/*)),)
  295. UNITDIR=
  296. endif
  297. # set the prefix directory where to install everything
  298. ifndef PREFIXINSTALLDIR
  299. ifdef inlinux
  300. PREFIXINSTALLDIR=/usr
  301. else
  302. PREFIXINSTALLDIR=/pp
  303. endif
  304. endif
  305. # set the base directory where to install everything
  306. ifndef BASEINSTALLDIR
  307. ifdef inlinux
  308. BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION)
  309. else
  310. BASEINSTALLDIR=$(PREFIXINSTALLDIR)
  311. endif
  312. endif
  313. # On linux, try to find where libgcc.a is.
  314. ifdef inlinux
  315. ifndef GCCLIBDIR
  316. GCCLIBDIR:=$(shell dirname `(gcc -v 2>&1)| head -n 1| awk '{ print $$4 } '`)
  317. endif
  318. ifndef OTHERLIBDIR
  319. OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
  320. endif
  321. endif
  322. #####################################################################
  323. # Install Directories based on BASEINSTALLDIR
  324. #####################################################################
  325. # Linux binary really goes to baseinstalldir
  326. ifndef LIBINSTALLDIR
  327. ifdef inlinux
  328. LIBINSTALLDIR=$(BASEINSTALLDIR)
  329. else
  330. LIBINSTALLDIR=$(BASEINSTALLDIR)/lib
  331. endif
  332. endif
  333. # set the directory where to install the binaries
  334. ifndef BININSTALLDIR
  335. ifdef inlinux
  336. BININSTALLDIR=$(PREFIXINSTALLDIR)/bin
  337. else
  338. BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET)
  339. endif
  340. endif
  341. # Where the .msg files will be stored
  342. ifndef MSGINSTALLDIR
  343. MSGINSTALLDIR=$(BASEINSTALLDIR)/msg
  344. endif
  345. # Where the .msg files will be stored
  346. ifndef SOURCEINSTALLDIR
  347. SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source
  348. endif
  349. # Where the doc files will be stored
  350. ifndef DOCINSTALLDIR
  351. ifdef inlinux
  352. DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc/$(FPC_VERSION)
  353. else
  354. DOCINSTALLDIR=$(BASEINSTALLDIR)/doc
  355. endif
  356. endif
  357. ########################
  358. # Unit Directories
  359. ########################
  360. # this can be set to 'rtl' when the RTL units are installed
  361. ifndef UNITPREFIX
  362. UNITPREFIX=units
  363. endif
  364. # set the directory where to install the units.
  365. ifndef UNITINSTALLDIR
  366. UNITINSTALLDIR=$(BASEINSTALLDIR)/$(UNITPREFIX)/$(OS_TARGET)
  367. endif
  368. # set the directory where to install the units.
  369. ifndef STATIC_UNITINSTALLDIR
  370. STATIC_UNITINSTALLDIR=$(UNITINSTALLDIR)/static
  371. endif
  372. # set the directory where to install the units.
  373. ifndef SHARED_UNITINSTALLDIR
  374. SHARED_UNITINSTALLDIR=$(UNITINSTALLDIR)/shared
  375. endif
  376. # set the directory where to install the libs (must exist)
  377. ifndef STATIC_LIBINSTALLDIR
  378. STATIC_LIBINSTALLDIR=$(STATIC_UNITINSTALLDIR)
  379. endif
  380. # set the directory where to install the libs (must exist)
  381. ifndef SHARED_LIBINSTALLDIR
  382. ifdef inlinux
  383. SHARED_LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib
  384. else
  385. SHARED_LIBINSTALLDIR=$(SHARED_UNITINSTALLDIR)
  386. endif
  387. endif
  388. #####################################################################
  389. # Compiler Command Line
  390. #####################################################################
  391. # Load commandline OPTDEF and add CPU define
  392. override PPOPTDEF:=$(OPTDEF) -d$(CPU)
  393. # Load commandline OPT and add target and unit dir to be sure
  394. override PPOPT:=-T$(OS_TARGET) $(NEEDOPT) $(OPT)
  395. # RTL first and then Unit dir (a unit can override RTLunit)
  396. ifdef RTLDIR
  397. override PPOPT+=$(addprefix -Fu,$(RTLDIR))
  398. endif
  399. ifdef UNITDIR
  400. override PPOPT+=$(addprefix -Fu,$(UNITDIR))
  401. endif
  402. ifdef NEEDUNITDIR
  403. override PPOPT+=$(addprefix -Fu,$(NEEDUNITDIR))
  404. endif
  405. # Library dirs
  406. ifdef LIBDIR
  407. override PPOPT+=$(addprefix -Fl,$(LIBDIR))
  408. endif
  409. ifdef NEEDLIBDIR
  410. override PPOPT+=$(addprefix -Fl,$(NEEDLIBDIR))
  411. endif
  412. # Add GCC lib path if asked
  413. ifdef NEEDGCCLIB
  414. ifdef GCCLIBDIR
  415. override PPOPT+=-Fl$(GCCLIBDIR)
  416. endif
  417. endif
  418. # Add Other dirs path if asked
  419. ifdef NEEDOTHERLIB
  420. ifdef OTHERLIBDIR
  421. override PPOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
  422. endif
  423. endif
  424. # Object dirs
  425. ifdef OBJDIR
  426. override PPOPT+=$(addprefix -Fo,$(OBJDIR))
  427. endif
  428. ifdef NEEDOBJDIR
  429. override PPOPT+=$(addprefix -Fo,$(NEEDOBJDIR))
  430. endif
  431. # Add include dirs INC and PROCINC and OSINC
  432. ifdef INC
  433. override PPOPT+=$(addprefix -Fi,$(INC))
  434. endif
  435. ifdef PROCINC
  436. override PPOPT+=$(addprefix -Fi,$(PROCINC))
  437. endif
  438. ifdef OSINC
  439. override PPOPT+=$(addprefix -Fi,$(OSINC))
  440. endif
  441. # Target dirs
  442. ifdef TARGETDIR
  443. override PPOPT+=-FE$(TARGETDIR)
  444. endif
  445. ifdef UNITTARGETDIR
  446. override PPOPT+=-FU$(UNITTARGETDIR)
  447. endif
  448. # Smartlinking
  449. ifeq ($(SMARTLINK),YES)
  450. override PPOPT+=-Cx
  451. endif
  452. # Add defines from PPOPTDEF to PPOPT
  453. override PPOPT:=$(PPOPT) $(PPOPTDEF)
  454. # Was a config file specified ?
  455. ifdef CFGFILE
  456. override PPOPT:=$(PPOPT) @$(CFGFILE)
  457. endif
  458. override COMPILER=$(PP) $(PPOPT)
  459. #####################################################################
  460. # Default extensions
  461. #####################################################################
  462. # Default needed extensions (Go32v2,Linux)
  463. LOADEREXT=.as
  464. PPLEXT=.ppl
  465. PPUEXT=.ppu
  466. OEXT=.o
  467. ASMEXT=.s
  468. SMARTEXT=.sl
  469. STATICLIBEXT=.a
  470. SHAREDLIBEXT=.so
  471. PACKAGESUFFIX=
  472. # Go32v1
  473. ifeq ($(OS_TARGET),go32v1)
  474. PPUEXT=.pp1
  475. OEXT=.o1
  476. ASMEXT=.s1
  477. SMARTEXT=.sl1
  478. STATICLIBEXT=.a1
  479. SHAREDLIBEXT=.so1
  480. PACKAGESUFFIX=v1
  481. endif
  482. # Go32v2
  483. ifeq ($(OS_TARGET),go32v2)
  484. PACKAGESUFFIX=go32
  485. endif
  486. # Linux
  487. ifeq ($(OS_TARGET),linux)
  488. PACKAGESUFFIX=linux
  489. endif
  490. # Win32
  491. ifeq ($(OS_TARGET),win32)
  492. PPUEXT=.ppw
  493. OEXT=.ow
  494. ASMEXT=.sw
  495. SMARTEXT=.slw
  496. STATICLIBEXT=.aw
  497. SHAREDLIBEXT=.dll
  498. PACKAGESUFFIX=win32
  499. endif
  500. # OS/2
  501. ifeq ($(OS_TARGET),os2)
  502. PPUEXT=.ppo
  503. ASMEXT=.so2
  504. OEXT=.oo2
  505. SMARTEXT=.so
  506. STATICLIBEXT=.ao2
  507. SHAREDLIBEXT=.dll
  508. PACKAGESUFFIX=os2
  509. endif
  510. # library prefix
  511. LIBPREFIX=lib
  512. ifeq ($(OS_TARGET),go32v2)
  513. LIBPREFIX=
  514. endif
  515. ifeq ($(OS_TARGET),go32v1)
  516. LIBPREFIX=
  517. endif
  518. # determine which .pas extension is used
  519. ifndef PASEXT
  520. ifdef EXEOBJECTS
  521. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS)))))
  522. else
  523. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS)))))
  524. endif
  525. ifeq ($(TESTPAS),)
  526. PASEXT=.pp
  527. else
  528. PASEXT=.pas
  529. endif
  530. endif
  531. # also call ppas if with command option -s
  532. ifeq (,$(findstring -s ,$(COMPILER)))
  533. EXECPPAS=
  534. else
  535. EXECPPAS=@$(PPAS)
  536. endif
  537. ifdef DATE
  538. DATESTR=$(shell $(DATE) +%Y%m%d)
  539. else
  540. DATESTR=
  541. endif
  542. #####################################################################
  543. # Export commandline values, so nesting use the same values
  544. #####################################################################
  545. # Makefile
  546. export FPCDIR FPCMAKE
  547. # Compiler info
  548. export FPC_VERSION OS_SOURCE OS_TARGET CPU
  549. export OPT OPTDEF PP RELEASE VERBOSE SMARTLINK
  550. # Installation
  551. export PREFIXINSTALLDIR PACKAGESUFFIX
  552. # Directories
  553. export GCCLIBDIR OTHERLIBDIR
  554. #####################################################################
  555. # General compile rules
  556. #####################################################################
  557. # Create Filenames
  558. LOADEROFILES=$(addsuffix $(OEXT),$(LOADEROBJECTS))
  559. EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS))
  560. EXEOFILES=$(addsuffix $(OEXT),$(EXEOBJECTS))
  561. UNITPPUFILES=$(addsuffix $(PPUEXT),$(UNITOBJECTS))
  562. UNITOFILES=$(addsuffix $(OEXT),$(UNITOBJECTS))
  563. UNITAFILES=$(addsuffix $(STATICLIBEXT),$(UNITOBJECTS))
  564. .PHONY : fpc_all fpc_units fpc_loaders fpc_exes \
  565. fpc_staticlib fpc_sharedlib \
  566. fpc_clean fpc_libsclean fpc_cleanall \
  567. fpc_install fpc_staticinstall fpc_sharedinstall fpc_libinstall \
  568. fpc_info fpc_cfginfo fpc_objectinfo fpc_installinfo fpc_filesinfo\
  569. fpc_dirinfo
  570. .SUFFIXES : $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp
  571. #####################################################################
  572. # Default
  573. #####################################################################
  574. ifdef DEFAULTUNITS
  575. fpc_all: fpc_loaders fpc_units
  576. else
  577. fpc_all: fpc_loaders fpc_units fpc_exes
  578. endif
  579. fpc_loaders: $(LOADEROFILES)
  580. fpc_units: $(UNITPPUFILES)
  581. fpc_exes: $(EXEFILES)
  582. # General compile rules, available for both possible PASEXT
  583. %$(PPUEXT): %.pp
  584. $(COMPILER) $< $(REDIR)
  585. $(EXECPASS)
  586. %$(PPUEXT): %.pas
  587. $(COMPILER) $< $(REDIR)
  588. $(EXECPASS)
  589. %$(EXEEXT): %.pp
  590. $(COMPILER) $< $(REDIR)
  591. $(EXECPASS)
  592. %$(EXEEXT): %.pas
  593. $(COMPILER) $< $(REDIR)
  594. $(EXECPASS)
  595. %$(OEXT): %$(LOADEREXT)
  596. $(AS) -o $*$(OEXT) $<
  597. #####################################################################
  598. # Library
  599. #####################################################################
  600. # Default sharedlib units are all unit objects
  601. ifndef SHAREDLIBUNITOBJECTS
  602. SHAREDLIBUNITOBJECTS=$(UNITOBJECTS)
  603. endif
  604. fpc_staticlib:
  605. $(MAKE) libsclean
  606. $(MAKE) all SMARTLINK=YES
  607. fpc_sharedlib: all
  608. ifdef inlinux
  609. ifndef LIBNAME
  610. @$(ECHO) LIBNAME not set
  611. else
  612. $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBNAME)
  613. endif
  614. else
  615. @$(ECHO) Shared Libraries not supported
  616. endif
  617. #####################################################################
  618. # Install rules
  619. #####################################################################
  620. fpc_showinstallfiles : all
  621. ifndef DEFAULTUNITS
  622. ifdef EXEOBJECTS
  623. @$(ECHO) $(addprefix "\n"$(BININSTALLDIR)/,$(EXEFILES))
  624. endif
  625. endif
  626. ifdef LOADEROBJECTS
  627. @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(LOADEROFILES))
  628. endif
  629. ifdef UNITOBJECTS
  630. @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(wildcard $(UNITPPUFILES) $(UNITOFILES) $(UNITAFILES)))
  631. endif
  632. ifdef EXTRAINSTALLUNITS
  633. @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(wildcard $(addsuffix $(OEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))))
  634. endif
  635. fpc_install : all
  636. $(MAKE) fpc_install2
  637. fpc_install2 :
  638. # Create UnitInstallFiles
  639. ifdef EXTRAINSTALLUNITS
  640. override EXTRAINSTALLFILES=$(wildcard $(addsuffix $(OEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS)))
  641. endif
  642. ifndef DEFAULTUNITS
  643. ifdef EXEOBJECTS
  644. $(MKDIR) $(BININSTALLDIR)
  645. # Compress the exes if upx is defined
  646. ifdef UPXPROG
  647. -$(UPXPROG) $(EXEFILES)
  648. endif
  649. $(INSTALLEXE) $(EXEFILES) $(BININSTALLDIR)
  650. endif
  651. endif
  652. ifdef LOADEROBJECTS
  653. $(MKDIR) $(UNITINSTALLDIR)
  654. $(INSTALL) $(LOADEROFILES) $(UNITINSTALLDIR)
  655. endif
  656. ifdef UNITOBJECTS
  657. $(MKDIR) $(UNITINSTALLDIR)
  658. $(INSTALL) $(wildcard $(UNITPPUFILES) $(UNITOFILES) $(UNITAFILES)) $(UNITINSTALLDIR)
  659. endif
  660. ifneq ($(wildcard $(addsuffix $(OEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))),)
  661. $(MKDIR) $(UNITINSTALLDIR)
  662. $(INSTALL) $(wildcard $(addsuffix $(OEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))) $(UNITINSTALLDIR)
  663. endif
  664. # Target for the sharedlib install which is not avail for all targets
  665. ifdef inlinux
  666. SHAREDINSTALL=sharedinstall
  667. else
  668. SHAREDINSTALL=
  669. endif
  670. fpc_staticinstall: staticlib
  671. $(MKDIR) $(STATIC_UNITINSTALLDIR)
  672. $(INSTALL) $(UNITINSTALLFILES) $(STATIC_UNITINSTALLDIR)
  673. $(MKDIR) $(STATIC_LIBINSTALLDIR)
  674. $(INSTALLEXE) *$(STATICLIBEXT) $(STATIC_LIBINSTALLDIR)
  675. fpc_sharedinstall: sharedlib
  676. $(MKDIR) $(SHARED_UNITINSTALLDIR)
  677. ifdef UNITINSTALLFILES
  678. $(INSTALL) $(UNITINSTALLFILES) $(SHARED_UNITINSTALLDIR)
  679. else
  680. $(INSTALL) $(UNITOFILES) $(SHARED_UNITINSTALLDIR)
  681. endif
  682. $(MKDIR) $(SHARED_LIBINSTALLDIR)
  683. $(INSTALLEXE) *$(SHAREDLIBEXT) $(SHARED_LIBINSTALLDIR)
  684. fpc_libinstall: staticinstall $(SHAREDINSTALL)
  685. #####################################################################
  686. # Zip
  687. #####################################################################
  688. # Temporary path to pack a file
  689. ifndef PACKDIR
  690. ifndef inlinux
  691. PACKDIR=pack_tmp
  692. else
  693. PACKDIR=/tmp/fpc-pack
  694. endif
  695. endif
  696. # Test dir if none specified
  697. ifndef PACKAGEDIR
  698. PACKAGEDIR=$(BASEDIR)
  699. endif
  700. # Add .zip/.tar.gz extension
  701. ifdef ZIPNAME
  702. ifndef inlinux
  703. override ZIPNAME:=$(ZIPNAME)$(ZIPEXT)
  704. endif
  705. endif
  706. # Default target which is call before zipping
  707. ifndef ZIPTARGET
  708. ZIPTARGET=install
  709. endif
  710. # Note: This will not remove the zipfile first
  711. fpc_zipinstalladd:
  712. ifndef ZIPNAME
  713. @$(ECHO) Please specify ZIPNAME!
  714. @exit
  715. else
  716. $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
  717. ifdef inlinux
  718. gzip -d $(PACKAGEDIR)/$(ZIPNAME).tar.gz
  719. cd $(PACKDIR) ; tar rv --file $(PACKAGEDIR)/$(ZIPNAME).tar * ; cd $(BASEDIR)
  720. gzip $(PACKAGEDIR)/$(ZIPNAME).tar
  721. else
  722. cd $(PACKDIR) ; $(ZIPPROG) $(PACKAGEDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
  723. endif
  724. $(DELTREE) $(PACKDIR)
  725. endif
  726. # First remove the zip and then install
  727. fpc_zipinstall:
  728. ifndef ZIPNAME
  729. @$(ECHO) Please specify ZIPNAME!
  730. @exit
  731. else
  732. $(DEL) $(PACKAGEDIR)/$(ZIPNAME)
  733. $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
  734. ifdef inlinux
  735. cd $(PACKDIR) ; tar cvz --file $(PACKAGEDIR)/$(ZIPNAME).tar.gz * ; cd $(BASEDIR)
  736. else
  737. cd $(PACKDIR) ; $(ZIPPROG) $(PACKAGEDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
  738. endif
  739. $(DELTREE) $(PACKDIR)
  740. endif
  741. #####################################################################
  742. # Clean rules
  743. #####################################################################
  744. fpc_clean:
  745. make fpc_clean2
  746. fpc_clean2:
  747. ifdef EXEOBJECTS
  748. -$(DEL) $(EXEFILES) $(EXEOFILES)
  749. endif
  750. ifdef LOADEROBJECTS
  751. -$(DEL) $(LOADEROFILES)
  752. endif
  753. ifdef UNITOBJECTS
  754. -$(DEL) $(wildcard $(UNITPPUFILES) $(UNITOFILES) $(UNITAFILES))
  755. endif
  756. ifneq ($(wildcard $(addsuffix $(OEXT),$(EXTRACLEANUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRACLEANUNITS)) $(addsuffix $(PPUEXT),$(EXTRACLEANUNITS))) ,)
  757. -$(DEL) $(wildcard $(addsuffix $(OEXT),$(EXTRACLEANUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRACLEANUNITS)) $(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)))
  758. endif
  759. -$(DEL) $(PPAS) link.res log
  760. fpc_libsclean: clean
  761. -$(DEL) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  762. fpc_cleanall:
  763. ifdef EXEOBJECTS
  764. -$(DEL) $(EXEFILES)
  765. endif
  766. -$(DEL) *$(OEXT) *$(PPUEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  767. -$(DELTREE) *$(SMARTEXT)
  768. #####################################################################
  769. # Depend rules
  770. #####################################################################
  771. fpc_depend:
  772. makedep $(UNITOBJECTS)
  773. #####################################################################
  774. # Info rules
  775. #####################################################################
  776. fpc_info: fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo\
  777. fpc_dirinfo
  778. fpc_cfginfo:
  779. @$(ECHO)
  780. @$(ECHO) == Configuration info ==
  781. @$(ECHO)
  782. @$(ECHO) FPCDir.... $(FPCDIR)
  783. @$(ECHO) FPCMake... $(FPCMAKE)
  784. @$(ECHO)
  785. @$(ECHO) Version... $(FPC_VERSION)
  786. @$(ECHO) CPU....... $(CPU)
  787. @$(ECHO) Source.... $(OS_SOURCE)
  788. @$(ECHO) Target.... $(OS_TARGET)
  789. @$(ECHO)
  790. fpc_dirinfo:
  791. ifdef inlinux
  792. @$(ECHO)
  793. @$(ECHO) == Directory info ==
  794. @$(ECHO)
  795. ifdef NEEDGCCLIB
  796. @$(ECHO) GCC library is needed.
  797. endif
  798. ifdef NEEDOTHERLIB
  799. @$(ECHO) Other library is needed.
  800. endif
  801. @$(ECHO) Basedir......... $(BASEDIR)
  802. @$(ECHO)
  803. @$(ECHO) GCC library..... $(GCCLIBDIR)
  804. @$(ECHO) Other library... $(OTHERLIBDIR)
  805. @$(ECHO)
  806. endif
  807. fpc_toolsinfo:
  808. @$(ECHO)
  809. @$(ECHO) == Tools info ==
  810. @$(ECHO)
  811. @$(ECHO) Pwd....... $(PWD)
  812. @$(ECHO) Echo...... $(ECHO)
  813. ifdef SED
  814. @$(ECHO) Sed....... $(SED)
  815. endif
  816. ifdef DATE
  817. @$(ECHO) Date...... $(DATE)
  818. endif
  819. ifdef DIFF
  820. @$(ECHO) Diff...... $(DIFF)
  821. endif
  822. ifdef CMP
  823. @$(ECHO) Cmp....... $(CMP)
  824. endif
  825. ifdef UPXPROG
  826. @$(ECHO) Upx....... $(UPXPROG)
  827. endif
  828. ifdef ZIPPROG
  829. @$(ECHO) Zip....... $(ZIPPROG)
  830. endif
  831. @$(ECHO)
  832. fpc_objectinfo:
  833. @$(ECHO)
  834. @$(ECHO) == Object info ==
  835. @$(ECHO)
  836. @$(ECHO) LoaderObjects..... $(LOADEROBJECTS)
  837. @$(ECHO) UnitObjects....... $(UNITOBJECTS)
  838. @$(ECHO) ExeObjects........ $(EXEOBJECTS)
  839. @$(ECHO)
  840. @$(ECHO) ExtraCleanUnits... $(EXTRACLEANUNITS)
  841. @$(ECHO) ExtraInstallUnits. $(EXTRAINSTALLUNITS)
  842. @$(ECHO) ExtraInstallUnits. $(EXTRAINSTALLFILES)
  843. @$(ECHO)
  844. @$(ECHO) == Unit info ==
  845. @$(ECHO)
  846. @$(ECHO) UnitInstallFiles. $(UNITINSTALLFILES)
  847. @$(ECHO) UnitCleanFiles... $(UNITCLEANFILES)
  848. @$(ECHO)
  849. fpc_installinfo:
  850. @$(ECHO)
  851. @$(ECHO) == Install info ==
  852. @$(ECHO)
  853. @$(ECHO) DateStr.............. $(DATESTR)
  854. @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX)
  855. @$(ECHO)
  856. @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR)
  857. @$(ECHO) BinInstallDir........ $(BININSTALLDIR)
  858. @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR)
  859. @$(ECHO) StaticUnitInstallDir. $(STATIC_UNITINSTALLDIR)
  860. @$(ECHO) SharedUnitInstallDir. $(SHARED_UNITINSTALLDIR)
  861. @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR)
  862. @$(ECHO) StaticLibInstallDir.. $(STATIC_LIBINSTALLDIR)
  863. @$(ECHO) SharedLibInstallDir.. $(SHARED_LIBINSTALLDIR)
  864. @$(ECHO) MsgInstallDir........ $(MSGINSTALLDIR)
  865. @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR)
  866. @$(ECHO)
  867. # try to get the files in the currentdir
  868. PASFILES:=$(wildcard *.pas)
  869. PPFILES:=$(wildcard *.pp)
  870. INCFILES:=$(wildcard *.inc)
  871. MSGFILES:=$(wildcard *.msg)
  872. ASFILES:=$(wildcard *.as)
  873. fpc_filesinfo:
  874. @$(ECHO)
  875. @$(ECHO) == Files info ==
  876. @$(ECHO)
  877. ifdef PASFILES
  878. @$(ECHO) Pas files are $(PASFILES)
  879. endif
  880. ifdef PPFILES
  881. @$(ECHO) PP files are $(PPFILES)
  882. endif
  883. ifdef INCFILES
  884. @$(ECHO) Inc files are $(INCFILES)
  885. endif
  886. ifdef MSGFILES
  887. @$(ECHO) Msg files are $(MSGFILES)
  888. endif
  889. ifdef ASFILES
  890. @$(ECHO) As files are $(ASFILES)
  891. endif
  892. #
  893. # $Log$
  894. # Revision 1.46 1999-08-30 12:07:43 pierre
  895. # * use unitdir only if existing and non empty
  896. #
  897. # Revision 1.45 1999/08/19 06:50:25 michael
  898. # + Changes from Sebastian Gunther
  899. #
  900. # Revision 1.44 1999/08/13 15:35:37 peter
  901. # * UPX -> UPXPROG, because upx 0.80+ use the environment itself
  902. #
  903. # Revision 1.43 1999/08/09 22:19:46 peter
  904. # * classes vmt changed to only positive addresses
  905. # * sharedlib creation is working
  906. #
  907. # Revision 1.42 1999/07/22 16:13:32 peter
  908. # * install,clean fixes
  909. #
  910. # Revision 1.41 1999/07/21 14:21:00 peter
  911. # * install works again
  912. #
  913. # Revision 1.40 1999/07/17 14:22:54 peter
  914. # * ECHO is now again without @
  915. #
  916. # Revision 1.39 1999/07/17 11:30:23 peter
  917. # * merged
  918. #
  919. # Revision 1.38 1999/07/16 13:45:24 peter
  920. # * 0.99.12b updates
  921. # * merges
  922. #
  923. # Revision 1.37 1999/07/05 21:37:35 peter
  924. # * display extraunits in info
  925. #
  926. # Revision 1.36 1999/07/01 18:20:01 jonas
  927. # * changed RELEASE=1 processor option from -Op2 to -Op3
  928. #
  929. # Revision 1.35 1999/06/18 11:03:08 peter
  930. # * merged
  931. #
  932. # Revision 1.34 1999/06/18 10:11:18 peter
  933. # * merged
  934. #
  935. # Revision 1.33 1999/06/13 22:43:23 peter
  936. # * merged from fixes
  937. #
  938. # Revision 1.32 1999/06/11 13:31:14 hajny
  939. # * fixes for OS/2
  940. #
  941. # Revision 1.31.2.5 1999/07/17 11:29:02 peter
  942. # * more extrainstallunits,extracleanunits updates
  943. #
  944. # Revision 1.31.2.4 1999/07/16 13:40:56 peter
  945. # + extrainstallunits,extracleanunits
  946. #
  947. # Revision 1.31.2.3 1999/06/18 10:55:31 peter
  948. # * version fixes
  949. # * EXTRAUNITS to set extra units that are build and needs to be cleaned
  950. #
  951. # Revision 1.31.2.2 1999/06/18 10:07:27 peter
  952. # * rtl/linux and units/linux also for linux installs
  953. #
  954. # Revision 1.31.2.1 1999/06/13 22:36:38 peter
  955. # * install msg files in msg/ instead of bin for not linux
  956. #
  957. # Revision 1.31 1999/06/10 15:02:08 peter
  958. # * last fixes for 0.99.12 release
  959. #
  960. # Revision 1.30 1999/06/03 09:36:31 peter
  961. # * first things for sharedlib to work again
  962. #
  963. # Revision 1.29 1999/06/01 13:27:24 peter
  964. # * updates for linux
  965. #
  966. # Revision 1.28 1999/05/30 11:33:04 peter
  967. # * releasever removed, fpc_version will be used
  968. #
  969. # Revision 1.27 1999/05/16 02:37:30 peter
  970. # + fpc_showinstallfiles to show which files will be added to the system
  971. #
  972. # Revision 1.26 1999/05/14 22:46:21 peter
  973. # * patch for comments in ld.so.conf
  974. #
  975. # Revision 1.25 1999/05/12 16:17:07 peter
  976. # + utils_X targets
  977. # * missing export of prefixinstalldir
  978. #
  979. # Revision 1.24 1999/05/11 00:48:12 peter
  980. # * fixed some typos
  981. #
  982. # Revision 1.23 1999/05/10 15:18:43 peter
  983. # * NEEDOTHERLIB define to load ld.so.conf for linux
  984. #
  985. # Revision 1.22 1999/05/04 23:20:42 pierre
  986. # + FPC_VERSION (with shell $(PP) -iV)
  987. #
  988. # Revision 1.21 1999/05/03 22:38:10 peter
  989. # * typo with -TP which should be -iTP
  990. #
  991. # Revision 1.20 1999/05/03 22:29:04 peter
  992. # * os_source,os_target depends now on the compiler
  993. # * cpu depends on the compiler
  994. # * datestr y2k proof
  995. #
  996. # Revision 1.19 1999/05/03 18:04:58 peter
  997. # + sourceinstalldir
  998. #
  999. # Revision 1.18 1999/04/29 15:52:38 peter
  1000. # * better gcclib dir detection
  1001. #
  1002. # Revision 1.17 1999/04/20 12:33:32 michael
  1003. # + Fixed GCCLIB detection. Added fpc_dirinfo target
  1004. #
  1005. # Revision 1.16 1999/04/20 12:07:49 michael
  1006. # Added autodetect of gcc lib for linux
  1007. #
  1008. # Revision 1.15 1999/04/16 20:12:35 michael
  1009. # + install target now correctly takes the BASEINSTALLDIR on linux
  1010. #
  1011. # Revision 1.14 1999/04/08 10:16:17 peter
  1012. # * zipinstall for linux with .tar.gz
  1013. #
  1014. # Revision 1.13 1999/04/01 22:52:28 peter
  1015. # * don't override pasext if set
  1016. #
  1017. # Revision 1.12 1999/03/29 16:04:58 peter
  1018. # * place -T as the first parameter on the commandline so a OPT=-A can
  1019. # overwrite it
  1020. #
  1021. # Revision 1.11 1999/03/16 00:46:55 peter
  1022. # * makefile.fpc targets start with fpc_
  1023. # * small updates for install scripts
  1024. #
  1025. # Revision 1.10 1999/03/12 21:01:30 michael
  1026. # + Changed clean and libsclean to fpc_target
  1027. #
  1028. # Revision 1.9 1999/03/11 17:54:00 peter
  1029. # * better check for makefile.fpc
  1030. # * check if cmp exists
  1031. #
  1032. # Revision 1.8 1999/03/09 01:35:47 peter
  1033. # * makefile.fpc updates and defaultfpcdir var
  1034. #
  1035. #