makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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. undef 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. ifdef inlinux
  38. TARGET=linux
  39. else
  40. TARGET=go32v2
  41. endif
  42. # What processor do you want to compile for : i386 m68k (case sensitive !!)
  43. ifndef CPU
  44. CPU= i386
  45. # CPU= m68k
  46. endif
  47. #####################################################################
  48. # Setup Files Directories
  49. #####################################################################
  50. # Set os-dependent files and extensions
  51. ifdef inlinux
  52. EXEEXT=
  53. REPLACE=mv -f
  54. CP=cp -f
  55. else
  56. EXEEXT=.exe
  57. REPLACE=move /y
  58. CP=cp -f
  59. endif
  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),dos)
  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.0
  87. # for a.out
  88. # LIBINSTALLDIR=/usr/lib/ppc/aout/0.99.0
  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. # set correct defines (also needed by mkdep)
  134. PPDEFS:=-d$(CPU) -dGDB -dFPC
  135. # Set the needed compiler options
  136. PPOPTS:=$(OPT) $(PPDEFS) -Sg
  137. # Unitdir specified ?
  138. ifneq ("$(UNITDIR)", "")
  139. PPOPTS:=$(PPOPTS) -Up$(UNITDIR)
  140. endif
  141. # Do we need the GCC library ?
  142. ifeq ($(LINK_TO_C),YES)
  143. PPOPTS:=$(PPOPTS) -Fg$(GCCLIBPATH)
  144. endif
  145. # Create the whole compiler commandline
  146. COMPILER=$(PP) $(PPOPTS)
  147. #####################################################################
  148. # Setup os-independent filenames
  149. #####################################################################
  150. PPEXENAME=pp$(EXEEXT)
  151. EXENAME=ppc386$(EXEEXT)
  152. TEMPNAME=ppc$(EXEEXT)
  153. TEMPNAME1=ppc1$(EXEEXT)
  154. TEMPNAME2=ppc2$(EXEEXT)
  155. TEMPNAME3=ppc3$(EXEEXT)
  156. MAKEDEP=mkdep$(EXEEXT)
  157. PASFILES:=$(shell ls *.pas)
  158. INCFILES:=$(shell ls *.inc)
  159. MSGFILES:=$(shell ls *.msg)
  160. #####################################################################
  161. # Default makefile
  162. #####################################################################
  163. .SUFFIXES: .pas $(EXEEXT) .ppu .dif .d3p .d3i .d3m .new
  164. .PHONY : all clean info \
  165. cycle remake remake3 \
  166. install \
  167. diff diff3 patch rtl toflor replacediff3 restorediff3 \
  168. test rtlzip \
  169. .pas.ppu:
  170. $(COMPILER) $<
  171. .pas$(EXEEXT):
  172. $(COMPILER) $<
  173. all : $(EXENAME)
  174. clean :
  175. -rm -f *.o *.ppu *.s $(EXENAME)
  176. #####################################################################
  177. # Info
  178. #####################################################################
  179. info :
  180. @echo - Target is $(TARGET)
  181. @echo - Basedir is $(BASEDIR)
  182. @echo - Pascal files are $(PASFILES)
  183. @echo - Inc files are $(INCFILES)
  184. @echo - Msg files are $(MSGFILES)
  185. #####################################################################
  186. # Include depencies (linux only)
  187. #####################################################################
  188. ifdef inlinux
  189. $(MAKEDEP) : $(RTLDIR)/utils/mkdep.pp
  190. $(PP) $(RTLDIR)/utils/mkdep.pp
  191. $(CP) $(RTLDIR)/utils/$(MAKEDEP) $(MAKEDEP)
  192. dependencies : $(MAKEDEP)
  193. $(MAKEDEP) pp.pas $(PPDEFS) '-A$$(COMPILER)' > depend
  194. include depend
  195. endif
  196. #####################################################################
  197. # Make targets
  198. #####################################################################
  199. # Make only the compiler
  200. ifdef inlinux
  201. $(EXENAME) : $(PPEXENAME)
  202. $(COMPILER) pp.pas
  203. $(REPLACE) $(PPEXENAME) $(EXENAME)
  204. else
  205. $(EXENAME) : $(PASFILES) $(INCFILES) $(MSGFILES)
  206. $(COMPILER) pp.pas
  207. $(REPLACE) $(PPEXENAME) $(EXENAME)
  208. endif
  209. # This target remakes the units with the currently made version
  210. remake: $(EXENAME)
  211. $(REPLACE) $(EXENAME) $(TEMPNAME)
  212. $(MAKE) clean
  213. $(MAKE) -C $(UNITDIR) clean
  214. $(MAKE) -C $(UNITDIR) 'PP=$(COMPILERDIR)/$(TEMPNAME)' all
  215. $(MAKE) 'PP=./$(TEMPNAME)' all
  216. remake3: $(TEMPNAME3)
  217. $(MAKE) clean
  218. $(MAKE) -C $(UNITDIR) clean
  219. $(MAKE) -C $(UNITDIR) 'PP=$(COMPILERDIR)/$(TEMPNAME3)' all
  220. $(MAKE) 'PP=./$(TEMPNAME3)' all
  221. diff $(TEMPNAME3) $(EXENAME)
  222. $(TEMPNAME1) : $(EXENAME)
  223. $(REPLACE) $(EXENAME) $(TEMPNAME1)
  224. $(TEMPNAME2) : $(TEMPNAME1)
  225. $(MAKE) clean
  226. $(MAKE) -C $(UNITDIR) clean
  227. $(MAKE) -C $(UNITDIR) 'PP=$(COMPILERDIR)/$(TEMPNAME1)' all
  228. $(MAKE) 'PP=./$(TEMPNAME1)' all
  229. $(REPLACE) $(EXENAME) $(TEMPNAME2)
  230. $(TEMPNAME3) : $(TEMPNAME2)
  231. $(MAKE) clean
  232. $(MAKE) -C $(UNITDIR) clean
  233. $(MAKE) -C $(UNITDIR) 'PP=$(COMPILERDIR)/$(TEMPNAME2)' all
  234. $(MAKE) 'PP=./$(TEMPNAME2)' all
  235. $(REPLACE) $(EXENAME) $(TEMPNAME3)
  236. cycle:
  237. $(MAKE) clean
  238. $(MAKE) -C $(UNITDIR) clean
  239. $(MAKE) -C $(UNITDIR)
  240. $(MAKE) remake3
  241. #####################################################################
  242. # Installation
  243. #####################################################################
  244. install:
  245. umask 022
  246. strip ppc386
  247. install -m 755 -d $(LIBINSTALLDIR)
  248. install -m 755 ppc386 $(LIBINSTALLDIR)
  249. ln -sf $(LIBINSTALLDIR)/ppc386 $(PROGINSTALLDIR)/ppc386
  250. makecfg $(LIBINSTALLDIR)/samplecfg $(UNITINSTALLDIR) $(MSGINSTALLDIR) $(GCCLIBPATH)
  251. install -m 755 -d $(MSGINSTALLDIR)
  252. install -m 644 errore.msg $(MSGINSTALLDIR)
  253. install -m 644 errorn.msg $(MSGINSTALLDIR)
  254. #####################################################################
  255. # Diffs
  256. #####################################################################
  257. SOURCEFILES = $(PASFILES) $(INCFILES) $(MSGFILES) Makefile
  258. DIFFFILES = $(patsubst %.pas,%.dif,$(PASFILES)) \
  259. $(patsubst %.inc,%.dif,$(INCFILES)) \
  260. $(patsubst %.msg,%.dif,$(MSGFILES)) \
  261. Makefile.dif
  262. DIFF3FILES = $(patsubst %.pas,%.d3p,$(PASFILES)) \
  263. $(patsubst %.inc,%.d3i,$(INCFILES)) \
  264. $(patsubst %.msg,%.d3m,$(MSGFILES)) \
  265. Makefile.di3
  266. PATCHFILES = $(patsubst %.pas,%.new,$(PASFILES)) \
  267. $(patsubst %.inc,%.new,$(INCFILES)) \
  268. $(patsubst %.msg,%.new,$(MSGFILES)) \
  269. Makefile.new
  270. %.dif : %.pas
  271. -$(DIFF) $(DIFFOPTS) $*.pas $(DIFDIR)/$*.pas > $*.dif
  272. %.dif : %.msg
  273. -$(DIFF) $(DIFFOPTS) $*.msg $(DIFDIR)/$*.msg > $*.dif
  274. %.dif : %.inc
  275. -$(DIFF) $(DIFFOPTS) $*.inc $(DIFDIR)/$*.inc > $*.dif
  276. Makefile.dif : Makefile
  277. -$(DIFF) $(DIFFOPTS) Makefile $(DIFDIR)/Makefile > Makefile.dif
  278. %.new : %.pas %.dif
  279. -copy /y $*.pas $*.new
  280. -patch $*.new $*.dif
  281. %.new : %.msg %.dif
  282. -copy /y $*.msg $*.new
  283. -patch $*.new $*.dif
  284. %.new : %.inc %.dif
  285. -copy /y $*.inc $*.new
  286. -patch $*.new $*.dif
  287. Makefile.new : Makefile Makefile.dif
  288. -copy /y Makefile Makefile.new
  289. -patch Makefile.new Makefile.dif
  290. %.d3p : %.pas
  291. -$(DIFF3) -m -E $*.pas $(REFDIR)/$*.pas $(DIFDIR)/$*.pas > $*.d3p
  292. %.d3m : %.msg
  293. -$(DIFF3) -m -E $*.msg $(REFDIR)/$*.msg $(DIFDIR)/$*.msg > $*.d3m
  294. %.d3i : %.inc
  295. -diff3 -m -E $*.inc $(REFDIR)/$*.inc $(DIFDIR)/$*.inc > $*.d3i
  296. Makefile.di3: Makefile
  297. -diff3 -m -E Makefile $(REFDIR)/Makefile $(DIFDIR)/Makefile > Makefile.di3
  298. diff : $(DIFFFILES)
  299. diff3 : $(DIFF3FILES)
  300. replacediff3 : diff3
  301. copy /y *.pas *.bkp
  302. copy /y *.inc *.bki
  303. copy /y *.msg *.bkm
  304. copy /y Makefile Makefile.old
  305. copy /y *.d3p *.pas
  306. copy /y *.d3i *.inc
  307. copy /y *.d3m *.msg
  308. copy /y Makefile.di3 Makefile
  309. restorediff3 :
  310. copy /y *.bkp *.pas
  311. copy /y *.bki *.inc
  312. copy /y *.bkm *.msg
  313. copy /y Makefile.old Makefile
  314. patch : $(PATCHFILES)
  315. diffclean :
  316. -del *.dif
  317. -del *.di3
  318. -del *.new
  319. rtl :
  320. make -C $(UNITDIR) all
  321. rtlclean :
  322. make -C $(UNITDIR) clean
  323. ################################################
  324. ## Just an easy way to handle the diffs
  325. ## I just use the tiny program cpne.pp
  326. ## that copy to directory toflor all .dif files
  327. ## that are not empty
  328. ## empty files are deleted
  329. ## I did not find any direct way to do this !! (PM)
  330. #################################################
  331. #########################
  332. # When making zip files
  333. #########################
  334. # Zip program
  335. ifdef inlinux
  336. ZIP = zip
  337. else
  338. ZIP = c:/pak/zip/zip386
  339. endif
  340. # Unzip program
  341. ifdef inlinux
  342. UNZIP = unzp
  343. else
  344. UNZIP= c:/pak/zip/unzip
  345. endif
  346. DIF=v97
  347. toflor : diff
  348. -rm toflor/*.dif
  349. cpne *.dif toflor
  350. cp Makefile toflor/Makefile
  351. cp cpne.pp toflor/cpne.pp
  352. cd toflor
  353. zip dif2$(DIF) *.dif Makefile cpne.pp
  354. cd ..
  355. src_comp.zip : $(SOURCEFILES)
  356. $(ZIP) -u src_comp $(SOURCEFILES)
  357. #####################################################################
  358. # Distribution
  359. #####################################################################
  360. dist :
  361. mkdir $(DISTDIR)/compiler
  362. cp *.pas *.inc makecfg Makefile depend errorE.msg $(DISTDIR)/compiler
  363. #################################################
  364. # Obsolete
  365. # does not contains all directories
  366. #################################################
  367. rtlzip :
  368. echo rtl\Makefile >rtl.cfg
  369. echo rtl\readme >>rtl.cfg
  370. echo rtl\cfg\Makefile >>rtl.cfg
  371. echo rtl\cfg\readme >>rtl.cfg
  372. echo rtl\cfg\*.cfg >>rtl.cfg
  373. echo rtl\inc\Makefile >>rtl.cfg
  374. echo rtl\inc\readme >>rtl.cfg
  375. echo rtl\inc\*.pp >>rtl.cfg
  376. echo rtl\inc\*.inc >>rtl.cfg
  377. echo rtl\i386\Makefile >>rtl.cfg
  378. echo rtl\i386\readme >>rtl.cfg
  379. echo rtl\i386\*.pp >>rtl.cfg
  380. echo rtl\i386\*.inc >>rtl.cfg
  381. echo rtl\m68k\Makefile >>rtl.cfg
  382. echo rtl\m68k\readme >>rtl.cfg
  383. echo rtl\m68k\*.pp >>rtl.cfg
  384. echo rtl\m68k\*.inc >>rtl.cfg
  385. echo rtl\template\Makefile >>rtl.cfg
  386. echo rtl\template\readme >>rtl.cfg
  387. echo rtl\template\*.pp >>rtl.cfg
  388. echo rtl\template\*.pas >>rtl.cfg
  389. echo rtl\template\*.inc >>rtl.cfg
  390. echo rtl\dos\Makefile >>rtl.cfg
  391. echo rtl\dos\readme >>rtl.cfg
  392. echo rtl\dos\*.pp >>rtl.cfg
  393. echo rtl\dos\*.inc >>rtl.cfg
  394. echo rtl\dos\ppi\Makefile >>rtl.cfg
  395. echo rtl\dos\ppi\readme >>rtl.cfg
  396. echo rtl\dos\ppi\*.ppi >>rtl.cfg
  397. echo rtl\dos\go32v2\Makefile >>rtl.cfg
  398. echo rtl\dos\go32v2\readme >>rtl.cfg
  399. echo rtl\dos\go32v2\*.pp >>rtl.cfg
  400. echo rtl\dos\go32v2\*.inc >>rtl.cfg
  401. echo rtl\dos\go32v2\sbrk16.a* >>rtl.cfg
  402. echo rtl\dos\go32v2\exit16.a* >>rtl.cfg
  403. echo rtl\dos\go32v2\v2prt0.as >>rtl.cfg
  404. echo rtl\dos\go32v2\exceptn.as >>rtl.cfg
  405. echo rtl\dos\go32v1\Makefile >>rtl.cfg
  406. echo rtl\dos\go32v1\readme >>rtl.cfg
  407. echo rtl\dos\go32v1\*.pp >>rtl.cfg
  408. echo rtl\dos\go32v1\*.inc >>rtl.cfg
  409. echo rtl\dos\go32v1\prt0.as >>rtl.cfg
  410. echo rtl\linux\Makefile >>rtl.cfg
  411. echo rtl\linux\readme >>rtl.cfg
  412. echo rtl\linux\*.pp >>rtl.cfg
  413. echo rtl\linux\*.inc >>rtl.cfg
  414. echo rtl\linux\prt*.as >>rtl.cfg
  415. echo rtl\os2\Makefile >>rtl.cfg
  416. echo rtl\os2\readme >>rtl.cfg
  417. echo rtl\os2\*.pas >>rtl.cfg
  418. echo rtl\os2\*.inc >>rtl.cfg
  419. echo rtl\os2\*.imp >>rtl.cfg
  420. echo rtl\os2\*.a >>rtl.cfg
  421. echo rtl\os2\*.btm >>rtl.cfg
  422. echo rtl\os2\*.cmd >>rtl.cfg
  423. echo rtl\os2\prt*.as >>rtl.cfg
  424. echo rtl\os2\dosini*.as >>rtl.cfg
  425. echo rtl.cfg >>rtl.cfg
  426. echo rtl.txt >>rtl.cfg
  427. echo Makefile >>rtl.cfg
  428. cd ..
  429. $(ZIP) -u rtl @rtl.cfg
  430. $(UNZIP) -v rtl >rtl.lst