home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / fpc / compiler / makefile < prev    next >
Encoding:
Makefile  |  1998-09-24  |  12.9 KB  |  550 lines

  1. #
  2. #   $Id: makefile,v 1.6.2.3 1998/08/06 14:27:26 pierre Exp $
  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. #####################################################################
  17. # Try to determine Operating System
  18. #####################################################################
  19.  
  20. BASEDIR=$(shell pwd)
  21.  
  22. # in linux no : in pathes
  23. ifeq ($(findstring :,$(BASEDIR)),)
  24. inlinux=1
  25. endif
  26.  
  27. # in case pwd is not present on the DOS-OS
  28. ifeq ($(strip $(BASEDIR)),'')
  29. inlinux=
  30. BASEDIR:=.
  31. endif
  32.  
  33. # What compiler to use
  34. ifndef PP
  35. PP=ppc386
  36. endif
  37.  
  38. #####################################################################
  39. # Setup Targets
  40. #####################################################################
  41.  
  42. # what target do we use
  43. # currently dos go32v2 os2 and linux are available
  44. ifdef inlinux
  45. TARGET=linux
  46. else
  47. TARGET=go32v2
  48. endif
  49.  
  50. # What processor do you want to compile for : i386 m68k (case sensitive !!)
  51. ifndef CPU
  52. CPU= i386
  53. # CPU= m68k
  54. endif
  55.  
  56. BUGFIX=YES
  57. export BUGFIX
  58.  
  59. #####################################################################
  60. # Setup Files Directories
  61. #####################################################################
  62.  
  63. # Set os-dependent files and extensions
  64. ifdef inlinux
  65. EXEEXT=
  66. REPLACE=mv -f
  67. CP=cp -f
  68. else
  69. EXEEXT=.exe
  70. REPLACE=move /y
  71. CP=cp -f
  72. endif
  73.  
  74. COMPILERDIR=$(BASEDIR)
  75. RTLDIR:=c:/pas/fpk/curver/rtl
  76.  
  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),dos)
  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.  
  90. # Where to install the executable program/link
  91. ifndef PROGINSTALLDIR
  92. ifdef inlinux
  93. PROGINSTALLDIR = /usr/bin
  94. else
  95. PROGINSTALLDIR = c:\pp\bin
  96. endif
  97. endif
  98.  
  99. # !!! Linux only
  100. # Where to install the _real_executable and support files
  101. ifndef LIBINSTALLDIR
  102. ifdef inlinux
  103. LIBINSTALLDIR=/usr/lib/fpc/0.99.5
  104. # for a.out
  105. # LIBINSTALLDIR=/usr/lib/ppc/aout/0.99.5
  106. else
  107. LIBINSTALLDIR=$(PROGINSTALLDIR)
  108. endif
  109. endif
  110.  
  111. # Where the .msg files will be stored
  112. ifndef MSGINSTALLDIR
  113. MSGINSTALLDIR=$(LIBINSTALLDIR)/msg
  114. endif
  115.  
  116. ifndef UNITINSTALLDIR
  117. ifdef inlinux
  118. UNITINSTALLDIR=$(LIBINSTALLDIR)/linuxunits
  119. else
  120. UNITINSTALLDIR=$(UNITDIR)
  121. endif
  122. endif
  123.  
  124. # !!! Linux only
  125. # GCCLIBPATH is wat is it on my PC... it MUST be set in the main Makefile
  126. ifndef GCCLIBPATH
  127. GCCLIBPATH=/usr/lib/gcc-lib/i486-linux/2.6.3
  128. endif
  129.  
  130. #####################################################################
  131. # When making diffs of the sources
  132. #####################################################################
  133.  
  134. # Diff program
  135. DIFF = diff
  136.  
  137. # Diff3 program
  138. DIFF3 = diff3
  139.  
  140. # Options to diff.
  141. DIFFOPTS = -b -c
  142.  
  143. # Directory where files are to make diffs with..
  144. ifdef inlinux
  145. DIFDIR = /usr/local/fpk/work/new/compiler
  146. else
  147. DIFDIR = h:/cvs/compiler
  148. endif
  149.  
  150. # Directory where reference files are for diff3
  151. ifdef inlinux
  152. REFDIR = /usr/local/fpk/dist/source/compiler
  153. else
  154. REFDIR = h:/myref/compiler
  155. endif
  156.  
  157. #####################################################################
  158. # End of configurable section. Do not edit after this line.
  159. #####################################################################
  160.  
  161. DIFFEXIST:=$(shell $(DIFF) --help)
  162.  
  163. # Used to avoid unnecessary steps in remake3
  164. ifdef DIFFEXIST
  165. ifdef OLDPP
  166. DIFFRESULT:=$(shell $(DIFF) $(OLDPP) $(PP))
  167. else
  168. DIFFRESULT=Not equal
  169. endif
  170. else
  171. DIFFRESULT=No diff program
  172. endif
  173.  
  174. # set correct defines (also needed by mkdep)
  175. PPDEFS:=-d$(CPU) -dGDB -dFPC
  176.  
  177. # Set the needed compiler options
  178. PPOPTS:=$(OPT) $(PPDEFS) -Sg
  179.  
  180. # Unitdir specified ?
  181. ifneq ("$(UNITDIR)", "")
  182. PPOPTS:=$(PPOPTS) -Up$(UNITDIR)
  183. endif
  184.  
  185. # Do we need the GCC library ?
  186. ifeq ($(LINK_TO_C),YES)
  187. PPOPTS:=$(PPOPTS) -Fg$(GCCLIBPATH)
  188. endif
  189.  
  190. # Create the whole compiler commandline
  191. COMPILER=$(PP) $(PPOPTS)
  192.  
  193. #####################################################################
  194. # Setup os-independent filenames
  195. #####################################################################
  196.  
  197. PPEXENAME=pp$(EXEEXT)
  198. EXENAME=ppc386$(EXEEXT)
  199. TEMPNAME=ppc$(EXEEXT)
  200. TEMPNAME1=ppc1$(EXEEXT)
  201. TEMPNAME2=ppc2$(EXEEXT)
  202. TEMPNAME3=ppc3$(EXEEXT)
  203. MAKEDEP=mkdep$(EXEEXT)
  204.  
  205. PASFILES:=$(shell ls *.pas)
  206. INCFILES:=$(shell ls *.inc)
  207. MSGFILES:=$(shell ls *.msg)
  208.  
  209. #####################################################################
  210. # Default makefile
  211. #####################################################################
  212.  
  213. .SUFFIXES: .pas $(EXEEXT) .ppu .dif .d3p .d3i .d3m .new
  214.  
  215. .PHONY : all clean info \
  216.      cycle remake remake3 \
  217.      install \
  218.      diff diff3 patch rtl toflor replacediff3 restorediff3 \
  219.      test rtlzip \
  220.  
  221. .pas.ppu:
  222.     $(COMPILER) $<
  223.  
  224. .pas$(EXEEXT):
  225.     $(COMPILER) $<
  226.  
  227. all : $(EXENAME)
  228.  
  229. ifndef DIFFRESULT
  230. next :
  231.     echo $(PP) and $(OLDPP)    are equal
  232.     $(CP) $(PP) $(EXENAME)
  233. else
  234. next :
  235.     $(MAKE) clean
  236.     $(MAKE) -C $(UNITDIR) clean
  237.     $(MAKE) -C $(UNITDIR) 'PP=$(COMPILERDIR)/$(PP)' all
  238.     $(MAKE) all
  239. endif
  240.  
  241. clean :
  242.     -rm -f *.o *.ppu *.s $(EXENAME)
  243.  
  244. #####################################################################
  245. # Info
  246. #####################################################################
  247.  
  248. info :
  249.     @echo - Target is $(TARGET)
  250.     @echo - Basedir is $(BASEDIR)
  251.     @echo - Pascal files are $(PASFILES)
  252.     @echo - Inc files are $(INCFILES)
  253.     @echo - Msg files are $(MSGFILES)
  254.  
  255. #####################################################################
  256. # Include depencies (linux only)
  257. #####################################################################
  258.  
  259. ifdef inlinux
  260. $(MAKEDEP) : $(RTLDIR)/utils/mkdep.pp
  261.     $(PP) $(RTLDIR)/utils/mkdep.pp
  262.     $(CP) $(RTLDIR)/utils/$(MAKEDEP) $(MAKEDEP)
  263.  
  264. dependencies : $(MAKEDEP)
  265.     $(MAKEDEP) pp.pas $(PPDEFS) '-A$$(COMPILER)' > depend
  266.  
  267. include depend
  268. endif
  269.  
  270. #####################################################################
  271. # Make targets
  272. #####################################################################
  273.  
  274. msgtxt.inc: errore.msg
  275.     msg2inc errore.msg msgtxt.inc msgtxt
  276.  
  277. optmsg.inc: optione.msg
  278.     msg2inc optione.msg optmsg.inc optiontxt
  279.  
  280. msg: msgtxt.inc optmsg.inc
  281.     
  282. # Make only the compiler
  283. ifdef inlinux
  284. $(EXENAME) : $(PPEXENAME)
  285.     $(COMPILER) pp.pas
  286.     $(REPLACE) $(PPEXENAME) $(EXENAME)
  287. else
  288. $(EXENAME) : $(PASFILES) $(INCFILES) $(MSGFILES)
  289.     $(COMPILER) pp.pas
  290.     $(REPLACE) $(PPEXENAME) $(EXENAME)
  291. endif
  292.  
  293. # This target remakes the units with the currently made version
  294. remake: $(EXENAME)
  295.     $(REPLACE) $(EXENAME) $(TEMPNAME)
  296.     $(MAKE) clean
  297.     $(MAKE) -C $(UNITDIR) clean
  298.     $(MAKE) -C $(UNITDIR) 'PP=$(COMPILERDIR)/$(TEMPNAME)' all
  299.     $(MAKE) 'PP=./$(TEMPNAME)' all
  300.  
  301. remake3: $(TEMPNAME3)
  302.     $(MAKE) 'PP=./$(TEMPNAME3)' 'OLDPP=./$(TEMPNAME2)' next
  303.     diff $(TEMPNAME3) $(EXENAME)
  304.  
  305. $(TEMPNAME1) : $(EXENAME)
  306.     $(REPLACE) $(EXENAME) $(TEMPNAME1)
  307.  
  308. $(TEMPNAME2) : $(TEMPNAME1)
  309.     $(MAKE) 'PP=./$(TEMPNAME1)' 'OLDPP=' next
  310.     $(REPLACE) $(EXENAME) $(TEMPNAME2)
  311.  
  312. $(TEMPNAME3) : $(TEMPNAME2)
  313.     $(MAKE) 'PP=./$(TEMPNAME2)' 'OLDPP=./$(TEMPNAME1)' next
  314.     $(REPLACE) $(EXENAME) $(TEMPNAME3)
  315.  
  316.  
  317. cycle:
  318.     $(MAKE) clean
  319.     $(MAKE) -C $(UNITDIR) clean
  320.     $(MAKE) -C $(UNITDIR)
  321.     $(MAKE) remake3
  322.  
  323. #####################################################################
  324. # Installation
  325. #####################################################################
  326.  
  327. install:
  328.     umask 022
  329.     strip ppc386
  330.     install -m 755 -d $(LIBINSTALLDIR)
  331.     install -m 755 ppc386 $(LIBINSTALLDIR)
  332.     ln -sf $(LIBINSTALLDIR)/ppc386 $(PROGINSTALLDIR)/ppc386
  333.     makecfg $(LIBINSTALLDIR)/samplecfg $(UNITINSTALLDIR) $(MSGINSTALLDIR) $(GCCLIBPATH)
  334.     install -m 755 -d $(MSGINSTALLDIR)
  335.     install -m 666 errore.msg $(MSGINSTALLDIR)
  336.     install -m 666 errorn.msg $(MSGINSTALLDIR)
  337.  
  338. #####################################################################
  339. # Diffs
  340. #####################################################################
  341.  
  342. SOURCEFILES = $(PASFILES) $(INCFILES) $(MSGFILES) Makefile
  343.  
  344. DIFFFILES = $(patsubst %.pas,%.dif,$(PASFILES)) \
  345.     $(patsubst %.inc,%.dif,$(INCFILES)) \
  346.     $(patsubst %.msg,%.dif,$(MSGFILES)) \
  347.     Makefile.dif
  348.  
  349. DIFF3FILES = $(patsubst %.pas,%.d3p,$(PASFILES)) \
  350.     $(patsubst %.inc,%.d3i,$(INCFILES)) \
  351.     $(patsubst %.msg,%.d3m,$(MSGFILES)) \
  352.     Makefile.di3
  353.  
  354. PATCHFILES = $(patsubst %.pas,%.new,$(PASFILES)) \
  355.     $(patsubst %.inc,%.new,$(INCFILES)) \
  356.     $(patsubst %.msg,%.new,$(MSGFILES)) \
  357.     Makefile.new
  358.  
  359. %.dif : %.pas
  360.     -$(DIFF) $(DIFFOPTS) $*.pas $(DIFDIR)/$*.pas   > $*.dif
  361.  
  362. %.dif : %.msg
  363.     -$(DIFF) $(DIFFOPTS) $*.msg $(DIFDIR)/$*.msg   > $*.dif
  364.  
  365. %.dif : %.inc
  366.     -$(DIFF) $(DIFFOPTS) $*.inc $(DIFDIR)/$*.inc   > $*.dif
  367.  
  368. Makefile.dif : Makefile
  369.     -$(DIFF) $(DIFFOPTS) Makefile $(DIFDIR)/Makefile   > Makefile.dif
  370.  
  371. %.new : %.pas %.dif
  372.     -copy /y $*.pas $*.new
  373.     -patch $*.new $*.dif
  374.  
  375. %.new : %.msg %.dif
  376.     -copy /y $*.msg $*.new
  377.     -patch $*.new $*.dif
  378.  
  379. %.new : %.inc %.dif
  380.     -copy /y $*.inc $*.new
  381.     -patch $*.new $*.dif
  382.  
  383. Makefile.new : Makefile Makefile.dif
  384.     -copy /y Makefile Makefile.new
  385.     -patch Makefile.new Makefile.dif
  386.  
  387. %.d3p : %.pas
  388.     -$(DIFF3) -m -E $*.pas $(REFDIR)/$*.pas $(DIFDIR)/$*.pas > $*.d3p
  389.  
  390. %.d3m : %.msg
  391.     -$(DIFF3) -m -E $*.msg $(REFDIR)/$*.msg $(DIFDIR)/$*.msg > $*.d3m
  392.  
  393. %.d3i : %.inc
  394.     -diff3 -m -E $*.inc $(REFDIR)/$*.inc $(DIFDIR)/$*.inc > $*.d3i
  395.  
  396. Makefile.di3: Makefile
  397.     -diff3 -m -E Makefile $(REFDIR)/Makefile $(DIFDIR)/Makefile > Makefile.di3
  398.  
  399. diff : $(DIFFFILES)
  400.  
  401. diff3 : $(DIFF3FILES)
  402.  
  403. replacediff3 : diff3
  404.     copy /y *.pas *.bkp
  405.     copy /y *.inc *.bki
  406.     copy /y *.msg *.bkm
  407.     copy /y Makefile Makefile.old
  408.     copy /y *.d3p *.pas
  409.     copy /y *.d3i *.inc
  410.     copy /y *.d3m *.msg
  411.     copy /y Makefile.di3 Makefile
  412.  
  413. restorediff3 :
  414.     copy /y *.bkp *.pas
  415.     copy /y *.bki *.inc
  416.     copy /y *.bkm *.msg
  417.     copy /y Makefile.old Makefile
  418.  
  419.  
  420. patch : $(PATCHFILES)
  421.  
  422. diffclean :
  423.     -del *.dif
  424.     -del *.di3
  425.     -del *.new
  426.  
  427. rtl :
  428.     make -C $(UNITDIR) all
  429.  
  430. rtlclean :
  431.     make -C $(UNITDIR) clean
  432.  
  433. ################################################
  434. ##  Just an easy way to handle the diffs
  435. ##  I just use the tiny program cpne.pp
  436. ##  that copy to directory toflor all .dif files
  437. ##  that are not empty
  438. ##  empty files are deleted
  439. ##  I did not find any direct way to do this !! (PM)
  440. #################################################
  441.  
  442. #########################
  443. # When    making zip files
  444. #########################
  445.  
  446. # Zip program
  447. ifdef inlinux
  448. ZIP = zip
  449. else
  450. ZIP = c:/pak/zip/zip386
  451. endif
  452.  
  453. # Unzip program
  454. ifdef inlinux
  455. UNZIP = unzp
  456. else
  457. UNZIP= c:/pak/zip/unzip
  458. endif
  459.  
  460. DIF=v97
  461.  
  462. toflor : diff
  463.     -rm toflor/*.dif
  464.     cpne *.dif toflor
  465.     cp Makefile toflor/Makefile
  466.     cp cpne.pp toflor/cpne.pp
  467.     cd toflor
  468.     zip dif2$(DIF) *.dif Makefile cpne.pp
  469.     cd ..
  470.  
  471. src_comp.zip : $(SOURCEFILES)
  472.     $(ZIP) -u src_comp $(SOURCEFILES)
  473.  
  474. #####################################################################
  475. # Distribution
  476. #####################################################################
  477.  
  478. dist :
  479.     mkdir $(DISTDIR)/compiler
  480.     cp *.pas *.inc makecfg Makefile depend errorE.msg $(DISTDIR)/compiler
  481.  
  482. #################################################
  483. # Obsolete
  484. # does not contains all directories
  485. #################################################
  486. rtlzip :
  487.     echo rtl\Makefile >rtl.cfg
  488.     echo rtl\readme >>rtl.cfg
  489.     echo rtl\cfg\Makefile >>rtl.cfg
  490.     echo rtl\cfg\readme >>rtl.cfg
  491.     echo rtl\cfg\*.cfg >>rtl.cfg
  492.     echo rtl\inc\Makefile >>rtl.cfg
  493.     echo rtl\inc\readme >>rtl.cfg
  494.     echo rtl\inc\*.pp >>rtl.cfg
  495.     echo rtl\inc\*.inc >>rtl.cfg
  496.     echo rtl\i386\Makefile >>rtl.cfg
  497.     echo rtl\i386\readme >>rtl.cfg
  498.     echo rtl\i386\*.pp >>rtl.cfg
  499.     echo rtl\i386\*.inc >>rtl.cfg
  500.     echo rtl\m68k\Makefile >>rtl.cfg
  501.     echo rtl\m68k\readme >>rtl.cfg
  502.     echo rtl\m68k\*.pp >>rtl.cfg
  503.     echo rtl\m68k\*.inc >>rtl.cfg
  504.     echo rtl\template\Makefile >>rtl.cfg
  505.     echo rtl\template\readme >>rtl.cfg
  506.     echo rtl\template\*.pp >>rtl.cfg
  507.     echo rtl\template\*.pas >>rtl.cfg
  508.     echo rtl\template\*.inc >>rtl.cfg
  509.     echo rtl\dos\Makefile >>rtl.cfg
  510.     echo rtl\dos\readme >>rtl.cfg
  511.     echo rtl\dos\*.pp >>rtl.cfg
  512.     echo rtl\dos\*.inc >>rtl.cfg
  513.     echo rtl\dos\ppi\Makefile >>rtl.cfg
  514.     echo rtl\dos\ppi\readme >>rtl.cfg
  515.     echo rtl\dos\ppi\*.ppi >>rtl.cfg
  516.     echo rtl\dos\go32v2\Makefile >>rtl.cfg
  517.     echo rtl\dos\go32v2\readme >>rtl.cfg
  518.     echo rtl\dos\go32v2\*.pp >>rtl.cfg
  519.     echo rtl\dos\go32v2\*.inc >>rtl.cfg
  520.     echo rtl\dos\go32v2\sbrk16.a* >>rtl.cfg
  521.     echo rtl\dos\go32v2\exit16.a* >>rtl.cfg
  522.     echo rtl\dos\go32v2\v2prt0.as >>rtl.cfg
  523.     echo rtl\dos\go32v2\exceptn.as >>rtl.cfg
  524.     echo rtl\dos\go32v1\Makefile >>rtl.cfg
  525.     echo rtl\dos\go32v1\readme >>rtl.cfg
  526.     echo rtl\dos\go32v1\*.pp >>rtl.cfg
  527.     echo rtl\dos\go32v1\*.inc >>rtl.cfg
  528.     echo rtl\dos\go32v1\prt0.as >>rtl.cfg
  529.     echo rtl\linux\Makefile >>rtl.cfg
  530.     echo rtl\linux\readme >>rtl.cfg
  531.     echo rtl\linux\*.pp >>rtl.cfg
  532.     echo rtl\linux\*.inc >>rtl.cfg
  533.     echo rtl\linux\prt*.as >>rtl.cfg
  534.     echo rtl\os2\Makefile >>rtl.cfg
  535.     echo rtl\os2\readme >>rtl.cfg
  536.     echo rtl\os2\*.pas >>rtl.cfg
  537.     echo rtl\os2\*.inc >>rtl.cfg
  538.     echo rtl\os2\*.imp >>rtl.cfg
  539.     echo rtl\os2\*.a >>rtl.cfg
  540.     echo rtl\os2\*.btm >>rtl.cfg
  541.     echo rtl\os2\*.cmd >>rtl.cfg
  542.     echo rtl\os2\prt*.as >>rtl.cfg
  543.     echo rtl\os2\dosini*.as >>rtl.cfg
  544.     echo rtl.cfg >>rtl.cfg
  545.     echo rtl.txt >>rtl.cfg
  546.     echo Makefile >>rtl.cfg
  547.     cd ..
  548.     $(ZIP) -u rtl @rtl.cfg
  549.     $(UNZIP) -v rtl >rtl.lst
  550.