makefile.fpc 26 KB

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