Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. #
  2. # Makefile generated by fpcmake v0.99.13 on 1999-12-21 00:34
  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. FPCMADE=fpcmade
  142. # Go32v1
  143. ifeq ($(OS_TARGET),go32v1)
  144. PPUEXT=.pp1
  145. OEXT=.o1
  146. ASMEXT=.s1
  147. SMARTEXT=.sl1
  148. STATICLIBEXT=.a1
  149. SHAREDLIBEXT=.so1
  150. PACKAGESUFFIX=v1
  151. FPCMADE=fpcmade.v1
  152. endif
  153. # Go32v2
  154. ifeq ($(OS_TARGET),go32v2)
  155. PACKAGESUFFIX=go32
  156. FPCMADE=fpcmade.dos
  157. endif
  158. # Linux
  159. ifeq ($(OS_TARGET),linux)
  160. PACKAGESUFFIX=linux
  161. FPCMADE=fpcmade.lnx
  162. endif
  163. # Win32
  164. ifeq ($(OS_TARGET),win32)
  165. PPUEXT=.ppw
  166. OEXT=.ow
  167. ASMEXT=.sw
  168. SMARTEXT=.slw
  169. STATICLIBEXT=.aw
  170. SHAREDLIBEXT=.dll
  171. PACKAGESUFFIX=win32
  172. FPCMADE=fpcmade.w32
  173. endif
  174. # OS/2
  175. ifeq ($(OS_TARGET),os2)
  176. PPUEXT=.ppo
  177. ASMEXT=.so2
  178. OEXT=.oo2
  179. SMARTEXT=.so
  180. STATICLIBEXT=.ao2
  181. SHAREDLIBEXT=.dll
  182. PACKAGESUFFIX=os2
  183. FPCMADE=fpcmade.os2
  184. endif
  185. # library prefix
  186. LIBPREFIX=lib
  187. ifeq ($(OS_TARGET),go32v2)
  188. LIBPREFIX=
  189. endif
  190. ifeq ($(OS_TARGET),go32v1)
  191. LIBPREFIX=
  192. endif
  193. # determine which .pas extension is used
  194. ifndef PASEXT
  195. ifdef EXEOBJECTS
  196. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS)))))
  197. else
  198. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS)))))
  199. endif
  200. ifeq ($(TESTPAS),)
  201. PASEXT=.pp
  202. else
  203. PASEXT=.pas
  204. endif
  205. endif
  206. #####################################################################
  207. # Standard rules
  208. #####################################################################
  209. #####################################################################
  210. # Package depends
  211. #####################################################################
  212. ifneq ($(wildcard $(RTLDIR)),)
  213. ifeq ($(wildcard $(RTLDIR)/$(FPCMADE)),)
  214. override COMPILEPACKAGES+=rtl
  215. rtl_package:
  216. $(MAKE) -C $(RTLDIR) all
  217. endif
  218. endif
  219. .PHONY: rtl_package
  220. #####################################################################
  221. # Users rules
  222. #####################################################################
  223. DIRS=tf ts tbs tbf test tesi to webtbs webtbf
  224. all : info
  225. tests : clean all_compilations
  226. cont_tests : all_compilations
  227. getret$(EXEEXT) : getret.pp
  228. $(FPC) getret
  229. getreturncode : getret$(EXEEXT)
  230. ifndef inlinux
  231. redir -ea $(FILE).log -oa $(FILE).log getret $(COMMAND)
  232. cp retcode $(FILE).$(RESEXT)
  233. else
  234. getret $(COMMAND) > $(FILE).log 2>$(FILE).log
  235. cp retcode $(FILE).$(RESEXT)
  236. # @echo "Return code of $(FILE) is $(cat retcode)"
  237. endif
  238. # retcode should be between 0 and 255
  239. # 256 is for halt
  240. # 512+doserror if doserror<>0
  241. # 1024 RESFILE does not exist
  242. # 2048 RESFILE is not set
  243. ifndef RESFILE
  244. RETVAL=2048
  245. else
  246. ifeq ($(wildcard $(RESFILE)*),$(RESFILE))
  247. RETVAL=$(shell cat $(RESFILE))
  248. else
  249. RETVAL=1024
  250. endif
  251. endif
  252. ifeq ($(RETVAL),0)
  253. testsuccess:
  254. @echo "Test for $(FILE) success (compiles)"
  255. @echo "Test for $(FILE) success (compiles)" >>$(LOG)
  256. else
  257. testsuccess:
  258. @echo "Test for $(FILE) fails (does not compile) error $(RETVAL)"
  259. @echo "Test for $(FILE) fails (does not compile) error $(RETVAL)" >>$(LOG)
  260. ifdef LONGLOG
  261. @echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $(LONGLOG)
  262. @echo "Test for $(FILE) fails (does not compile) error $(RETVAL)" >> $(LONGLOG)
  263. @echo "" >> $(LONGLOG)
  264. cat $(FILE).log >> $(LONGLOG)
  265. @echo "" >> $(LONGLOG)
  266. endif
  267. @echo $(FILE) >> ts_fail
  268. @echo $(FILE) >> faillist
  269. endif
  270. ifdef EXCFILE
  271. ifeq ($(wildcard $(EXCFILE)*),$(EXCFILE))
  272. EXERETVAL:=$(shell cat $(EXCFILE))
  273. else
  274. EXERETVAL=$(EXCFILE) does not exist
  275. endif
  276. else
  277. EXERETVAL=No EXCFILE variable defined
  278. endif
  279. ifeq ($(EXERETVAL),0)
  280. testexecsuccess:
  281. @echo "Test for exec $(FILE) success (runs without error)"
  282. @echo "Test for $(FILE) success (runs without error)" >> $(LOG)
  283. else
  284. testexecsuccess:
  285. @echo "Test for exec $(FILE) fails exec error $(EXERETVAL)"
  286. @echo "Test for exec $(FILE) fails exec error $(EXERETVAL)" >> $(LOG)
  287. ifdef LONGLOG
  288. @echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $(LONGLOG)
  289. @echo "Test for exec $(FILE) fails exec error $(EXERETVAL)" >> $(LONGLOG)
  290. @echo "" >> $(LONGLOG)
  291. cat $(FILE).elg >> $(LONGLOG)
  292. @echo $(FILE) >> ex_fail
  293. endif
  294. endif
  295. ifeq ($(wildcard $(FILE)$(EXEEXT)),$(FILE)$(EXEEXT))
  296. testexec:
  297. @echo "Testing $(FILE)$(EXEEXT)"
  298. ifdef NOREDIR
  299. getret $(FILE)$(EXEEXT)
  300. else
  301. ifndef inlinux
  302. redir -e $(FILE).elg -o $(FILE).elg getret $(FILE)$(EXEEXT)
  303. else
  304. getret $(FILE)$(EXEEXT) > $(FILE).elg 2>$(FILE).elg
  305. endif
  306. endif
  307. cp -f retcode $(FILE).exc
  308. $(MAKE) testexecsuccess 'FILE=$(FILE)' 'EXCFILE=$(FILE).exc'
  309. else
  310. testexec:
  311. ifeq ($(wildcard $(FILE)$(PPUEXT)),$(FILE)$(PPUEXT))
  312. @echo "file is a unit $(FILE)$(PPUEXT)"
  313. else
  314. @echo "No exefile $(FILE)$(EXEEXT)"
  315. @echo $(FILE) >> faillist
  316. ifdef LONGLOG
  317. @echo "No exefile $(FILE)$(EXEEXT) was generated" >> $(LONGLOG)
  318. endif
  319. endif
  320. endif
  321. test_exc :
  322. @echo $(wildcard $(FILE).exc*)
  323. @echo xx$(wildcard $(EXCFILE)*)xx xx$(EXCFILE)xx
  324. cat $(FILE).exc
  325. ifneq ($(RETVAL),0)
  326. testfail:
  327. @echo "Test for $(FILE) success (does not compile) error $(RETVAL)"
  328. @echo "Test for $(FILE) success (does not compile) error $(RETVAL)" >> $(LOG)
  329. else
  330. testfail:
  331. @echo "Test for $(FILE) fails (does compile and should not)"
  332. @echo "Test for $(FILE) fails (does compile and should not)" >> $(LOG)
  333. ifdef LONGLOG
  334. @echo "Test for $(FILE) fails (does compile and should not)" >> $(LONGLOG)
  335. endif
  336. @echo $(FILE) >> tf_fail
  337. @echo $(FILE) >> faillist
  338. endif
  339. ifndef LONGLOG
  340. export LONGLOG:=longlog
  341. endif
  342. ifndef LOG
  343. export LOG:=log
  344. endif
  345. ifdef FILE
  346. OPTFILE=$(wildcard $(FILE).opt)
  347. endif
  348. ifdef OPTFILE
  349. override OPT+=$(OPTFILE)
  350. endif
  351. ifndef FILE
  352. FILE=ts/ts00001.pp
  353. endif
  354. testone :
  355. $(MAKE) getreturncode 'COMMAND=$(FPC) $(OPT) $(FILE).pp' 'RESEXT=$(RESEXT)' 'FILE=$(FILE)'
  356. %.res : %.pp
  357. $(MAKE) testone 'FILE=$*' 'RESEXT=res'
  358. $(MAKE) testsuccess 'FILE=$*' 'RESFILE=$*.res'
  359. %.ref : %.pp
  360. $(MAKE) testone 'FILE=$*' 'RESEXT=ref'
  361. $(MAKE) testfail 'FILE=$*' 'RESFILE=$*.ref'
  362. # exec log files
  363. # creates two files
  364. # *.elg log file
  365. # *.exc exicode of program
  366. %.elg : %.res
  367. $(MAKE) testexec 'FILE=$*'
  368. %.eli : %.res
  369. $(MAKE) testexec 'FILE=$*' 'NOREDIR=YES'
  370. allts : $(patsubst %.pp,%.res,$(wildcard ts/ts*.pp))
  371. alltbs : $(patsubst %.pp,%.res,$(wildcard tbs/tbs*.pp))
  372. allwebtbs : $(patsubst %.pp,%.res,$(wildcard webtbs/tbug*.pp))
  373. tbs0to99 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs00*.pp))
  374. tbs100to199 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs01*.pp))
  375. tbs200to299 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs02*.pp))
  376. tbs300to399 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs03*.pp))
  377. alltest : $(patsubst %.pp,%.res,$(wildcard test/test*.pp))
  378. alltesi : $(patsubst %.pp,%.res,$(wildcard tesi/tesi*.pp))
  379. alltis : $(patsubst %.pp,%.res,$(wildcard tis/tis*.pp))
  380. alltf : $(patsubst %.pp,%.ref,$(wildcard tf/tf*.pp))
  381. alltbf : $(patsubst %.pp,%.ref,$(wildcard tbf/tbf*.pp))
  382. allwebtbf : $(patsubst %.pp,%.ref,$(wildcard webtbf/tbug*.pp))
  383. allto : $(patsubst %.pp,%.res,$(wildcard to/to*.pp))
  384. ifndef TS_FAIL_LIST
  385. ifeq ($(wildcard ts_fail*),ts_fail)
  386. TS_FAIL_LIST=$(shell cat ts_fail)
  387. export TS_FAIL_LIST
  388. endif
  389. endif
  390. ifndef TF_FAIL_LIST
  391. ifeq ($(wildcard tf_fail*),tf_fail)
  392. TF_FAIL_LIST=$(shell cat tf_fail)
  393. export TF_FAIL_LIST
  394. endif
  395. endif
  396. ifndef EXEC_FAIL_LIST
  397. ifeq ($(wildcard ex_fail*),ex_fail)
  398. EXEC_FAIL_LIST=$(shell cat ex_fail)
  399. export EXEC_FAIL_LIST
  400. endif
  401. endif
  402. clean_fail :
  403. -rm -f $(addsuffix .res,$(TS_FAIL_LIST))
  404. -rm -f $(addsuffix .ref,$(TF_FAIL_LIST))
  405. -rm -f $(addsuffix .res,$(EXEC_FAIL_LIST))
  406. -rm -f $(addsuffix .elg,$(EXEC_FAIL_LIST))
  407. # Test all failure of last time
  408. # don't forget to try to run them again
  409. again :
  410. $(MAKE) internal_again LOG=again.log LONGLOG=again.llg
  411. internal_again : clean_fail $(addsuffix .res,$(TS_FAIL_LIST)) \
  412. $(addsuffix .ref,$(TF_FAIL_LIST)) \
  413. $(addsuffix .elg,$(EXEC_FAIL_LIST) $(TS_FAIL_LIST))
  414. grep fails $(LOG)
  415. all_compilations : allts alltbs allwebtbs alltf alltbf allwebtbf allto alltest alltesi alltis
  416. grep fails $(LOG)
  417. allexec : alltsexec alltbsexec allwebtbsexec alltestexec
  418. grep fails $(LOG)
  419. alltestexec: $(patsubst %.pp,%.elg,$(wildcard test/test*.pp))
  420. allfails :
  421. grep fails $(LOG) > fails.log
  422. # these test are interactive
  423. # no redirection !!!
  424. alltesiexec: $(patsubst %.pp,%.eli,$(wildcard tesi/tesi*.pp))
  425. alltsexec: $(patsubst %.pp,%.elg,$(wildcard ts/ts*.pp))
  426. alltbsexec: $(patsubst %.pp,%.elg,$(wildcard tbs/tbs*.pp))
  427. allwebtbsexec: $(patsubst %.pp,%.elg,$(wildcard webtbs/tbug*.pp))
  428. tbsexec0to99 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs00*.pp))
  429. tbsexec100to199 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs01*.pp))
  430. tbsexec200to299 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs02*.pp))
  431. tbsexec300to399 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs03*.pp))
  432. alltisexec: $(patsubst %.pp,%.eli,$(wildcard tis/tis*.pp))
  433. clean:
  434. -rm -f $(addsuffix /*.re*,$(DIRS))
  435. -rm -f $(addsuffix /*$(PPUEXT),$(DIRS))
  436. -rm -f $(addsuffix /*$(OEXT),$(DIRS))
  437. -rm -f $(addsuffix /*.log,$(DIRS))
  438. -rm -f $(addsuffix /*.elg,$(DIRS))
  439. -rm -f $(addsuffix /*.exc,$(DIRS))
  440. ifdef inlinux
  441. -rm -f $(patsubst %.pp,%$(EXEEXT),$(wildcard $(addsuffix /t*.pp,$(DIRS))))
  442. else
  443. -rm -f $(addsuffix /*$(EXEEXT),$(DIRS))
  444. endif
  445. -rm -f $(LOG) $(LONGLOG) faillist ts_fail tf_fail
  446. -rm -f fpcmaked ppas.sh ppas.bat retcode
  447. info :
  448. @echo This Makefile allows to test the compiler
  449. @echo compilation of 'ts*.pp' should succeed
  450. @echo compilation of 'tf*.pp' should fail
  451. @echo compilation of 'test*.pp' should succeed
  452. @echo 'to*.pp' files should also compile
  453. @echo simply run \'make tests\' to test all compilation
  454. @echo run \'make allexec\' to test also if the executables
  455. @echo created behave like the should
  456. @echo run \'make tesiexec\' to test executables
  457. @echo that require interactive mode