Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. #
  2. # Makefile generated by fpcmake v0.99.13 on 1999-12-13 13:02
  3. #
  4. defaultrule: info
  5. #####################################################################
  6. # Autodetect OS (Linux or Dos or Windows NT)
  7. # define inlinux when running under linux
  8. # define inWinNT when running under WinNT
  9. #####################################################################
  10. # We need only / in the path
  11. override PATH:=$(subst \,/,$(PATH))
  12. # Search for PWD and determine also if we are under linux
  13. PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
  14. ifeq ($(PWD),)
  15. PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
  16. ifeq ($(PWD),)
  17. nopwd:
  18. @echo You need the GNU utils package to use this Makefile!
  19. @echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
  20. @exit
  21. else
  22. inlinux=1
  23. endif
  24. else
  25. PWD:=$(firstword $(PWD))
  26. endif
  27. # Detect NT - NT sets OS to Windows_NT
  28. ifndef inlinux
  29. ifeq ($(OS),Windows_NT)
  30. inWinNT=1
  31. endif
  32. endif
  33. # Detect OS/2 - OS/2 has OS2_SHELL defined
  34. ifndef inlinux
  35. ifndef inWinNT
  36. ifdef OS2_SHELL
  37. inOS2=1
  38. endif
  39. endif
  40. endif
  41. # The extension of executables
  42. ifdef inlinux
  43. EXEEXT=
  44. else
  45. EXEEXT=.exe
  46. endif
  47. # The path which is search separated by spaces
  48. ifdef inlinux
  49. SEARCHPATH=$(subst :, ,$(PATH))
  50. else
  51. SEARCHPATH=$(subst ;, ,$(PATH))
  52. endif
  53. #####################################################################
  54. # FPC version/target Detection
  55. #####################################################################
  56. # What compiler to use ?
  57. ifndef FPC
  58. # Compatibility with old makefiles
  59. ifdef PP
  60. export FPC=$(PP)
  61. else
  62. ifdef inOS2
  63. export FPC=ppos2$(EXEEXT)
  64. else
  65. export FPC=ppc386$(EXEEXT)
  66. endif
  67. endif
  68. endif
  69. # Target OS
  70. ifndef OS_TARGET
  71. export OS_TARGET:=$(shell $(FPC) -iTO)
  72. endif
  73. # Source OS
  74. ifndef OS_SOURCE
  75. export OS_SOURCE:=$(shell $(FPC) -iSO)
  76. endif
  77. # Target CPU
  78. ifndef CPU_TARGET
  79. export CPU_TARGET:=$(shell $(FPC) -iTP)
  80. endif
  81. # Source CPU
  82. ifndef CPU_SOURCE
  83. export CPU_SOURCE:=$(shell $(FPC) -iSP)
  84. endif
  85. # FPC version
  86. ifndef FPC_VERSION
  87. export FPC_VERSION:=$(shell $(FPC) -iV)
  88. endif
  89. #####################################################################
  90. # Default Settings
  91. #####################################################################
  92. # Release ? Then force OPT and don't use extra opts via commandline
  93. ifndef REDIRFILE
  94. REDIRFILE=log
  95. endif
  96. ifdef RELEASE
  97. override OPT:=-Xs -OG2p3 -n
  98. endif
  99. # Verbose settings (warning,note,info)
  100. ifdef VERBOSE
  101. override OPT+=-vwni
  102. endif
  103. ifdef REDIR
  104. ifndef inlinux
  105. override FPC=redir -eo $(FPC)
  106. endif
  107. # set the verbosity to max
  108. override OPT+=-va
  109. override REDIR:= >> $(REDIRFILE)
  110. endif
  111. #####################################################################
  112. # User Settings
  113. #####################################################################
  114. # Targets
  115. # Clean
  116. # Install
  117. ZIPTARGET=install
  118. # Defaults
  119. # Directories
  120. ifndef PACKAGEDIR
  121. PACKAGEDIR=$(FPCDIR)/packages
  122. endif
  123. ifndef COMPONENTDIR
  124. COMPONENTDIR=$(FPCDIR)/components
  125. endif
  126. # Packages
  127. # Libraries
  128. #####################################################################
  129. # Default extensions
  130. #####################################################################
  131. # Default needed extensions (Go32v2,Linux)
  132. LOADEREXT=.as
  133. PPLEXT=.ppl
  134. PPUEXT=.ppu
  135. OEXT=.o
  136. ASMEXT=.s
  137. SMARTEXT=.sl
  138. STATICLIBEXT=.a
  139. SHAREDLIBEXT=.so
  140. PACKAGESUFFIX=
  141. # Go32v1
  142. ifeq ($(OS_TARGET),go32v1)
  143. PPUEXT=.pp1
  144. OEXT=.o1
  145. ASMEXT=.s1
  146. SMARTEXT=.sl1
  147. STATICLIBEXT=.a1
  148. SHAREDLIBEXT=.so1
  149. PACKAGESUFFIX=v1
  150. endif
  151. # Go32v2
  152. ifeq ($(OS_TARGET),go32v2)
  153. PACKAGESUFFIX=go32
  154. endif
  155. # Linux
  156. ifeq ($(OS_TARGET),linux)
  157. PACKAGESUFFIX=linux
  158. endif
  159. # Win32
  160. ifeq ($(OS_TARGET),win32)
  161. PPUEXT=.ppw
  162. OEXT=.ow
  163. ASMEXT=.sw
  164. SMARTEXT=.slw
  165. STATICLIBEXT=.aw
  166. SHAREDLIBEXT=.dll
  167. PACKAGESUFFIX=win32
  168. endif
  169. # OS/2
  170. ifeq ($(OS_TARGET),os2)
  171. PPUEXT=.ppo
  172. ASMEXT=.so2
  173. OEXT=.oo2
  174. SMARTEXT=.so
  175. STATICLIBEXT=.ao2
  176. SHAREDLIBEXT=.dll
  177. PACKAGESUFFIX=os2
  178. endif
  179. # library prefix
  180. LIBPREFIX=lib
  181. ifeq ($(OS_TARGET),go32v2)
  182. LIBPREFIX=
  183. endif
  184. ifeq ($(OS_TARGET),go32v1)
  185. LIBPREFIX=
  186. endif
  187. # determine which .pas extension is used
  188. ifndef PASEXT
  189. ifdef EXEOBJECTS
  190. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS)))))
  191. else
  192. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS)))))
  193. endif
  194. ifeq ($(TESTPAS),)
  195. PASEXT=.pp
  196. else
  197. PASEXT=.pas
  198. endif
  199. endif
  200. #####################################################################
  201. # Standard rules
  202. #####################################################################
  203. #####################################################################
  204. # Package depends
  205. #####################################################################
  206. ifneq ($(wildcard $(RTLDIR)),)
  207. ifeq ($(wildcard $(RTLDIR)/$(FPCMAKED)),)
  208. override COMPILEPACKAGES+=rtl
  209. rtl_package:
  210. $(MAKE) -C $(RTLDIR) all
  211. endif
  212. endif
  213. .PHONY: rtl_package
  214. #####################################################################
  215. # Users rules
  216. #####################################################################
  217. DIRS=tf ts tbs tbf test tesi to webtbs webtbf
  218. all : info
  219. tests : clean all_compilations
  220. cont_tests : all_compilations
  221. getret$(EXEEXT) : getret.pp
  222. $(FPC) getret
  223. getreturncode : getret$(EXEEXT)
  224. ifndef inlinux
  225. redir -ea $(FILE).log -oa $(FILE).log getret $(COMMAND)
  226. cp retcode $(FILE).$(RESEXT)
  227. else
  228. getret $(COMMAND) > $(FILE).log 2>$(FILE).log
  229. cp retcode $(FILE).$(RESEXT)
  230. # @echo "Return code of $(FILE) is $(cat retcode)"
  231. endif
  232. # retcode should be between 0 and 255
  233. # 256 is for halt
  234. # 512+doserror if doserror<>0
  235. # 1024 RESFILE does not exist
  236. # 2048 RESFILE is not set
  237. ifndef RESFILE
  238. RETVAL=2048
  239. else
  240. ifeq ($(wildcard $(RESFILE)*),$(RESFILE))
  241. RETVAL=$(shell cat $(RESFILE))
  242. else
  243. RETVAL=1024
  244. endif
  245. endif
  246. ifeq ($(RETVAL),0)
  247. testsuccess:
  248. @echo "Test for $(FILE) success (compiles)"
  249. @echo "Test for $(FILE) success (compiles)" >>log
  250. else
  251. testsuccess:
  252. @echo "Test for $(FILE) fails (does not compile) error $(RETVAL)"
  253. @echo "Test for $(FILE) fails (does not compile) error $(RETVAL)" >>log
  254. ifdef LONGLOG
  255. @echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> longlog
  256. @echo "Test for $(FILE) fails (does not compile) error $(RETVAL)" >> longlog
  257. @echo "" >> longlog
  258. cat $(FILE).log >> longlog
  259. @echo "" >> longlog
  260. endif
  261. @echo $(FILE) >> ts_fail
  262. @echo $(FILE) >> faillist
  263. endif
  264. ifdef EXCFILE
  265. ifeq ($(wildcard $(EXCFILE)*),$(EXCFILE))
  266. EXERETVAL:=$(shell cat $(EXCFILE))
  267. else
  268. EXERETVAL=$(EXCFILE) does not exist
  269. endif
  270. else
  271. EXERETVAL=No EXCFILE variable defined
  272. endif
  273. ifeq ($(EXERETVAL),0)
  274. testexecsuccess:
  275. @echo "Test for exec $(FILE) success (runs without error)"
  276. @echo "Test for $(FILE) success (runs without error)" >> log
  277. else
  278. testexecsuccess:
  279. @echo "Test for exec $(FILE) fails exec error $(EXERETVAL)"
  280. @echo "Test for exec $(FILE) fails exec error $(EXERETVAL)" >> log
  281. ifdef LONGLOG
  282. @echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> longlog
  283. @echo "Test for exec $(FILE) fails exec error $(EXERETVAL)" >> longlog
  284. @echo "" >> longlog
  285. cat $(FILE).elg >> longlog
  286. endif
  287. endif
  288. ifeq ($(wildcard $(FILE)$(EXEEXT)),$(FILE)$(EXEEXT))
  289. testexec:
  290. @echo "Testing $(FILE)$(EXEEXT)"
  291. ifdef NOREDIR
  292. getret $(FILE)$(EXEEXT)
  293. else
  294. ifndef inlinux
  295. redir -e $(FILE).elg -o $(FILE).elg getret $(FILE)$(EXEEXT)
  296. else
  297. getret $(FILE)$(EXEEXT) > $(FILE).elg 2>$(FILE).elg
  298. endif
  299. endif
  300. cp -f retcode $(FILE).exc
  301. $(MAKE) testexecsuccess 'FILE=$(FILE)' 'EXCFILE=$(FILE).exc'
  302. else
  303. testexec:
  304. ifeq ($(wildcard $(FILE)$(PPUEXT)),$(FILE)$(PPUEXT))
  305. @echo "file is a unit $(FILE)$(PPUEXT)"
  306. else
  307. @echo "No exefile $(FILE)$(EXEEXT)"
  308. @echo $(FILE) >> faillist
  309. ifdef LONGLOG
  310. @echo "No exefile $(FILE)$(EXEEXT) was generated" >> longlog
  311. endif
  312. endif
  313. endif
  314. test_exc :
  315. @echo $(wildcard $(FILE).exc*)
  316. @echo xx$(wildcard $(EXCFILE)*)xx xx$(EXCFILE)xx
  317. cat $(FILE).exc
  318. ifneq ($(RETVAL),0)
  319. testfail:
  320. @echo "Test for $(FILE) success (does not compile) error $(RETVAL)"
  321. @echo "Test for $(FILE) success (does not compile) error $(RETVAL)" >> log
  322. else
  323. testfail:
  324. @echo "Test for $(FILE) fails (does compile and should not)"
  325. @echo "Test for $(FILE) fails (does compile and should not)" >> log
  326. ifdef LONGLOG
  327. @echo "Test for $(FILE) fails (does compile and should not)" >> longlog
  328. endif
  329. @echo $(FILE) >> tf_fail
  330. @echo $(FILE) >> faillist
  331. endif
  332. ifdef FILE
  333. OPTFILE=$(wildcard $(FILE).opt)
  334. endif
  335. ifdef OPTFILE
  336. override OPT+=$(OPTFILE)
  337. endif
  338. ifndef FILE
  339. FILE=ts/ts00001.pp
  340. endif
  341. testone :
  342. $(MAKE) getreturncode 'COMMAND=$(FPC) $(OPT) $(FILE).pp' 'RESEXT=$(RESEXT)' 'FILE=$(FILE)'
  343. %.res : %.pp
  344. $(MAKE) testone 'FILE=$*' 'RESEXT=res'
  345. $(MAKE) testsuccess 'FILE=$*' 'RESFILE=$*.res'
  346. %.ref : %.pp
  347. $(MAKE) testone 'FILE=$*' 'RESEXT=ref'
  348. $(MAKE) testfail 'FILE=$*' 'RESFILE=$*.ref'
  349. # exec log files
  350. # creates two files
  351. # *.elg log file
  352. # *.exc exicode of program
  353. %.elg : %.res
  354. $(MAKE) testexec 'FILE=$*'
  355. %.eli : %.res
  356. $(MAKE) testexec 'FILE=$*' 'NOREDIR=YES'
  357. allts : $(patsubst %.pp,%.res,$(wildcard ts/ts*.pp))
  358. alltbs : $(patsubst %.pp,%.res,$(wildcard tbs/tbs*.pp))
  359. allwebtbs : $(patsubst %.pp,%.res,$(wildcard webtbs/tbug*.pp))
  360. tbs0to99 : $(patsubst %.pp,%.res,$(wildcard tbs00*.pp))
  361. tbs100to199 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs01*.pp))
  362. tbs200to299 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs02*.pp))
  363. tbs300to399 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs03*.pp))
  364. alltest : $(patsubst %.pp,%.res,$(wildcard test/test*.pp))
  365. alltesi : $(patsubst %.pp,%.res,$(wildcard tesi/tesi*.pp))
  366. alltis : $(patsubst %.pp,%.res,$(wildcard tis/tis*.pp))
  367. alltf : $(patsubst %.pp,%.ref,$(wildcard tf/tf*.pp))
  368. alltbf : $(patsubst %.pp,%.ref,$(wildcard tbf/tbf*.pp))
  369. allwebtbf : $(patsubst %.pp,%.ref,$(wildcard webtbf/tbug*.pp))
  370. allto : $(patsubst %.pp,%.res,$(wildcard to/to*.pp))
  371. ifndef TS_FAIL_LIST
  372. ifeq ($(wildcard ts_fail*),ts_fail)
  373. TS_FAIL_LIST=$(shell cat ts_fail)
  374. export TS_FAIL_LIST
  375. endif
  376. endif
  377. ifndef TF_FAIL_LIST
  378. ifeq ($(wildcard tf_fail*),tf_fail)
  379. TF_FAIL_LIST=$(shell cat tf_fail)
  380. export TF_FAIL_LIST
  381. endif
  382. endif
  383. clean_fail :
  384. -rm -f $(addsuffix .res,$(TS_FAIL_LIST))
  385. -rm -f $(addsuffix .ref,$(TF_FAIL_LIST))
  386. -rm log longlog
  387. again : clean_fail $(addsuffix .res,$(TS_FAIL_LIST)) $(addsuffix .ref,$(TF_FAIL_LIST))
  388. grep fails log
  389. all_compilations : allts alltbs allwebtbs alltf alltbf allwebtbf allto alltest alltesi alltis
  390. grep fails log
  391. allexec : alltsexec alltbsexec allwebtbsexec alltestexec
  392. grep fails log
  393. alltestexec: $(patsubst %.pp,%.elg,$(wildcard test/test*.pp))
  394. allfails :
  395. grep fails log > fails.log
  396. # these test are interactive
  397. # no redirection !!!
  398. alltesiexec: $(patsubst %.pp,%.eli,$(wildcard tesi/tesi*.pp))
  399. alltsexec: $(patsubst %.pp,%.elg,$(wildcard ts/ts*.pp))
  400. alltbsexec: $(patsubst %.pp,%.elg,$(wildcard tbs/tbs*.pp))
  401. allwebtbsexec: $(patsubst %.pp,%.elg,$(wildcard webtbs/tbug*.pp))
  402. tbsexec0to99 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs00*.pp))
  403. tbsexec100to199 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs01*.pp))
  404. tbsexec200to299 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs02*.pp))
  405. tbsexec300to399 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs03*.pp))
  406. alltisexec: $(patsubst %.pp,%.eli,$(wildcard tis/tis*.pp))
  407. clean:
  408. -rm -f $(addsuffix /*.re*,$(DIRS))
  409. -rm -f $(addsuffix /*$(PPUEXT),$(DIRS))
  410. -rm -f $(addsuffix /*$(OEXT),$(DIRS))
  411. -rm -f $(addsuffix /*.log,$(DIRS))
  412. -rm -f $(addsuffix /*.elg,$(DIRS))
  413. -rm -f $(addsuffix /*.exc,$(DIRS))
  414. ifdef inlinux
  415. -rm -f $(patsubst %.pp,%$(EXEEXT),$(wildcard $(addsuffix /t*.pp,$(DIRS))))
  416. else
  417. -rm -f $(addsuffix /*$(EXEEXT),$(DIRS))
  418. endif
  419. -rm -f log longlog faillist ts_fail tf_fail
  420. -rm -f fpcmaked ppas.sh ppas.bat retcode
  421. info :
  422. @echo This Makefile allows to test the compiler
  423. @echo compilation of 'ts*.pp' should succeed
  424. @echo compilation of 'tf*.pp' should fail
  425. @echo compilation of 'test*.pp' should succeed
  426. @echo 'to*.pp' files should also compile
  427. @echo simply run \'make tests\' to test all compilation
  428. @echo run \'make allexec\' to test also if the executables
  429. @echo created behave like the should
  430. @echo run \'make tesiexec\' to test executables
  431. @echo that require interactive mode