makefile 11 KB

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