makefile.fpc 25 KB

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