makefile.fpc 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164
  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
  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. UNITPPUFILES=$(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: $(UNITPPUFILES)
  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)/,$(wildcard $(UNITPPUFILES) $(UNITOFILES) $(UNITAFILES)))
  629. endif
  630. ifdef EXTRAINSTALLUNITS
  631. $(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(wildcard $(addsuffix $(OEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))))
  632. endif
  633. fpc_install : all
  634. # Create UnitInstallFiles
  635. ifdef EXTRAINSTALLUNITS
  636. override EXTRAINSTALLFILES=$(wildcard $(addsuffix $(OEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS)))
  637. endif
  638. ifndef DEFAULTUNITS
  639. ifdef EXEOBJECTS
  640. $(MKDIR) $(BININSTALLDIR)
  641. # Compress the exes if upx is defined
  642. ifdef UPX
  643. -$(UPX) $(EXEFILES)
  644. endif
  645. $(INSTALLEXE) $(EXEFILES) $(BININSTALLDIR)
  646. endif
  647. endif
  648. ifdef LOADEROBJECTS
  649. $(MKDIR) $(UNITINSTALLDIR)
  650. $(INSTALL) $(LOADEROFILES) $(UNITINSTALLDIR)
  651. endif
  652. ifdef UNITOBJECTS
  653. $(MKDIR) $(UNITINSTALLDIR)
  654. $(INSTALL) $(wildcard $(UNITPPUFILES) $(UNITOFILES) $(UNITAFILES)) $(UNITINSTALLDIR)
  655. endif
  656. ifdef EXTRAINSTALLUNITS
  657. $(MKDIR) $(UNITINSTALLDIR)
  658. $(INSTALL) $(wildcard $(addsuffix $(OEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))) $(UNITINSTALLDIR)
  659. endif
  660. # Target for the sharedlib install which is not avail for all targets
  661. ifdef inlinux
  662. SHAREDINSTALL=sharedinstall
  663. else
  664. SHAREDINSTALL=
  665. endif
  666. fpc_staticinstall: staticlib
  667. $(MKDIR) $(STATIC_UNITINSTALLDIR)
  668. $(INSTALL) $(UNITINSTALLFILES) $(STATIC_UNITINSTALLDIR)
  669. $(MKDIR) $(STATIC_LIBINSTALLDIR)
  670. $(INSTALLEXE) *$(STATICLIBEXT) $(STATIC_LIBINSTALLDIR)
  671. fpc_sharedinstall: sharedlib
  672. $(MKDIR) $(SHARED_UNITINSTALLDIR)
  673. $(INSTALL) $(UNITINSTALLFILES) $(SHARED_UNITINSTALLDIR)
  674. $(MKDIR) $(SHARED_LIBINSTALLDIR)
  675. $(INSTALLEXE) *$(SHAREDLIBEXT) $(SHARED_LIBINSTALLDIR)
  676. fpc_libinstall: staticinstall $(SHAREDINSTALL)
  677. #####################################################################
  678. # Zip
  679. #####################################################################
  680. # Temporary path to pack a file
  681. ifndef PACKDIR
  682. ifndef inlinux
  683. PACKDIR=pack_tmp
  684. else
  685. PACKDIR=/tmp/fpc-pack
  686. endif
  687. endif
  688. # Test dir if none specified
  689. ifndef PACKAGEDIR
  690. PACKAGEDIR=$(BASEDIR)
  691. endif
  692. # Add .zip/.tar.gz extension
  693. ifdef ZIPNAME
  694. ifndef inlinux
  695. override ZIPNAME:=$(ZIPNAME)$(ZIPEXT)
  696. endif
  697. endif
  698. # Default target which is call before zipping
  699. ifndef ZIPTARGET
  700. ZIPTARGET=install
  701. endif
  702. # Note: This will not remove the zipfile first
  703. fpc_zipinstalladd:
  704. ifndef ZIPNAME
  705. @$(ECHO) Please specify ZIPNAME!
  706. @exit
  707. else
  708. $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
  709. ifdef inlinux
  710. gzip -d $(PACKAGEDIR)/$(ZIPNAME).tar.gz
  711. cd $(PACKDIR) ; tar rv --file $(PACKAGEDIR)/$(ZIPNAME).tar * ; cd $(BASEDIR)
  712. gzip $(PACKAGEDIR)/$(ZIPNAME).tar
  713. else
  714. cd $(PACKDIR) ; $(ZIPPROG) $(PACKAGEDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
  715. endif
  716. $(DELTREE) $(PACKDIR)
  717. endif
  718. # First remove the zip and then install
  719. fpc_zipinstall:
  720. ifndef ZIPNAME
  721. @$(ECHO) Please specify ZIPNAME!
  722. @exit
  723. else
  724. $(DEL) $(PACKAGEDIR)/$(ZIPNAME)
  725. $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
  726. ifdef inlinux
  727. cd $(PACKDIR) ; tar cvz --file $(PACKAGEDIR)/$(ZIPNAME).tar.gz * ; cd $(BASEDIR)
  728. else
  729. cd $(PACKDIR) ; $(ZIPPROG) $(PACKAGEDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
  730. endif
  731. $(DELTREE) $(PACKDIR)
  732. endif
  733. #####################################################################
  734. # Clean rules
  735. #####################################################################
  736. fpc_clean:
  737. ifdef EXEOBJECTS
  738. -$(DEL) $(EXEFILES) $(EXEOFILES)
  739. endif
  740. ifdef LOADEROBJECTS
  741. -$(DEL) $(LOADEROFILES)
  742. endif
  743. ifdef UNITOBJECTS
  744. -$(DEL) $(wildcard $(UNITPPUFILES) $(UNITOFILES) $(UNITAFILES))
  745. endif
  746. ifdef EXTRACLEANUNITS
  747. -$(DEL) $(wildcard $(addsuffix $(OEXT),$(EXTRACLEANUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRACLEANUNITS)) $(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)))
  748. endif
  749. -$(DEL) $(PPAS) link.res log
  750. fpc_libsclean: clean
  751. -$(DEL) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  752. fpc_cleanall:
  753. ifdef EXEOBJECTS
  754. -$(DEL) $(EXEFILES)
  755. endif
  756. -$(DEL) *$(OEXT) *$(PPUEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  757. -$(DELTREE) *$(SMARTEXT)
  758. #####################################################################
  759. # Depend rules
  760. #####################################################################
  761. fpc_depend:
  762. makedep $(UNITOBJECTS)
  763. #####################################################################
  764. # Info rules
  765. #####################################################################
  766. fpc_info: fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo\
  767. fpc_dirinfo
  768. fpc_cfginfo:
  769. @$(ECHO)
  770. @$(ECHO) == Configuration info ==
  771. @$(ECHO)
  772. @$(ECHO) FPCDir.... $(FPCDIR)
  773. @$(ECHO) FPCMake... $(FPCMAKE)
  774. @$(ECHO)
  775. @$(ECHO) Version... $(FPC_VERSION)
  776. @$(ECHO) CPU....... $(CPU)
  777. @$(ECHO) Source.... $(OS_SOURCE)
  778. @$(ECHO) Target.... $(OS_TARGET)
  779. @$(ECHO)
  780. fpc_dirinfo:
  781. ifdef inlinux
  782. @$(ECHO)
  783. @$(ECHO) == Directory info ==
  784. @$(ECHO)
  785. ifdef NEEDGCCLIB
  786. @$(ECHO) GCC library is needed.
  787. endif
  788. ifdef NEEDOTHERLIB
  789. @$(ECHO) Other library is needed.
  790. endif
  791. @$(ECHO) Basedir......... $(BASEDIR)
  792. @$(ECHO)
  793. @$(ECHO) GCC library..... $(GCCLIBDIR)
  794. @$(ECHO) Other library... $(OTHERLIBDIR)
  795. @$(ECHO)
  796. endif
  797. fpc_toolsinfo:
  798. @$(ECHO)
  799. @$(ECHO) == Tools info ==
  800. @$(ECHO)
  801. @$(ECHO) Pwd....... $(PWD)
  802. @$(ECHO) Echo...... $(ECHO)
  803. ifdef SED
  804. @$(ECHO) Sed....... $(SED)
  805. endif
  806. ifdef DATE
  807. @$(ECHO) Date...... $(DATE)
  808. endif
  809. ifdef DIFF
  810. @$(ECHO) Diff...... $(DIFF)
  811. endif
  812. ifdef CMP
  813. @$(ECHO) Cmp....... $(CMP)
  814. endif
  815. ifdef UPX
  816. @$(ECHO) Upx....... $(UPX)
  817. endif
  818. ifdef ZIPPROG
  819. @$(ECHO) Zip....... $(ZIPPROG)
  820. endif
  821. @$(ECHO)
  822. fpc_objectinfo:
  823. @$(ECHO)
  824. @$(ECHO) == Object info ==
  825. @$(ECHO)
  826. @$(ECHO) LoaderObjects..... $(LOADEROBJECTS)
  827. @$(ECHO) UnitObjects....... $(UNITOBJECTS)
  828. @$(ECHO) ExeObjects........ $(EXEOBJECTS)
  829. @$(ECHO)
  830. @$(ECHO) ExtraCleanUnits... $(EXTRACLEANUNITS)
  831. @$(ECHO) ExtraInstallUnits. $(EXTRAINSTALLUNITS)
  832. @$(ECHO) ExtraInstallUnits. $(EXTRAINSTALLFILES)
  833. @$(ECHO)
  834. @$(ECHO) == Unit info ==
  835. @$(ECHO)
  836. @$(ECHO) UnitInstallFiles. $(UNITINSTALLFILES)
  837. @$(ECHO) UnitCleanFiles... $(UNITCLEANFILES)
  838. @$(ECHO)
  839. fpc_installinfo:
  840. @$(ECHO)
  841. @$(ECHO) == Install info ==
  842. @$(ECHO)
  843. @$(ECHO) DateStr.............. $(DATESTR)
  844. @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX)
  845. @$(ECHO)
  846. @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR)
  847. @$(ECHO) BinInstallDir........ $(BININSTALLDIR)
  848. @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR)
  849. @$(ECHO) StaticUnitInstallDir. $(STATIC_UNITINSTALLDIR)
  850. @$(ECHO) SharedUnitInstallDir. $(SHARED_UNITINSTALLDIR)
  851. @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR)
  852. @$(ECHO) StaticLibInstallDir.. $(STATIC_LIBINSTALLDIR)
  853. @$(ECHO) SharedLibInstallDir.. $(SHARED_LIBINSTALLDIR)
  854. @$(ECHO) MsgInstallDir........ $(MSGINSTALLDIR)
  855. @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR)
  856. @$(ECHO)
  857. # try to get the files in the currentdir
  858. PASFILES:=$(wildcard *.pas)
  859. PPFILES:=$(wildcard *.pp)
  860. INCFILES:=$(wildcard *.inc)
  861. MSGFILES:=$(wildcard *.msg)
  862. ASFILES:=$(wildcard *.as)
  863. fpc_filesinfo:
  864. @$(ECHO)
  865. @$(ECHO) == Files info ==
  866. @$(ECHO)
  867. ifdef PASFILES
  868. @$(ECHO) Pas files are $(PASFILES)
  869. endif
  870. ifdef PPFILES
  871. @$(ECHO) PP files are $(PPFILES)
  872. endif
  873. ifdef INCFILES
  874. @$(ECHO) Inc files are $(INCFILES)
  875. endif
  876. ifdef MSGFILES
  877. @$(ECHO) Msg files are $(MSGFILES)
  878. endif
  879. ifdef ASFILES
  880. @$(ECHO) As files are $(ASFILES)
  881. endif
  882. #
  883. # $Log$
  884. # Revision 1.40 1999-07-17 14:22:54 peter
  885. # * ECHO is now again without @
  886. #
  887. # Revision 1.39 1999/07/17 11:30:23 peter
  888. # * merged
  889. #
  890. # Revision 1.38 1999/07/16 13:45:24 peter
  891. # * 0.99.12b updates
  892. # * merges
  893. #
  894. # Revision 1.37 1999/07/05 21:37:35 peter
  895. # * display extraunits in info
  896. #
  897. # Revision 1.36 1999/07/01 18:20:01 jonas
  898. # * changed RELEASE=1 processor option from -Op2 to -Op3
  899. #
  900. # Revision 1.35 1999/06/18 11:03:08 peter
  901. # * merged
  902. #
  903. # Revision 1.34 1999/06/18 10:11:18 peter
  904. # * merged
  905. #
  906. # Revision 1.33 1999/06/13 22:43:23 peter
  907. # * merged from fixes
  908. #
  909. # Revision 1.32 1999/06/11 13:31:14 hajny
  910. # * fixes for OS/2
  911. #
  912. # Revision 1.31.2.5 1999/07/17 11:29:02 peter
  913. # * more extrainstallunits,extracleanunits updates
  914. #
  915. # Revision 1.31.2.4 1999/07/16 13:40:56 peter
  916. # + extrainstallunits,extracleanunits
  917. #
  918. # Revision 1.31.2.3 1999/06/18 10:55:31 peter
  919. # * version fixes
  920. # * EXTRAUNITS to set extra units that are build and needs to be cleaned
  921. #
  922. # Revision 1.31.2.2 1999/06/18 10:07:27 peter
  923. # * rtl/linux and units/linux also for linux installs
  924. #
  925. # Revision 1.31.2.1 1999/06/13 22:36:38 peter
  926. # * install msg files in msg/ instead of bin for not linux
  927. #
  928. # Revision 1.31 1999/06/10 15:02:08 peter
  929. # * last fixes for 0.99.12 release
  930. #
  931. # Revision 1.30 1999/06/03 09:36:31 peter
  932. # * first things for sharedlib to work again
  933. #
  934. # Revision 1.29 1999/06/01 13:27:24 peter
  935. # * updates for linux
  936. #
  937. # Revision 1.28 1999/05/30 11:33:04 peter
  938. # * releasever removed, fpc_version will be used
  939. #
  940. # Revision 1.27 1999/05/16 02:37:30 peter
  941. # + fpc_showinstallfiles to show which files will be added to the system
  942. #
  943. # Revision 1.26 1999/05/14 22:46:21 peter
  944. # * patch for comments in ld.so.conf
  945. #
  946. # Revision 1.25 1999/05/12 16:17:07 peter
  947. # + utils_X targets
  948. # * missing export of prefixinstalldir
  949. #
  950. # Revision 1.24 1999/05/11 00:48:12 peter
  951. # * fixed some typos
  952. #
  953. # Revision 1.23 1999/05/10 15:18:43 peter
  954. # * NEEDOTHERLIB define to load ld.so.conf for linux
  955. #
  956. # Revision 1.22 1999/05/04 23:20:42 pierre
  957. # + FPC_VERSION (with shell $(PP) -iV)
  958. #
  959. # Revision 1.21 1999/05/03 22:38:10 peter
  960. # * typo with -TP which should be -iTP
  961. #
  962. # Revision 1.20 1999/05/03 22:29:04 peter
  963. # * os_source,os_target depends now on the compiler
  964. # * cpu depends on the compiler
  965. # * datestr y2k proof
  966. #
  967. # Revision 1.19 1999/05/03 18:04:58 peter
  968. # + sourceinstalldir
  969. #
  970. # Revision 1.18 1999/04/29 15:52:38 peter
  971. # * better gcclib dir detection
  972. #
  973. # Revision 1.17 1999/04/20 12:33:32 michael
  974. # + Fixed GCCLIB detection. Added fpc_dirinfo target
  975. #
  976. # Revision 1.16 1999/04/20 12:07:49 michael
  977. # Added autodetect of gcc lib for linux
  978. #
  979. # Revision 1.15 1999/04/16 20:12:35 michael
  980. # + install target now correctly takes the BASEINSTALLDIR on linux
  981. #
  982. # Revision 1.14 1999/04/08 10:16:17 peter
  983. # * zipinstall for linux with .tar.gz
  984. #
  985. # Revision 1.13 1999/04/01 22:52:28 peter
  986. # * don't override pasext if set
  987. #
  988. # Revision 1.12 1999/03/29 16:04:58 peter
  989. # * place -T as the first parameter on the commandline so a OPT=-A can
  990. # overwrite it
  991. #
  992. # Revision 1.11 1999/03/16 00:46:55 peter
  993. # * makefile.fpc targets start with fpc_
  994. # * small updates for install scripts
  995. #
  996. # Revision 1.10 1999/03/12 21:01:30 michael
  997. # + Changed clean and libsclean to fpc_target
  998. #
  999. # Revision 1.9 1999/03/11 17:54:00 peter
  1000. # * better check for makefile.fpc
  1001. # * check if cmp exists
  1002. #
  1003. # Revision 1.8 1999/03/09 01:35:47 peter
  1004. # * makefile.fpc updates and defaultfpcdir var
  1005. #
  1006. #