makefile.fpc 20 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  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=$(BASEINSTALLDIR)/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. ifndef inlinux
  658. PACKDIR=pack_tmp
  659. else
  660. PACKDIR=/tmp/fpc-pack
  661. endif
  662. endif
  663. # Test dir if none specified
  664. ifndef PACKAGEDIR
  665. PACKAGEDIR=$(BASEDIR)
  666. endif
  667. # Add .zip/.tar.gz extension
  668. ifdef ZIPNAME
  669. ifndef inlinux
  670. override ZIPNAME:=$(ZIPNAME)$(ZIPEXT)
  671. endif
  672. endif
  673. # Default target which is call before zipping
  674. ifndef ZIPTARGET
  675. ZIPTARGET=install
  676. endif
  677. # Note: This will not remove the zipfile first
  678. fpc_zipinstalladd:
  679. ifndef ZIPNAME
  680. @$(ECHO) Please specify ZIPNAME!
  681. @exit
  682. else
  683. $(MAKE) $(ZIPTARGET) BASEINSTALLDIR=$(PACKDIR)
  684. ifdef inlinux
  685. gzip -d $(PACKAGEDIR)/$(ZIPNAME).tar.gz
  686. cd $(PACKDIR) ; tar rv --file $(PACKAGEDIR)/$(ZIPNAME).tar * ; cd $(BASEDIR)
  687. gzip $(PACKAGEDIR)/$(ZIPNAME).tar
  688. else
  689. cd $(PACKDIR) ; $(ZIPPROG) $(PACKAGEDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
  690. endif
  691. $(DELTREE) $(PACKDIR)
  692. endif
  693. # First remove the zip and then install
  694. fpc_zipinstall:
  695. ifndef ZIPNAME
  696. @$(ECHO) Please specify ZIPNAME!
  697. @exit
  698. else
  699. $(DEL) $(PACKAGEDIR)/$(ZIPNAME)
  700. $(MAKE) $(ZIPTARGET) BASEINSTALLDIR=$(PACKDIR)
  701. ifdef inlinux
  702. cd $(PACKDIR) ; tar cvz --file $(PACKAGEDIR)/$(ZIPNAME).tar.gz * ; cd $(BASEDIR)
  703. else
  704. cd $(PACKDIR) ; $(ZIPPROG) $(PACKAGEDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
  705. endif
  706. $(DELTREE) $(PACKDIR)
  707. endif
  708. #####################################################################
  709. # Clean rules
  710. #####################################################################
  711. fpc_clean:
  712. -$(DEL) $(UNITOFILES) $(UNITFILES) $(PPAS) link.res log
  713. ifeq ($(SMARTLINK),YES)
  714. -$(DELTREE) *$(SMARTEXT)
  715. endif
  716. ifdef EXEOBJECTS
  717. -$(DEL) $(EXEFILES) $(EXEOFILES)
  718. endif
  719. ifdef LOADEROBJECTS
  720. -$(DEL) $(LOADEROFILES)
  721. endif
  722. fpc_libsclean: clean
  723. -$(DEL) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  724. fpc_cleanall:
  725. ifdef EXEOBJECTS
  726. -$(DEL) $(EXEFILES)
  727. endif
  728. -$(DEL) *$(OEXT) *$(PPUEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
  729. -$(DELTREE) *$(SMARTEXT)
  730. #####################################################################
  731. # Depend rules
  732. #####################################################################
  733. fpc_depend:
  734. makedep $(UNITOBJECTS)
  735. #####################################################################
  736. # Info rules
  737. #####################################################################
  738. fpc_info: fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo
  739. fpc_cfginfo:
  740. @$(ECHO)
  741. @$(ECHO) == Configuration info ==
  742. @$(ECHO)
  743. @$(ECHO) FPCDir.... $(FPCDIR)
  744. @$(ECHO) FPCMake... $(FPCMAKE)
  745. @$(ECHO)
  746. @$(ECHO) Source.... $(OS_SOURCE)
  747. @$(ECHO) Target.... $(OS_TARGET)
  748. @$(ECHO) Basedir... $(BASEDIR)
  749. @$(ECHO)
  750. fpc_toolsinfo:
  751. @$(ECHO)
  752. @$(ECHO) == Tools info ==
  753. @$(ECHO)
  754. @$(ECHO) Pwd....... $(PWD)
  755. @$(ECHO) Echo...... $(ECHO)
  756. ifdef SED
  757. @$(ECHO) Sed....... $(SED)
  758. endif
  759. ifdef DATE
  760. @$(ECHO) Date...... $(DATE)
  761. endif
  762. ifdef DIFF
  763. @$(ECHO) Diff...... $(DIFF)
  764. endif
  765. ifdef CMP
  766. @$(ECHO) Cmp....... $(CMP)
  767. endif
  768. ifdef UPX
  769. @$(ECHO) Upx....... $(UPX)
  770. endif
  771. ifdef UPX
  772. @$(ECHO) Zip....... $(ZIPPROG)
  773. endif
  774. @$(ECHO)
  775. fpc_objectinfo:
  776. @$(ECHO)
  777. @$(ECHO) == Object info ==
  778. @$(ECHO)
  779. @$(ECHO) LoaderObjects. $(LOADEROBJECTS)
  780. @$(ECHO) UnitObjects... $(UNITOBJECTS)
  781. @$(ECHO) ExeObjects.... $(EXEOBJECTS)
  782. @$(ECHO)
  783. fpc_installinfo:
  784. @$(ECHO)
  785. @$(ECHO) == Install info ==
  786. @$(ECHO)
  787. @$(ECHO) DateStr.............. $(DATESTR)
  788. @$(ECHO) PackageSuffix........ $(PACKAGESUFFIX)
  789. @$(ECHO)
  790. @$(ECHO) BaseInstallDir....... $(BASEINSTALLDIR)
  791. @$(ECHO) BinInstallDir........ $(BININSTALLDIR)
  792. @$(ECHO) UnitInstallDir....... $(UNITINSTALLDIR)
  793. @$(ECHO) StaticUnitInstallDir. $(STATIC_UNITINSTALLDIR)
  794. @$(ECHO) SharedUnitInstallDir. $(SHARED_UNITINSTALLDIR)
  795. @$(ECHO) LibInstallDir........ $(LIBINSTALLDIR)
  796. @$(ECHO) StaticLibInstallDir.. $(STATIC_LIBINSTALLDIR)
  797. @$(ECHO) SharedLibInstallDir.. $(SHARED_LIBINSTALLDIR)
  798. @$(ECHO) MsgInstallDir........ $(MSGINSTALLDIR)
  799. @$(ECHO) DocInstallDir........ $(DOCINSTALLDIR)
  800. @$(ECHO)
  801. # try to get the files in the currentdir
  802. PASFILES:=$(wildcard *.pas)
  803. PPFILES:=$(wildcard *.pp)
  804. INCFILES:=$(wildcard *.inc)
  805. MSGFILES:=$(wildcard *.msg)
  806. ASFILES:=$(wildcard *.as)
  807. fpc_filesinfo:
  808. @$(ECHO)
  809. @$(ECHO) == Files info ==
  810. @$(ECHO)
  811. ifdef PASFILES
  812. @$(ECHO) Pas files are $(PASFILES)
  813. endif
  814. ifdef PPFILES
  815. @$(ECHO) PP files are $(PPFILES)
  816. endif
  817. ifdef INCFILES
  818. @$(ECHO) Inc files are $(INCFILES)
  819. endif
  820. ifdef MSGFILES
  821. @$(ECHO) Msg files are $(MSGFILES)
  822. endif
  823. ifdef ASFILES
  824. @$(ECHO) As files are $(ASFILES)
  825. endif
  826. #
  827. # $Log$
  828. # Revision 1.15 1999-04-16 20:12:35 michael
  829. # + install target now correctly takes the BASEINSTALLDIR on linux
  830. #
  831. # Revision 1.14 1999/04/08 10:16:17 peter
  832. # * zipinstall for linux with .tar.gz
  833. #
  834. # Revision 1.13 1999/04/01 22:52:28 peter
  835. # * don't override pasext if set
  836. #
  837. # Revision 1.12 1999/03/29 16:04:58 peter
  838. # * place -T as the first parameter on the commandline so a OPT=-A can
  839. # overwrite it
  840. #
  841. # Revision 1.11 1999/03/16 00:46:55 peter
  842. # * makefile.fpc targets start with fpc_
  843. # * small updates for install scripts
  844. #
  845. # Revision 1.10 1999/03/12 21:01:30 michael
  846. # + Changed clean and libsclean to fpc_target
  847. #
  848. # Revision 1.9 1999/03/11 17:54:00 peter
  849. # * better check for makefile.fpc
  850. # * check if cmp exists
  851. #
  852. # Revision 1.8 1999/03/09 01:35:47 peter
  853. # * makefile.fpc updates and defaultfpcdir var
  854. #
  855. #