makefile 12 KB

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