makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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. # Unitdir specified ?
  150. ifneq ("$(UNITDIR)", "")
  151. PPOPTS:=$(PPOPTS) -Up$(UNITDIR)
  152. endif
  153. # Do we need the GCC library ?
  154. ifeq ($(LINK_TO_C),YES)
  155. PPOPTS:=$(PPOPTS) -Fg$(GCCLIBPATH)
  156. endif
  157. # Create the whole compiler commandline
  158. COMPILER=$(PP) $(PPOPTS)
  159. #####################################################################
  160. # Setup os-independent filenames
  161. #####################################################################
  162. PPEXENAME=pp$(EXEEXT)
  163. EXENAME=ppc386$(EXEEXT)
  164. TEMPNAME=ppc$(EXEEXT)
  165. TEMPNAME1=ppc1$(EXEEXT)
  166. TEMPNAME2=ppc2$(EXEEXT)
  167. TEMPNAME3=ppc3$(EXEEXT)
  168. MAKEDEP=mkdep$(EXEEXT)
  169. PASFILES:=$(wildcard *.pas)
  170. INCFILES:=$(wildcard *.inc)
  171. MSGFILES:=$(wildcard *.msg)
  172. #####################################################################
  173. # Default makefile
  174. #####################################################################
  175. .SUFFIXES: .pas $(EXEEXT) .ppu .dif .d3p .d3i .d3m .new
  176. .PHONY : all clean info \
  177. cycle remake remake3 \
  178. install next \
  179. diff diff3 patch rtl toflor replacediff3 restorediff3 \
  180. test rtlzip rtlclean \
  181. .pas.ppu:
  182. $(COMPILER) $<
  183. .pas$(EXEEXT):
  184. $(COMPILER) $<
  185. all : $(EXENAME)
  186. ifndef DIFFRESULT
  187. next :
  188. @echo $(OLDPP) and $(PP) are equal
  189. $(CP) $(PP) $(EXENAME)
  190. else
  191. next :
  192. $(MAKE) clean
  193. $(MAKE) -C $(UNITDIR) clean
  194. $(MAKE) -C $(UNITDIR) 'PP=$(COMPILERDIR)/$(PP)' all
  195. $(MAKE) all
  196. endif
  197. clean :
  198. -rm -f *.o *.ppu *.s $(EXENAME)
  199. distclean: clean
  200. -rm -f $(TEMPNAME) $(TEMPNAME1) $(TEMPNAME2) $(TEMPNAME3)
  201. #####################################################################
  202. # Info
  203. #####################################################################
  204. info :
  205. @echo - Target is $(TARGET)
  206. @echo - Basedir is $(BASEDIR)
  207. @echo - Unitdir is $(UNITDIR)
  208. @echo - Pascal files are $(PASFILES)
  209. @echo - Inc files are $(INCFILES)
  210. @echo - Msg files are $(MSGFILES)
  211. #####################################################################
  212. # Include depencies (linux only)
  213. #####################################################################
  214. ifdef inlinux
  215. $(MAKEDEP) : $(RTLDIR)/utils/mkdep.pp
  216. $(PP) $(RTLDIR)/utils/mkdep.pp
  217. $(CP) $(RTLDIR)/utils/$(MAKEDEP) $(MAKEDEP)
  218. dependencies : $(MAKEDEP)
  219. $(MAKEDEP) pp.pas $(PPDEFS) '-F$$(COMPILER)' > depend
  220. include depend
  221. endif
  222. #####################################################################
  223. # Make targets
  224. #####################################################################
  225. msgtxt.inc: errore.msg
  226. msg2inc errore.msg msgtxt.inc msgtxt
  227. optmsg.inc: optione.msg
  228. msg2inc optione.msg optmsg.inc optiontxt
  229. msg: msgtxt.inc optmsg.inc
  230. # Make only the compiler
  231. ifdef inlinux
  232. $(EXENAME) : $(PPEXENAME)
  233. $(REPLACE) $(PPEXENAME) $(EXENAME)
  234. else
  235. $(EXENAME) : $(PASFILES) $(INCFILES) $(MSGFILES)
  236. $(COMPILER) pp.pas
  237. $(REPLACE) $(PPEXENAME) $(EXENAME)
  238. endif
  239. # This target remakes the units with the currently made version
  240. remake: $(EXENAME)
  241. $(REPLACE) $(EXENAME) $(TEMPNAME)
  242. $(MAKE) clean
  243. $(MAKE) -C $(UNITDIR) clean
  244. $(MAKE) -C $(UNITDIR) 'PP=$(COMPILERDIR)/$(TEMPNAME)' all
  245. $(MAKE) 'PP=./$(TEMPNAME)' all
  246. remake3: $(TEMPNAME3)
  247. $(MAKE) 'PP=./$(TEMPNAME3)' 'OLDPP=./$(TEMPNAME2)' next
  248. diff $(TEMPNAME3) $(EXENAME)
  249. $(TEMPNAME1) : $(EXENAME)
  250. -$(REMOVE) $(TEMPNAME1)
  251. $(REPLACE) $(EXENAME) $(TEMPNAME1)
  252. $(TEMPNAME2) : $(TEMPNAME1)
  253. $(MAKE) 'PP=./$(TEMPNAME1)' 'OLDPP=' next
  254. -$(REMOVE) $(TEMPNAME2)
  255. $(REPLACE) $(EXENAME) $(TEMPNAME2)
  256. $(TEMPNAME3) : $(TEMPNAME2)
  257. $(MAKE) 'PP=./$(TEMPNAME2)' 'OLDPP=./$(TEMPNAME1)' next
  258. -$(REMOVE) $(TEMPNAME3)
  259. $(REPLACE) $(EXENAME) $(TEMPNAME3)
  260. cycle:
  261. $(MAKE) clean
  262. $(MAKE) -C $(UNITDIR) clean
  263. $(MAKE) -C $(UNITDIR)
  264. $(MAKE) remake3
  265. ansirtl:
  266. $(MAKE) -C $(UNITDIR) clean
  267. $(MAKE) -C $(UNITDIR) PP=$(COMPILERDIR)/ppc386 \
  268. OPT='-g -dUSeAnsiStrings' all
  269. #####################################################################
  270. # Installation
  271. #####################################################################
  272. install:
  273. umask 022
  274. strip ppc386
  275. install -m 755 -d $(LIBINSTALLDIR)
  276. install -m 755 ppc386 $(LIBINSTALLDIR)
  277. ln -sf $(LIBINSTALLDIR)/ppc386 $(PROGINSTALLDIR)/ppc386
  278. -makecfg $(LIBINSTALLDIR)/samplecfg $(UNITINSTALLDIR) $(MSGINSTALLDIR) $(GCCLIBPATH)
  279. install -m 755 -d $(MSGINSTALLDIR)
  280. install -m 666 errore.msg $(MSGINSTALLDIR)
  281. install -m 666 errorn.msg $(MSGINSTALLDIR)
  282. #####################################################################
  283. # Diffs
  284. #####################################################################
  285. SOURCEFILES = $(PASFILES) $(INCFILES) $(MSGFILES) Makefile
  286. DIFFFILES = $(patsubst %.pas,%.dif,$(PASFILES)) \
  287. $(patsubst %.inc,%.dif,$(INCFILES)) \
  288. $(patsubst %.msg,%.dif,$(MSGFILES)) \
  289. Makefile.dif
  290. DIFF3FILES = $(patsubst %.pas,%.d3p,$(PASFILES)) \
  291. $(patsubst %.inc,%.d3i,$(INCFILES)) \
  292. $(patsubst %.msg,%.d3m,$(MSGFILES)) \
  293. Makefile.di3
  294. PATCHFILES = $(patsubst %.pas,%.new,$(PASFILES)) \
  295. $(patsubst %.inc,%.new,$(INCFILES)) \
  296. $(patsubst %.msg,%.new,$(MSGFILES)) \
  297. Makefile.new
  298. %.dif : %.pas
  299. -$(DIFF) $(DIFFOPTS) $*.pas $(DIFDIR)/$*.pas > $*.dif
  300. %.dif : %.msg
  301. -$(DIFF) $(DIFFOPTS) $*.msg $(DIFDIR)/$*.msg > $*.dif
  302. %.dif : %.inc
  303. -$(DIFF) $(DIFFOPTS) $*.inc $(DIFDIR)/$*.inc > $*.dif
  304. Makefile.dif : Makefile
  305. -$(DIFF) $(DIFFOPTS) Makefile $(DIFDIR)/Makefile > Makefile.dif
  306. %.new : %.pas %.dif
  307. -copy /y $*.pas $*.new
  308. -patch $*.new $*.dif
  309. %.new : %.msg %.dif
  310. -copy /y $*.msg $*.new
  311. -patch $*.new $*.dif
  312. %.new : %.inc %.dif
  313. -copy /y $*.inc $*.new
  314. -patch $*.new $*.dif
  315. Makefile.new : Makefile Makefile.dif
  316. -copy /y Makefile Makefile.new
  317. -patch Makefile.new Makefile.dif
  318. %.d3p : %.pas
  319. -$(DIFF3) -m -E $*.pas $(REFDIR)/$*.pas $(DIFDIR)/$*.pas > $*.d3p
  320. %.d3m : %.msg
  321. -$(DIFF3) -m -E $*.msg $(REFDIR)/$*.msg $(DIFDIR)/$*.msg > $*.d3m
  322. %.d3i : %.inc
  323. -diff3 -m -E $*.inc $(REFDIR)/$*.inc $(DIFDIR)/$*.inc > $*.d3i
  324. Makefile.di3: Makefile
  325. -diff3 -m -E Makefile $(REFDIR)/Makefile $(DIFDIR)/Makefile > Makefile.di3
  326. diff : $(DIFFFILES)
  327. diff3 : $(DIFF3FILES)
  328. replacediff3 : diff3
  329. copy /y *.pas *.bkp
  330. copy /y *.inc *.bki
  331. copy /y *.msg *.bkm
  332. copy /y Makefile Makefile.old
  333. copy /y *.d3p *.pas
  334. copy /y *.d3i *.inc
  335. copy /y *.d3m *.msg
  336. copy /y Makefile.di3 Makefile
  337. restorediff3 :
  338. copy /y *.bkp *.pas
  339. copy /y *.bki *.inc
  340. copy /y *.bkm *.msg
  341. copy /y Makefile.old Makefile
  342. patch : $(PATCHFILES)
  343. diffclean :
  344. -del *.dif
  345. -del *.d3*
  346. -del *.new
  347. rtl :
  348. make -C $(UNITDIR) all
  349. rtlclean :
  350. make -C $(UNITDIR) clean
  351. # Test of log at the end
  352. # does CVS add # at start of each line ??
  353. # $Log$
  354. # Revision 1.25 1998-08-18 09:24:41 pierre
  355. # * small warning position bug fixed
  356. # * support_mmx switches splitting was missing
  357. # * rhide error and warning output corrected
  358. #
  359. # Revision 1.24 1998/08/14 09:29:53 michael
  360. # Updated compiler number
  361. #
  362. # Revision 1.23 1998/08/06 10:42:56 pierre
  363. # + faster remake3 :
  364. # stops when two executables are equal
  365. #
  366. # Revision 1.22 1998/07/23 18:17:58 michael
  367. # + Added ansirtl target to make an ansistrings capable rtl
  368. #
  369. # Revision 1.21 1998/07/22 21:33:32 michael
  370. # + COPY and Replace back to mv and cp
  371. #
  372. # Revision 1.20 1998/06/24 14:02:58 peter
  373. # * new depend for the new ra units
  374. #
  375. # Revision 1.19 1998/06/23 14:00:15 peter
  376. # * renamed RA* units
  377. #
  378. # Revision 1.18 1998/06/10 10:42:44 peter
  379. # * ifndef TARGET to allow target on commandline
  380. #
  381. # Revision 1.17 1998/06/08 09:22:02 michael
  382. # fixed dependcies and rules. Make would not run any more after peters changes.
  383. #
  384. # Revision 1.16 1998/06/05 14:37:28 pierre
  385. # * fixes for inline for operators
  386. # * inline procedure more correctly restricted
  387. #
  388. # Revision 1.15 1998/06/03 09:33:39 michael
  389. # added distclean target to remove ppc1-ppc3 too
  390. #
  391. # Revision 1.14 1998/06/03 09:27:51 michael
  392. # Clean cannot remove ppc1-ppc3 : make cycle uses clean
  393. #
  394. # Revision 1.13 1998/06/02 11:29:36 peter
  395. # + make clean removes also ppc1 - ppc3
  396. #
  397. # Revision 1.12 1998/05/31 14:09:45 peter
  398. # * use mv -f instead of move /y whch is not dos6.2 compatible
  399. #
  400. # Revision 1.11 1998/05/06 14:03:27 michael
  401. # + Make install doesn't stop if makecfg not found
  402. #
  403. # Revision 1.10 1998/04/23 13:21:46 michael
  404. # Updated version number
  405. #
  406. # Revision 1.9 1998/04/15 14:16:48 michael
  407. # + Removed CR characters
  408. #
  409. # Revision 1.8 1998/04/06 12:28:23 pierre
  410. # Test of makefile log !
  411. #
  412. # End of log