makefile 12 KB

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