makefile.fpc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. #
  2. # $Id$
  3. # Copyright (c) 1998 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.9
  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. PWD=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
  25. ifeq ($(PWD),)
  26. PWD=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
  27. ifeq ($(PWD),)
  28. nopwd:
  29. @echo
  30. @echo You need the GNU pwd,cp,mv,rm,install utils to use this makefile!
  31. @echo Get ftp://tflily.fys.kuleuven.ac.be/pub/fpc/dist/gnuutils.zip
  32. @echo
  33. @exit
  34. else
  35. inlinux=1
  36. endif
  37. else
  38. PWD:=$(subst \,/,$(firstword $(PWD)))
  39. endif
  40. # Detect NT - NT sets OS to Windows_NT
  41. ifndef inlinux
  42. ifeq ($(OS),Windows_NT)
  43. inWinNT=1
  44. endif
  45. endif
  46. #####################################################################
  47. # Targets
  48. #####################################################################
  49. # Target OS
  50. ifndef OS_TARGET
  51. ifdef inlinux
  52. OS_TARGET=linux
  53. else
  54. ifdef inWinNT
  55. OS_TARGET=win32
  56. else
  57. OS_TARGET=go32v2
  58. endif
  59. endif
  60. endif
  61. # Source OS
  62. ifndef OS_SOURCE
  63. ifdef inlinux
  64. OS_SOURCE=linux
  65. else
  66. ifndef inWinNT
  67. OS_SOURCE=win32
  68. else
  69. OS_SOURCE=go32v2
  70. endif
  71. endif
  72. endif
  73. # CPU
  74. ifndef CPU
  75. CPU=i386
  76. endif
  77. # Options
  78. ifndef OPT
  79. OPT=
  80. endif
  81. # What compiler to use ?
  82. ifndef PP
  83. PP=ppc386
  84. endif
  85. # assembler, redefine it if cross compiling
  86. ifndef AS
  87. AS=as
  88. endif
  89. # linker, but probably not used
  90. ifndef LD
  91. LD=ld
  92. endif
  93. # Release ? Then force OPT and don't use extra opts via commandline
  94. ifdef RELEASE
  95. override OPT:=-Xs -OG2p2 -n
  96. endif
  97. # Verbose settings (warning,note,info)
  98. ifdef VERBOSE
  99. override OPT+=-vwni
  100. endif
  101. #####################################################################
  102. # Shell commands
  103. #####################################################################
  104. # To copy pograms
  105. ifndef COPY
  106. COPY=cp -fp
  107. endif
  108. # To move pograms
  109. ifndef MOVE
  110. MOVE=mv -f
  111. endif
  112. # Check delete program
  113. ifndef DEL
  114. DEL=rm -f
  115. endif
  116. # Check deltree program
  117. ifndef DELTREE
  118. DELTREE=rm -rf
  119. endif
  120. # To install files
  121. ifndef INSTALL
  122. ifdef inlinux
  123. INSTALL=install -m 644
  124. else
  125. INSTALL=$(COPY)
  126. # ginstall has the strange thing to stubify all .o files !
  127. #INSTALL=ginstall -m 644
  128. endif
  129. endif
  130. # To install programs
  131. ifndef INSTALLEXE
  132. ifdef inlinux
  133. INSTALLEXE=install -m 755
  134. else
  135. INSTALLEXE=$(COPY)
  136. # ginstall has the strange thing to stubify all .o files !
  137. #INSTALLEXE=ginstall -m 755
  138. endif
  139. endif
  140. # To make a directory.
  141. ifndef MKDIR
  142. ifdef inlinux
  143. MKDIR=install -m 755 -d
  144. else
  145. MKDIR=ginstall -m 755 -d
  146. endif
  147. endif
  148. #####################################################################
  149. # Default Tools
  150. #####################################################################
  151. # ppas.bat / ppas.sh
  152. ifdef inlinux
  153. PPAS=ppas.sh
  154. else
  155. PPAS=ppas.bat
  156. endif
  157. # ldconfig to rebuild .so cache
  158. ifdef inlinux
  159. LDCONFIG=ldconfig
  160. else
  161. LDCONFIG=
  162. endif
  163. # Where is the ppumove program ?
  164. ifndef PPUMOVE
  165. PPUMOVE=ppumove
  166. endif
  167. # diff
  168. ifndef DIFF
  169. DIFF=diff
  170. endif
  171. # date
  172. ifndef DATE
  173. # first try go32v2 specific gdate
  174. DATE=$(strip $(wildcard $(addsuffix /gdate.exe,$(subst ;, ,$(PATH)))))
  175. # try generic date.exe
  176. ifeq ($(DATE),)
  177. DATE=$(strip $(wildcard $(addsuffix /date.exe,$(subst ;, ,$(PATH)))))
  178. # finally try for linux
  179. ifeq ($(DATE),)
  180. DATE=$(strip $(wildcard $(addsuffix /date,$(subst :, ,$(PATH)))))
  181. ifeq ($(DATE),)
  182. DATE=
  183. endif
  184. else
  185. DATE:=$(subst \,/,$(firstword $(DATE)))
  186. endif
  187. else
  188. DATE:=$(subst \,/,$(firstword $(DATE)))
  189. endif
  190. endif
  191. # Sed
  192. ifndef SED
  193. SED=$(strip $(wildcard $(addsuffix /sed.exe,$(subst ;, ,$(PATH)))))
  194. ifeq ($(SED),)
  195. SED=$(strip $(wildcard $(addsuffix /sed,$(subst :, ,$(PATH)))))
  196. ifeq ($(SED),)
  197. SED=
  198. endif
  199. else
  200. SED:=$(subst \,/,$(firstword $(SED)))
  201. endif
  202. endif
  203. #####################################################################
  204. # Default Directories
  205. #####################################################################
  206. # Base dir
  207. ifdef PWD
  208. BASEDIR=$(shell $(PWD))
  209. endif
  210. # set the directory to the rtl base
  211. ifndef RTLDIR
  212. ifdef RTL
  213. RTLDIR=$(RTL)
  214. else
  215. RTLDIR:=$(BASEDIR)/../rtl
  216. endif
  217. endif
  218. # specify where units are.
  219. ifndef UNITDIR
  220. UNITDIR=$(RTLDIR)/$(OS_TARGET)
  221. ifeq ($(OS_TARGET),go32v1)
  222. UNITDIR=$(RTLDIR)/dos/go32v1
  223. endif
  224. ifeq ($(OS_TARGET),go32v2)
  225. UNITDIR=$(RTLDIR)/dos/go32v2
  226. endif
  227. endif
  228. # set the base directory where to install everything
  229. ifndef BASEINSTALLDIR
  230. ifdef inlinux
  231. BASEINSTALLDIR=/usr/lib/fpc/$(RELEASEVER)
  232. else
  233. BASEINSTALLDIR=/pp
  234. endif
  235. endif
  236. #####################################################################
  237. # Install Directories based on BASEINSTALLDIR
  238. #####################################################################
  239. # Linux binary really goes to baseinstalldir
  240. ifndef LIBINSTALLDIR
  241. ifdef inlinux
  242. LIBINSTALLDIR=$(BASEINSTALLDIR)
  243. else
  244. LIBINSTALLDIR=$(BASEINSTALLDIR)/lib
  245. endif
  246. endif
  247. # set the directory where to install the binaries
  248. ifndef BININSTALLDIR
  249. ifdef inlinux
  250. BININSTALLDIR=/usr/bin
  251. else
  252. BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET)
  253. endif
  254. endif
  255. # set the directory where to install the units.
  256. ifndef UNITINSTALLDIR
  257. ifdef inlinux
  258. UNITINSTALLDIR=$(BASEINSTALLDIR)/linuxunits
  259. else
  260. UNITINSTALLDIR=$(BASEINSTALLDIR)/rtl/$(OS_TARGET)
  261. endif
  262. endif
  263. # set the directory where to install the units.
  264. ifndef STATIC_UNITINSTALLDIR
  265. ifdef inlinux
  266. STATIC_UNITINSTALLDIR=$(BASEINSTALLDIR)/staticunits
  267. else
  268. STATIC_UNITINSTALLDIR=$(BASEINSTALLDIR)/rtl/$(OS_TARGET)/static
  269. endif
  270. endif
  271. # set the directory where to install the units.
  272. ifndef SHARED_UNITINSTALLDIR
  273. ifdef inlinux
  274. SHARED_UNITINSTALLDIR=$(BASEINSTALLDIR)/sharedunits
  275. else
  276. SHARED_UNITINSTALLDIR=$(BASEINSTALLDIR)/rtl/$(OS_TARGET)/shared
  277. endif
  278. endif
  279. # set the directory where to install the libs (must exist)
  280. ifndef STATIC_LIBINSTALLDIR
  281. ifdef inlinux
  282. STATIC_LIBINSTALLDIR=$(BASEINSTALLDIR)/staticunits
  283. else
  284. STATIC_LIBINSTALLDIR=$(STATIC_UNITINSTALLDIR)
  285. endif
  286. endif
  287. # set the directory where to install the libs (must exist)
  288. ifndef SHARED_LIBINSTALLDIR
  289. ifdef inlinux
  290. SHARED_LIBINSTALLDIR=/usr/lib
  291. else
  292. SHARED_LIBINSTALLDIR=$(SHARED_UNITINSTALLDIR)
  293. endif
  294. endif
  295. # Where the .msg files will be stored
  296. ifndef MSGINSTALLDIR
  297. ifdef inlinux
  298. MSGINSTALLDIR=$(BASEINSTALLDIR)/msg
  299. else
  300. MSGINSTALLDIR=$(BININSTALLDIR)
  301. endif
  302. endif
  303. # Where the doc files will be stored
  304. ifndef DOCINSTALLDIR
  305. ifdef inlinux
  306. DOCINSTALLDIR=/usr/doc/fpc/$(RELEASEVER)
  307. else
  308. DOCINSTALLDIR=$(BASEINSTALLDIR)/doc
  309. endif
  310. endif
  311. #####################################################################
  312. # Compiler Command Line
  313. #####################################################################
  314. # Load commandline OPTDEF and add CPU define
  315. override PPOPTDEF=$(OPTDEF) -d$(CPU)
  316. # Load commandline OPT and add target and unit dir to be sure
  317. override PPOPT=$(OPT) -T$(OS_TARGET) -Fu$(UNITDIR)
  318. # Add include dirs INC and PROCINC
  319. ifdef INC
  320. override PPOPT+=-I$(INC)
  321. endif
  322. ifdef PROCINC
  323. override PPOPT+=-I$(PROCINC)
  324. endif
  325. ifdef OSINC
  326. override PPOPT+=-I$(OSINC)
  327. endif
  328. # Target dirs
  329. ifdef TARGETDIR
  330. override PPOPT+=-FE$(TARGETDIR)
  331. endif
  332. ifdef UNITTARGETDIR
  333. override PPOPT+=-FU$(UNITTARGETDIR)
  334. endif
  335. # Smartlinking
  336. ifeq ($(SMARTLINK),YES)
  337. ifeq ($(LIBTYPE),shared)
  338. override SMARTLINK=NO
  339. else
  340. override PPOPT+=-Cx
  341. endif
  342. endif
  343. # Add library type, for static libraries smartlinking is automatic used
  344. ifeq ($(LIBTYPE),shared)
  345. override PPOPT+=-CD
  346. else
  347. ifeq ($(LIBTYPE),static)
  348. override PPOPT+=-CS
  349. endif
  350. endif
  351. # Add library name
  352. ifneq ($(LIBNAME),)
  353. override PPOPT:=$(PPOPT) -o$(LIBNAME)
  354. endif
  355. # Add defines from PPOPTDEF to PPOPT
  356. override PPOPT:=$(PPOPT) $(PPOPTDEF)
  357. # Was a config file specified ?
  358. ifdef CFGFILE
  359. override PPOPT:=$(PPOPT) @$(CFGFILE)
  360. endif
  361. override COMPILER=$(PP) $(PPOPT)
  362. #####################################################################
  363. # Default extensions
  364. #####################################################################
  365. # Default needed extensions (Go32v2,Linux)
  366. PPLEXT=.ppl
  367. PPUEXT=.ppu
  368. OEXT=.o
  369. ASMEXT=.s
  370. SMARTEXT=.sl
  371. STATICLIBEXT=.a
  372. SHAREDLIBEXT=.so
  373. # Executable extension
  374. ifdef inlinux
  375. EXEEXT=
  376. else
  377. EXEEXT=.exe
  378. endif
  379. # Go32v1
  380. ifeq ($(OS_TARGET),go32v1)
  381. PPUEXT=.pp1
  382. OEXT=.o1
  383. ASMEXT=.s1
  384. SMARTEXT=.sl1
  385. STATICLIBEXT=.a1
  386. SHAREDLIBEXT=.so1
  387. endif
  388. # Win32
  389. ifeq ($(OS_TARGET),win32)
  390. PPUEXT=.ppw
  391. OEXT=.ow
  392. ASMEXT=.sw
  393. SMARTEXT=.slw
  394. STATICLIBEXT=.aw
  395. SHAREDLIBEXT=.dll
  396. endif
  397. # OS/2
  398. ifeq ($(OS_TARGET),os2)
  399. PPUEXT=.ppo
  400. ASMEXT=.so2
  401. OEXT=.o2
  402. SMARTEXT=.so
  403. STATICLIBEXT=.ao
  404. SHAREDLIBEXT=.dll
  405. endif
  406. # determine libary extension.
  407. ifeq ($(LIBTYPE),static)
  408. LIBEXT=$(STATICLIBEXT)
  409. else
  410. LIBEXT=$(SHAREDLIBEXT)
  411. endif
  412. # library prefix
  413. LIBPREFIX=lib
  414. ifeq ($(OS_TARGET),go32v2)
  415. LIBPREFIX=
  416. endif
  417. ifeq ($(OS_TARGET),go32v1)
  418. LIBPREFIX=
  419. endif
  420. # determine with .pas extension is used
  421. ifdef EXEOBJECTS
  422. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS)))))
  423. else
  424. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS)))))
  425. endif
  426. ifeq ($(TESTPAS),)
  427. PASEXT=.pp
  428. else
  429. PASEXT=.pas
  430. endif
  431. #####################################################################
  432. # Export commandline values, so nesting use the same values
  433. #####################################################################
  434. export OS_SOURCE OS_TARGET OPT OPTDEF CPU PP RELEASE VERBOSE
  435. export SMARTLINK LIBTYPE LIBNAME
  436. export BASEINSTALLDIR
  437. #####################################################################
  438. # General compile rules
  439. #####################################################################
  440. # Create Filenames
  441. EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS))
  442. UNITFILES=$(addsuffix $(PPUEXT),$(UNITOBJECTS))
  443. UNITOFILES=$(addsuffix $(OEXT),$(UNITOBJECTS))
  444. .PHONY : all clean install \
  445. info cfginfo objectinfo installinfo filesinfo
  446. .SUFFIXES : $(EXEEXT) $(PPUEXT) $(PASEXT)
  447. all: units exes
  448. units: $(UNITFILES)
  449. exes: $(EXEFILES)
  450. # General compile rules
  451. %$(PPUEXT): %$(PASEXT)
  452. $(COMPILER) $<
  453. %$(EXEEXT): %$(PASEXT)
  454. $(COMPILER) $<
  455. #####################################################################
  456. # Install rules
  457. #####################################################################
  458. install : all
  459. ifdef EXEOBJECTS
  460. $(MKDIR) $(BININSTALLDIR)
  461. $(INSTALLEXE) $(EXEFILES) $(BININSTALLDIR)
  462. endif
  463. ifdef UNITOBJECTS
  464. $(MKDIR) $(UNITINSTALLDIR)
  465. ifeq ($(SMARTLINK),YES)
  466. $(INSTALL) $(LIBPREFIX)$(LIBNAME)$(LIBEXT) $(UNITINSTALLDIR)
  467. else
  468. $(INSTALL) $(UNITFILES) $(UNITOFILES) $(UNITINSTALLDIR)
  469. endif
  470. endif
  471. #####################################################################
  472. # Clean rules
  473. #####################################################################
  474. clean:
  475. -$(DEL) *$(OEXT) *$(ASMEXT) *$(PPUEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) $(PPAS) link.res log
  476. -$(DELTREE) *$(SMARTEXT)
  477. ifdef EXEOBJECTS
  478. -$(DEL) $(EXEFILES)
  479. endif
  480. #####################################################################
  481. # Depend rules
  482. #####################################################################
  483. depend:
  484. makedep $(UNITOBJECTS)
  485. #####################################################################
  486. # Info rules
  487. #####################################################################
  488. info: cfginfo objectinfo installinfo
  489. cfginfo:
  490. @echo
  491. @echo == Configuration info ==
  492. @echo
  493. @echo Source.... $(OS_SOURCE)
  494. @echo Target.... $(OS_TARGET)
  495. @echo Basedir... $(BASEDIR)
  496. @echo Pwd....... $(PWD)
  497. ifdef SED
  498. @echo Sed....... $(SED)
  499. endif
  500. @echo
  501. objectinfo:
  502. @echo
  503. @echo == Object info ==
  504. @echo
  505. @echo UnitObjects... $(UNITOBJECTS)
  506. @echo ExeObjects.... $(EXEOBJECTS)
  507. @echo
  508. installinfo:
  509. @echo
  510. @echo == Install info ==
  511. @echo
  512. @echo BaseInstallDir....... $(BASEINSTALLDIR)
  513. @echo BinInstallDir........ $(BININSTALLDIR)
  514. @echo UnitInstallDir....... $(UNITINSTALLDIR)
  515. @echo StaticUnitInstallDir. $(STATIC_UNITINSTALLDIR)
  516. @echo SharedUnitInstallDir. $(SHARED_UNITINSTALLDIR)
  517. @echo LibInstallDir........ $(LIBINSTALLDIR)
  518. @echo StaticLibInstallDir.. $(STATIC_LIBINSTALLDIR)
  519. @echo SharedLibInstallDir.. $(SHARED_LIBINSTALLDIR)
  520. @echo MsgInstallDir........ $(MSGINSTALLDIR)
  521. @echo DocInstallDir........ $(DOCINSTALLDIR)
  522. @echo
  523. # try to get the files in the currentdir
  524. PASFILES:=$(wildcard *.pas)
  525. PPFILES:=$(wildcard *.pp)
  526. INCFILES:=$(wildcard *.inc)
  527. MSGFILES:=$(wildcard *.msg)
  528. ASFILES:=$(wildcard *.as)
  529. filesinfo:
  530. @echo
  531. @echo == Files info ==
  532. @echo
  533. ifdef PASFILES
  534. @echo Pas files are $(PASFILES)
  535. endif
  536. ifdef PPFILES
  537. @echo PP files are $(PPFILES)
  538. endif
  539. ifdef INCFILES
  540. @echo Inc files are $(INCFILES)
  541. endif
  542. ifdef MSGFILES
  543. @echo Msg files are $(MSGFILES)
  544. endif
  545. ifdef ASFILES
  546. @echo As files are $(ASFILES)
  547. endif
  548. #
  549. # $Log$
  550. # Revision 1.2 1998-10-28 00:14:13 peter
  551. # * argh.. ifndef winnt -> ifdef winnt :(
  552. #
  553. # Revision 1.1 1998/10/27 14:23:59 peter
  554. # + makefiles
  555. #
  556. #