makefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. #
  2. # $Id$
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1993-98 by the Free Pascal Development Team
  5. #
  6. # Makefile for the Free Pascal Compiler
  7. #
  8. # See the file COPYING.FPC, included in this distribution,
  9. # for details about the copyright.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. #
  15. #####################################################################
  16. # Try to determine Operating System
  17. #####################################################################
  18. BASEDIR=$(shell pwd)
  19. # in linux no : in pathes
  20. ifeq ($(findstring :,$(BASEDIR)),)
  21. inlinux=1
  22. endif
  23. # in case pwd is not present on the DOS-OS
  24. ifeq ($(strip $(BASEDIR)),'')
  25. inlinux=
  26. BASEDIR:=.
  27. endif
  28. # What compiler to use
  29. ifndef PP
  30. PP=ppc386
  31. endif
  32. # first try go32v2 specific gdate
  33. DATE=$(strip $(wildcard $(addsuffix /gdate.exe,$(subst ;, ,$(PATH)))))
  34. # try generic date.exe
  35. ifeq ($(DATE),)
  36. DATE=$(strip $(wildcard $(addsuffix /date.exe,$(subst :, ,$(PATH)))))
  37. endif
  38. # finally try for linux
  39. ifeq ($(DATE),)
  40. DATE=$(strip $(wildcard $(addsuffix /date,$(subst :, ,$(PATH)))))
  41. endif
  42. #####################################################################
  43. # Setup Targets
  44. #####################################################################
  45. # what target do we use
  46. # currently dos go32v2 os2 and linux are available
  47. ifndef TARGET
  48. ifdef inlinux
  49. TARGET=linux
  50. else
  51. TARGET=go32v2
  52. endif
  53. endif
  54. # What processor do you want to compile for : i386 m68k (case sensitive !!)
  55. ifndef CPU
  56. CPU= i386
  57. # CPU= m68k
  58. endif
  59. ifndef LANGUAGE
  60. LANGUAGE=e
  61. endif
  62. #####################################################################
  63. # Setup Files Directories
  64. #####################################################################
  65. # Set os-dependent files and extensions
  66. ifdef inlinux
  67. EXEEXT=
  68. else
  69. EXEEXT=.exe
  70. endif
  71. REPLACE=mv -f
  72. REMOVE=rm
  73. CP=cp -f
  74. MSGFILE=error$(LANGUAGE).msg
  75. COMPILERDIR=$(BASEDIR)
  76. RTLDIR:=$(BASEDIR)/../rtl
  77. # specify where units are.
  78. # This needs to be set correctly for the 'remake' target to work !
  79. ifndef UNITDIR
  80. UNITDIR=$(RTLDIR)/$(TARGET)
  81. ifeq ($(TARGET),go32v1)
  82. UNITDIR=$(RTLDIR)/dos/go32v1
  83. endif
  84. ifeq ($(TARGET),go32v2)
  85. UNITDIR=$(RTLDIR)/dos/go32v2
  86. endif
  87. endif
  88. # not def UNITDIR
  89. # Where to install the executable program/link
  90. ifndef PROGINSTALLDIR
  91. ifdef inlinux
  92. PROGINSTALLDIR = /usr/bin
  93. else
  94. PROGINSTALLDIR = c:\pp\bin
  95. endif
  96. endif
  97. # !!! Linux only
  98. # Where to install the _real_executable and support files
  99. ifndef LIBINSTALLDIR
  100. ifdef inlinux
  101. LIBINSTALLDIR=/usr/lib/fpc/0.99.7
  102. # for a.out
  103. # LIBINSTALLDIR=/usr/lib/ppc/aout/0.99.7
  104. else
  105. LIBINSTALLDIR=$(PROGINSTALLDIR)
  106. endif
  107. endif
  108. # Where the .msg files will be stored
  109. ifndef MSGINSTALLDIR
  110. MSGINSTALLDIR=$(LIBINSTALLDIR)/msg
  111. endif
  112. ifndef UNITINSTALLDIR
  113. ifdef inlinux
  114. UNITINSTALLDIR=$(LIBINSTALLDIR)/linuxunits
  115. else
  116. UNITINSTALLDIR=$(UNITDIR)
  117. endif
  118. endif
  119. # !!! Linux only
  120. # GCCLIBPATH is wat is it on my PC... it MUST be set in the main Makefile
  121. ifndef GCCLIBPATH
  122. GCCLIBPATH=/usr/lib/gcc-lib/i486-linux/2.6.3
  123. endif
  124. #####################################################################
  125. # When making diffs of the sources
  126. #####################################################################
  127. # Diff program
  128. DIFF = diff
  129. # Diff3 program
  130. DIFF3 = diff3
  131. # Options to diff.
  132. DIFFOPTS = -b -c
  133. # Directory where files are to make diffs with..
  134. ifdef inlinux
  135. DIFDIR = /usr/local/fpk/work/new/compiler
  136. else
  137. DIFDIR = h:/cvs/compiler
  138. endif
  139. # Directory where reference files are for diff3
  140. ifdef inlinux
  141. REFDIR = /usr/local/fpk/dist/source/compiler
  142. else
  143. REFDIR = h:/myref/compiler
  144. endif
  145. #####################################################################
  146. # End of configurable section. Do not edit after this line.
  147. #####################################################################
  148. DIFFEXIST:=$(shell $(DIFF) --help)
  149. # Used to avoid unnecessary steps in remake3
  150. ifdef DIFFEXIST
  151. ifdef OLDPP
  152. DIFFRESULT:=$(shell $(DIFF) $(OLDPP) $(PP))
  153. else
  154. DIFFRESULT=Not equal
  155. endif
  156. else
  157. DIFFRESULT=No diff program
  158. endif
  159. # set correct defines (also needed by mkdep)
  160. PPDEFS:=-d$(CPU) -dGDB -dFPC
  161. # Set the needed compiler options
  162. PPOPTS:=$(OPT) $(LOCALOPT) $(PPDEFS) -Sg -T$(TARGET)
  163. # for win32 create at least 8 mb heap
  164. ifdef Win32
  165. PPOPTS:=$(PPOPTS) -Ch8000000
  166. endif
  167. # Unitdir specified ?
  168. ifneq ("$(UNITDIR)", "")
  169. PPOPTS:=$(PPOPTS) -Up$(UNITDIR)
  170. endif
  171. # Do we need the GCC library ?
  172. ifeq ($(LINK_TO_C),YES)
  173. PPOPTS:=$(PPOPTS) -Fg$(GCCLIBPATH)
  174. endif
  175. # Create the whole compiler commandline
  176. COMPILER=$(PP) $(PPOPTS)
  177. #####################################################################
  178. # Setup os-independent filenames
  179. #####################################################################
  180. PPEXENAME=pp$(EXEEXT)
  181. EXENAME=ppc386$(EXEEXT)
  182. M68KEXENAME=ppc68k$(EXEEXT)
  183. TEMPNAME=ppc$(EXEEXT)
  184. TEMPNAME1=ppc1$(EXEEXT)
  185. TEMPNAME2=ppc2$(EXEEXT)
  186. TEMPNAME3=ppc3$(EXEEXT)
  187. MAKEDEP=mkdep$(EXEEXT)
  188. PASFILES:=$(wildcard *.pas)
  189. INCFILES:=$(wildcard *.inc)
  190. MSGFILES:=$(wildcard *.msg)
  191. #####################################################################
  192. # Default makefile
  193. #####################################################################
  194. .SUFFIXES: .pas $(EXEEXT) .ppu .dif .d3p .d3i .d3m .new
  195. .PHONY : all clean info \
  196. cycle remake remake3 \
  197. install next \
  198. diff diff3 patch rtl toflor replacediff3 restorediff3 \
  199. test rtlzip rtlclean \
  200. # also call ppas if with command option -s
  201. ifeq (,$(findstring -s ,$(COMPILER)))
  202. EXECPPAS=
  203. else
  204. EXECPPAS=@ppas
  205. endif
  206. .pas.ppu:
  207. $(COMPILER) $<
  208. $(EXECPPAS)
  209. .pas$(EXEEXT):
  210. $(COMPILER) $<
  211. $(EXECPPAS)
  212. all : $(EXENAME)
  213. # @echo Start $(STARTTIME) now $(ENDTIME)
  214. # does not work because $(ENDTIME) is expanded
  215. # before execution !!
  216. $(MAKE) echotime
  217. ifeq ($(MAKELEVEL),0)
  218. ifndef STARTTIME
  219. STARTTIME:=$(shell $(DATE) +%T)
  220. endif
  221. endif
  222. export STARTTIME
  223. ENDTIME=$(shell $(DATE) +%T)
  224. echotime:
  225. @echo Start $(STARTTIME) now $(ENDTIME)
  226. ifndef DIFFRESULT
  227. next :
  228. @echo $(OLDPP) and $(PP) are equal
  229. $(CP) $(PP) $(EXENAME)
  230. else
  231. next :
  232. $(MAKE) clean
  233. $(MAKE) -C $(UNITDIR) clean
  234. $(MAKE) -C $(UNITDIR) 'PP=$(COMPILERDIR)/$(PP)' all
  235. $(MAKE) all
  236. endif
  237. clean :
  238. -rm -f *.o *.ppu *.ppw *.s $(EXENAME)
  239. distclean: clean
  240. -rm -f $(TEMPNAME) $(TEMPNAME1) $(TEMPNAME2) $(TEMPNAME3)
  241. #####################################################################
  242. # Info
  243. #####################################################################
  244. info :
  245. @echo Target is $(TARGET)
  246. @echo Basedir is $(BASEDIR)
  247. @echo Unitdir is $(UNITDIR)
  248. @echo Compiler is $(COMPILER)
  249. @echo Execppas is $(EXECPPAS)
  250. @echo Pascal files are $(PASFILES)
  251. @echo Inc files are $(INCFILES)
  252. @echo Msg files are $(MSGFILES)
  253. #####################################################################
  254. # Include depencies (linux only)
  255. #####################################################################
  256. ifdef inlinux
  257. $(MAKEDEP) : $(RTLDIR)/utils/mkdep.pp
  258. $(PP) $(RTLDIR)/utils/mkdep.pp
  259. $(CP) $(RTLDIR)/utils/$(MAKEDEP) $(MAKEDEP)
  260. dependencies : $(MAKEDEP)
  261. $(MAKEDEP) pp.pas $(PPDEFS) '-F$$(COMPILER)' > depend
  262. include depend
  263. endif
  264. #####################################################################
  265. # Make targets
  266. #####################################################################
  267. msgtxt.inc: $(MSGFILE)
  268. msg2inc $(MSGFILE) msg msg
  269. msg: msgtxt.inc
  270. # Make only the compiler
  271. ifdef inlinux
  272. $(EXENAME) : $(PPEXENAME)
  273. $(EXECPPAS)
  274. $(REPLACE) $(PPEXENAME) $(EXENAME)
  275. else
  276. $(EXENAME) : $(PASFILES) $(INCFILES) $(MSGFILES)
  277. $(COMPILER) pp.pas
  278. $(EXECPPAS)
  279. $(REPLACE) $(PPEXENAME) $(EXENAME)
  280. endif
  281. # This target remakes the units with the currently made version
  282. remake: $(EXENAME)
  283. $(REPLACE) $(EXENAME) $(TEMPNAME)
  284. $(MAKE) clean
  285. $(MAKE) -C $(UNITDIR) clean
  286. $(MAKE) -C $(UNITDIR) 'PP=$(COMPILERDIR)/$(TEMPNAME)' all
  287. $(MAKE) 'PP=./$(TEMPNAME)' all
  288. remake3: $(TEMPNAME3)
  289. $(MAKE) 'PP=./$(TEMPNAME3)' 'OLDPP=./$(TEMPNAME2)' next
  290. diff $(TEMPNAME3) $(EXENAME)
  291. $(TEMPNAME1) : $(EXENAME)
  292. -$(REMOVE) $(TEMPNAME1)
  293. $(REPLACE) $(EXENAME) $(TEMPNAME1)
  294. $(TEMPNAME2) : $(TEMPNAME1)
  295. $(MAKE) 'PP=./$(TEMPNAME1)' 'OLDPP=' next
  296. -$(REMOVE) $(TEMPNAME2)
  297. $(REPLACE) $(EXENAME) $(TEMPNAME2)
  298. $(TEMPNAME3) : $(TEMPNAME2)
  299. $(MAKE) 'PP=./$(TEMPNAME2)' 'OLDPP=./$(TEMPNAME1)' next
  300. -$(REMOVE) $(TEMPNAME3)
  301. $(REPLACE) $(EXENAME) $(TEMPNAME3)
  302. cycle:
  303. $(MAKE) clean
  304. $(MAKE) -C $(UNITDIR) clean
  305. $(MAKE) -C $(UNITDIR)
  306. $(MAKE) remake3
  307. $(MAKE) echotime
  308. ansirtl:
  309. $(MAKE) -C $(UNITDIR) clean
  310. $(MAKE) -C $(UNITDIR) PP=$(COMPILERDIR)/ppc386 \
  311. OPT='-g -dUSeAnsiStrings' all
  312. #####################################################################
  313. # Installation
  314. #####################################################################
  315. install:
  316. umask 022
  317. strip ppc386
  318. install -m 755 -d $(LIBINSTALLDIR)
  319. install -m 755 ppc386 $(LIBINSTALLDIR)
  320. ln -sf $(LIBINSTALLDIR)/ppc386 $(PROGINSTALLDIR)/ppc386
  321. -makecfg $(LIBINSTALLDIR)/samplecfg $(UNITINSTALLDIR) $(MSGINSTALLDIR) $(GCCLIBPATH)
  322. install -m 755 -d $(MSGINSTALLDIR)
  323. install -m 666 errore.msg $(MSGINSTALLDIR)
  324. install -m 666 errorn.msg $(MSGINSTALLDIR)
  325. #####################################################################
  326. # Diffs
  327. #####################################################################
  328. SOURCEFILES = $(PASFILES) $(INCFILES) $(MSGFILES) Makefile
  329. DIFFFILES = $(patsubst %.pas,%.dif,$(PASFILES)) \
  330. $(patsubst %.inc,%.dif,$(INCFILES)) \
  331. $(patsubst %.msg,%.dif,$(MSGFILES)) \
  332. Makefile.dif
  333. DIFF3FILES = $(patsubst %.pas,%.d3p,$(PASFILES)) \
  334. $(patsubst %.inc,%.d3i,$(INCFILES)) \
  335. $(patsubst %.msg,%.d3m,$(MSGFILES)) \
  336. Makefile.di3
  337. PATCHFILES = $(patsubst %.pas,%.new,$(PASFILES)) \
  338. $(patsubst %.inc,%.new,$(INCFILES)) \
  339. $(patsubst %.msg,%.new,$(MSGFILES)) \
  340. Makefile.new
  341. %.dif : %.pas
  342. -$(DIFF) $(DIFFOPTS) $*.pas $(DIFDIR)/$*.pas > $*.dif
  343. %.dif : %.msg
  344. -$(DIFF) $(DIFFOPTS) $*.msg $(DIFDIR)/$*.msg > $*.dif
  345. %.dif : %.inc
  346. -$(DIFF) $(DIFFOPTS) $*.inc $(DIFDIR)/$*.inc > $*.dif
  347. Makefile.dif : Makefile
  348. -$(DIFF) $(DIFFOPTS) Makefile $(DIFDIR)/Makefile > Makefile.dif
  349. %.new : %.pas %.dif
  350. -copy /y $*.pas $*.new
  351. -patch $*.new $*.dif
  352. %.new : %.msg %.dif
  353. -copy /y $*.msg $*.new
  354. -patch $*.new $*.dif
  355. %.new : %.inc %.dif
  356. -copy /y $*.inc $*.new
  357. -patch $*.new $*.dif
  358. Makefile.new : Makefile Makefile.dif
  359. -copy /y Makefile Makefile.new
  360. -patch Makefile.new Makefile.dif
  361. %.d3p : %.pas
  362. -$(DIFF3) -m -E $*.pas $(REFDIR)/$*.pas $(DIFDIR)/$*.pas > $*.d3p
  363. %.d3m : %.msg
  364. -$(DIFF3) -m -E $*.msg $(REFDIR)/$*.msg $(DIFDIR)/$*.msg > $*.d3m
  365. %.d3i : %.inc
  366. -diff3 -m -E $*.inc $(REFDIR)/$*.inc $(DIFDIR)/$*.inc > $*.d3i
  367. Makefile.di3: Makefile
  368. -diff3 -m -E Makefile $(REFDIR)/Makefile $(DIFDIR)/Makefile > Makefile.di3
  369. diff : $(DIFFFILES)
  370. diff3 : $(DIFF3FILES)
  371. replacediff3 : diff3
  372. copy /y *.pas *.bkp
  373. copy /y *.inc *.bki
  374. copy /y *.msg *.bkm
  375. copy /y Makefile Makefile.old
  376. copy /y *.d3p *.pas
  377. copy /y *.d3i *.inc
  378. copy /y *.d3m *.msg
  379. copy /y Makefile.di3 Makefile
  380. restorediff3 :
  381. copy /y *.bkp *.pas
  382. copy /y *.bki *.inc
  383. copy /y *.bkm *.msg
  384. copy /y Makefile.old Makefile
  385. patch : $(PATCHFILES)
  386. diffclean :
  387. -del *.dif
  388. -del *.d3*
  389. -del *.new
  390. rtl :
  391. $(MAKE) -C $(UNITDIR) all
  392. rtlclean :
  393. $(MAKE) -C $(UNITDIR) clean
  394. # just a quick way to get ppc68k
  395. $(M68KEXENAME):
  396. $(MAKE) clean
  397. $(PP) -uI386 -uSUPPORT_MMX -dm68k -o$(M68KEXENAME) pp
  398. $(MAKE) clean
  399. test:
  400. @echo time is $(STARTTIME) date.exe is $(DATE)
  401. # Test of log at the end
  402. # does CVS add # at start of each line ??
  403. # $Log$
  404. # Revision 1.29 1998-09-02 08:51:30 pierre
  405. # + added -s support must be defined as LOCALOPT
  406. # because it does not work for rtl building
  407. # + added some compilation time info
  408. #
  409. # Revision 1.28 1998/08/29 13:52:30 peter
  410. # + new messagefile
  411. # * merged optione.msg into errore.msg
  412. #
  413. # Revision 1.27 1998/08/21 15:16:56 peter
  414. # * win32 compiles a bit better, no growheap crash
  415. #
  416. # Revision 1.26 1998/08/21 14:08:46 pierre
  417. # + TEST_FUNCRET now default (old code removed)
  418. # works also for m68k (at least compiles)
  419. #
  420. # Revision 1.25 1998/08/18 09:24:41 pierre
  421. # * small warning position bug fixed
  422. # * support_mmx switches splitting was missing
  423. # * rhide error and warning output corrected
  424. #
  425. # Revision 1.24 1998/08/14 09:29:53 michael
  426. # Updated compiler number
  427. #
  428. # Revision 1.23 1998/08/06 10:42:56 pierre
  429. # + faster remake3 :
  430. # stops when two executables are equal
  431. #
  432. # Revision 1.22 1998/07/23 18:17:58 michael
  433. # + Added ansirtl target to make an ansistrings capable rtl
  434. #
  435. # Revision 1.21 1998/07/22 21:33:32 michael
  436. # + COPY and Replace back to mv and cp
  437. #
  438. # Revision 1.20 1998/06/24 14:02:58 peter
  439. # * new depend for the new ra units
  440. #
  441. # Revision 1.19 1998/06/23 14:00:15 peter
  442. # * renamed RA* units
  443. #
  444. # Revision 1.18 1998/06/10 10:42:44 peter
  445. # * ifndef TARGET to allow target on commandline
  446. #
  447. # Revision 1.17 1998/06/08 09:22:02 michael
  448. # fixed dependcies and rules. Make would not run any more after peters changes.
  449. #
  450. # Revision 1.16 1998/06/05 14:37:28 pierre
  451. # * fixes for inline for operators
  452. # * inline procedure more correctly restricted
  453. #
  454. # Revision 1.15 1998/06/03 09:33:39 michael
  455. # added distclean target to remove ppc1-ppc3 too
  456. #
  457. # Revision 1.14 1998/06/03 09:27:51 michael
  458. # Clean cannot remove ppc1-ppc3 : make cycle uses clean
  459. #
  460. # Revision 1.13 1998/06/02 11:29:36 peter
  461. # + make clean removes also ppc1 - ppc3
  462. #
  463. # Revision 1.12 1998/05/31 14:09:45 peter
  464. # * use mv -f instead of move /y whch is not dos6.2 compatible
  465. #
  466. # Revision 1.11 1998/05/06 14:03:27 michael
  467. # + Make install doesn't stop if makecfg not found
  468. #
  469. # Revision 1.10 1998/04/23 13:21:46 michael
  470. # Updated version number
  471. #
  472. # Revision 1.9 1998/04/15 14:16:48 michael
  473. # + Removed CR characters
  474. #
  475. # Revision 1.8 1998/04/06 12:28:23 pierre
  476. # Test of makefile log !
  477. #
  478. # End of log