2
0

makefile.fpc 20 KB

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