Makefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. #
  2. # Makefile generated by fpcmake v0.99.13 [2000/02/08]
  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 searched separated by spaces
  48. ifdef inlinux
  49. SEARCHPATH=$(subst :, ,$(PATH))
  50. else
  51. SEARCHPATH=$(subst ;, ,$(PATH))
  52. endif
  53. # Base dir
  54. ifdef PWD
  55. BASEDIR:=$(shell $(PWD))
  56. else
  57. BASEDIR=.
  58. endif
  59. #####################################################################
  60. # FPC version/target Detection
  61. #####################################################################
  62. # What compiler to use ?
  63. ifndef FPC
  64. # Compatibility with old makefiles
  65. ifdef PP
  66. FPC=$(PP)
  67. else
  68. ifdef inOS2
  69. FPC=ppos2
  70. else
  71. FPC=ppc386
  72. endif
  73. endif
  74. endif
  75. override FPC:=$(subst $(EXEEXT),,$(FPC))
  76. override FPC:=$(subst \,/,$(FPC))$(EXEEXT)
  77. # Target OS
  78. ifndef OS_TARGET
  79. OS_TARGET:=$(shell $(FPC) -iTO)
  80. endif
  81. # Source OS
  82. ifndef OS_SOURCE
  83. OS_SOURCE:=$(shell $(FPC) -iSO)
  84. endif
  85. # Target CPU
  86. ifndef CPU_TARGET
  87. CPU_TARGET:=$(shell $(FPC) -iTP)
  88. endif
  89. # Source CPU
  90. ifndef CPU_SOURCE
  91. CPU_SOURCE:=$(shell $(FPC) -iSP)
  92. endif
  93. # FPC version
  94. ifndef FPC_VERSION
  95. FPC_VERSION:=$(shell $(FPC) -iV)
  96. endif
  97. export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION
  98. #####################################################################
  99. # FPCDIR Setting
  100. #####################################################################
  101. # Test FPCDIR to look if the RTL dir exists
  102. ifdef FPCDIR
  103. override FPCDIR:=$(subst \,/,$(FPCDIR))
  104. ifeq ($(wildcard $(FPCDIR)/rtl),)
  105. ifeq ($(wildcard $(FPCDIR)/units),)
  106. override FPCDIR=wrong
  107. endif
  108. endif
  109. else
  110. override FPCDIR=wrong
  111. endif
  112. # Detect FPCDIR
  113. ifeq ($(FPCDIR),wrong)
  114. ifdef inlinux
  115. override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
  116. ifeq ($(wildcard $(FPCDIR)/units),)
  117. override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
  118. endif
  119. else
  120. override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
  121. override FPCDIR:=$(FPCDIR)/..
  122. ifeq ($(wildcard $(FPCDIR)/rtl),)
  123. ifeq ($(wildcard $(FPCDIR)/units),)
  124. override FPCDIR:=$(FPCDIR)/..
  125. ifeq ($(wildcard $(FPCDIR)/rtl),)
  126. ifeq ($(wildcard $(FPCDIR)/units),)
  127. override FPCDIR=c:/pp
  128. endif
  129. endif
  130. endif
  131. endif
  132. endif
  133. endif
  134. #####################################################################
  135. # User Settings
  136. #####################################################################
  137. # Targets
  138. # Clean
  139. # Install
  140. ZIPTARGET=install
  141. # Defaults
  142. # Directories
  143. # Packages
  144. # Libraries
  145. #####################################################################
  146. # Default extensions
  147. #####################################################################
  148. # Default needed extensions (Go32v2,Linux)
  149. LOADEREXT=.as
  150. PPLEXT=.ppl
  151. PPUEXT=.ppu
  152. OEXT=.o
  153. ASMEXT=.s
  154. SMARTEXT=.sl
  155. STATICLIBEXT=.a
  156. SHAREDLIBEXT=.so
  157. RSTEXT=.rst
  158. FPCMADE=fpcmade
  159. # Go32v1
  160. ifeq ($(OS_TARGET),go32v1)
  161. PPUEXT=.pp1
  162. OEXT=.o1
  163. ASMEXT=.s1
  164. SMARTEXT=.sl1
  165. STATICLIBEXT=.a1
  166. SHAREDLIBEXT=.so1
  167. FPCMADE=fpcmade.v1
  168. endif
  169. # Go32v2
  170. ifeq ($(OS_TARGET),go32v2)
  171. FPCMADE=fpcmade.dos
  172. endif
  173. # Linux
  174. ifeq ($(OS_TARGET),linux)
  175. FPCMADE=fpcmade.lnx
  176. endif
  177. # Win32
  178. ifeq ($(OS_TARGET),win32)
  179. PPUEXT=.ppw
  180. OEXT=.ow
  181. ASMEXT=.sw
  182. SMARTEXT=.slw
  183. STATICLIBEXT=.aw
  184. SHAREDLIBEXT=.dll
  185. FPCMADE=fpcmade.w32
  186. endif
  187. # OS/2
  188. ifeq ($(OS_TARGET),os2)
  189. PPUEXT=.ppo
  190. ASMEXT=.so2
  191. OEXT=.oo2
  192. SMARTEXT=.so
  193. STATICLIBEXT=.ao2
  194. SHAREDLIBEXT=.dll
  195. FPCMADE=fpcmade.os2
  196. endif
  197. # library prefix
  198. LIBPREFIX=lib
  199. ifeq ($(OS_TARGET),go32v2)
  200. LIBPREFIX=
  201. endif
  202. ifeq ($(OS_TARGET),go32v1)
  203. LIBPREFIX=
  204. endif
  205. # determine which .pas extension is used
  206. ifndef PASEXT
  207. ifdef EXEOBJECTS
  208. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS)))))
  209. else
  210. override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS)))))
  211. endif
  212. ifeq ($(TESTPAS),)
  213. PASEXT=.pp
  214. else
  215. PASEXT=.pas
  216. endif
  217. endif
  218. #####################################################################
  219. # Default Directories
  220. #####################################################################
  221. # set the prefix directory where to install everything
  222. ifndef PREFIXINSTALLDIR
  223. ifdef inlinux
  224. PREFIXINSTALLDIR=/usr
  225. else
  226. PREFIXINSTALLDIR=/pp
  227. endif
  228. endif
  229. export PREFIXINSTALLDIR
  230. # Where to place the resulting zip files
  231. ifndef DESTZIPDIR
  232. DESTZIPDIR:=$(BASEDIR)
  233. endif
  234. export DESTZIPDIR
  235. #####################################################################
  236. # Redirection
  237. #####################################################################
  238. ifndef REDIRFILE
  239. REDIRFILE=log
  240. endif
  241. ifdef REDIR
  242. ifndef inlinux
  243. override FPC=redir -eo $(FPC)
  244. endif
  245. # set the verbosity to max
  246. override FPCOPT+=-va
  247. override REDIR:= >> $(REDIRFILE)
  248. endif
  249. #####################################################################
  250. # Standard rules
  251. #####################################################################
  252. #####################################################################
  253. # Local Makefile
  254. #####################################################################
  255. ifneq ($(wildcard fpcmake.loc),)
  256. include fpcmake.loc
  257. endif
  258. #####################################################################
  259. # Users rules
  260. #####################################################################
  261. DIRS=tf ts tbs tbf test tesi to webtbs webtbf
  262. all : info
  263. tests : clean all_compilations
  264. cont_tests : all_compilations
  265. getret$(EXEEXT) : getret.pp
  266. $(FPC) getret
  267. getreturncode : getret$(EXEEXT)
  268. ifndef inlinux
  269. redir -ea $(FILE).log -oa $(FILE).log getret $(COMMAND)
  270. cp retcode $(FILE).$(RESEXT)
  271. else
  272. getret $(COMMAND) > $(FILE).log 2>$(FILE).log
  273. cp retcode $(FILE).$(RESEXT)
  274. # @echo "Return code of $(FILE) is $(cat retcode)"
  275. endif
  276. # retcode should be between 0 and 255
  277. # 256 is for halt
  278. # 512+doserror if doserror<>0
  279. # 1024 RESFILE does not exist
  280. # 2048 RESFILE is not set
  281. ifndef RESFILE
  282. RETVAL=2048
  283. else
  284. ifeq ($(wildcard $(RESFILE)*),$(RESFILE))
  285. RETVAL=$(shell cat $(RESFILE))
  286. else
  287. RETVAL=1024
  288. endif
  289. endif
  290. ifeq ($(RETVAL),0)
  291. testsuccess:
  292. @echo "Test for $(FILE) success (compiles)"
  293. @echo "Test for $(FILE) success (compiles)" >>$(LOG)
  294. else
  295. testsuccess:
  296. @echo "Test for $(FILE) fails (does not compile) error $(RETVAL)"
  297. @echo "Test for $(FILE) fails (does not compile) error $(RETVAL)" >>$(LOG)
  298. ifdef LONGLOG
  299. @echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $(LONGLOG)
  300. @echo "Test for $(FILE) fails (does not compile) error $(RETVAL)" >> $(LONGLOG)
  301. @echo "" >> $(LONGLOG)
  302. cat $(FILE).log >> $(LONGLOG)
  303. @echo "" >> $(LONGLOG)
  304. endif
  305. @echo $(FILE) >> ts_fail
  306. @echo $(FILE) >> faillist
  307. endif
  308. ifdef EXCFILE
  309. ifeq ($(wildcard $(EXCFILE)*),$(EXCFILE))
  310. EXERETVAL:=$(shell cat $(EXCFILE))
  311. else
  312. EXERETVAL=$(EXCFILE) does not exist
  313. endif
  314. else
  315. EXERETVAL=No EXCFILE variable defined
  316. endif
  317. ifeq ($(EXERETVAL),0)
  318. testexecsuccess:
  319. @echo "Test for exec $(FILE) success (runs without error)"
  320. @echo "Test for $(FILE) success (runs without error)" >> $(LOG)
  321. else
  322. testexecsuccess:
  323. @echo "Test for exec $(FILE) fails exec error $(EXERETVAL)"
  324. @echo "Test for exec $(FILE) fails exec error $(EXERETVAL)" >> $(LOG)
  325. ifdef LONGLOG
  326. @echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $(LONGLOG)
  327. @echo "Test for exec $(FILE) fails exec error $(EXERETVAL)" >> $(LONGLOG)
  328. @echo "" >> $(LONGLOG)
  329. cat $(FILE).elg >> $(LONGLOG)
  330. @echo $(FILE) >> ex_fail
  331. endif
  332. endif
  333. ifeq ($(wildcard $(FILE)$(EXEEXT)),$(FILE)$(EXEEXT))
  334. testexec:
  335. @echo "Testing $(FILE)$(EXEEXT)"
  336. ifdef NOREDIR
  337. getret $(FILE)$(EXEEXT)
  338. else
  339. ifndef inlinux
  340. redir -e $(FILE).elg -o $(FILE).elg getret $(FILE)$(EXEEXT)
  341. else
  342. getret $(FILE)$(EXEEXT) > $(FILE).elg 2>$(FILE).elg
  343. endif
  344. endif
  345. cp -f retcode $(FILE).exc
  346. $(MAKE) testexecsuccess 'FILE=$(FILE)' 'EXCFILE=$(FILE).exc'
  347. else
  348. testexec:
  349. ifeq ($(wildcard $(FILE)$(PPUEXT)),$(FILE)$(PPUEXT))
  350. @echo "file is a unit $(FILE)$(PPUEXT)"
  351. else
  352. @echo "No exefile $(FILE)$(EXEEXT)"
  353. @echo $(FILE) >> faillist
  354. ifdef LONGLOG
  355. @echo "No exefile $(FILE)$(EXEEXT) was generated" >> $(LONGLOG)
  356. endif
  357. endif
  358. endif
  359. test_exc :
  360. @echo $(wildcard $(FILE).exc*)
  361. @echo xx$(wildcard $(EXCFILE)*)xx xx$(EXCFILE)xx
  362. cat $(FILE).exc
  363. ifneq ($(RETVAL),0)
  364. testfail:
  365. @echo "Test for $(FILE) success (does not compile) error $(RETVAL)"
  366. @echo "Test for $(FILE) success (does not compile) error $(RETVAL)" >> $(LOG)
  367. else
  368. testfail:
  369. @echo "Test for $(FILE) fails (does compile and should not)"
  370. @echo "Test for $(FILE) fails (does compile and should not)" >> $(LOG)
  371. ifdef LONGLOG
  372. @echo "Test for $(FILE) fails (does compile and should not)" >> $(LONGLOG)
  373. endif
  374. @echo $(FILE) >> tf_fail
  375. @echo $(FILE) >> faillist
  376. endif
  377. ifndef LONGLOG
  378. export LONGLOG:=longlog
  379. endif
  380. ifndef LOG
  381. export LOG:=log
  382. endif
  383. ifdef FILE
  384. OPTFILE=$(wildcard $(FILE).opt)
  385. endif
  386. ifdef OPTFILE
  387. override OPT+=$(OPTFILE)
  388. endif
  389. ifndef FILE
  390. FILE=ts/ts00001.pp
  391. endif
  392. testone :
  393. $(MAKE) getreturncode 'COMMAND=$(FPC) $(OPT) $(FILE).pp' 'RESEXT=$(RESEXT)' 'FILE=$(FILE)'
  394. %.res : %.pp
  395. $(MAKE) testone 'FILE=$*' 'RESEXT=res'
  396. $(MAKE) testsuccess 'FILE=$*' 'RESFILE=$*.res'
  397. %.ref : %.pp
  398. $(MAKE) testone 'FILE=$*' 'RESEXT=ref'
  399. $(MAKE) testfail 'FILE=$*' 'RESFILE=$*.ref'
  400. # exec log files
  401. # creates two files
  402. # *.elg log file
  403. # *.exc exicode of program
  404. %.elg : %.res
  405. $(MAKE) testexec 'FILE=$*'
  406. %.eli : %.res
  407. $(MAKE) testexec 'FILE=$*' 'NOREDIR=YES'
  408. allts : $(patsubst %.pp,%.res,$(wildcard ts/ts*.pp))
  409. alltbs : $(patsubst %.pp,%.res,$(wildcard tbs/tbs*.pp))
  410. allwebtbs : $(patsubst %.pp,%.res,$(wildcard webtbs/tbug*.pp))
  411. tbs0to99 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs00*.pp))
  412. tbs100to199 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs01*.pp))
  413. tbs200to299 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs02*.pp))
  414. tbs300to399 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs03*.pp))
  415. alltest : $(patsubst %.pp,%.res,$(wildcard test/test*.pp))
  416. alltesi : $(patsubst %.pp,%.res,$(wildcard tesi/tesi*.pp))
  417. alltis : $(patsubst %.pp,%.res,$(wildcard tis/tis*.pp))
  418. alltf : $(patsubst %.pp,%.ref,$(wildcard tf/tf*.pp))
  419. alltbf : $(patsubst %.pp,%.ref,$(wildcard tbf/tbf*.pp))
  420. allwebtbf : $(patsubst %.pp,%.ref,$(wildcard webtbf/tbug*.pp))
  421. allto : $(patsubst %.pp,%.res,$(wildcard to/to*.pp))
  422. ifndef TS_FAIL_LIST
  423. ifeq ($(wildcard ts_fail*),ts_fail)
  424. TS_FAIL_LIST=$(shell cat ts_fail)
  425. export TS_FAIL_LIST
  426. endif
  427. endif
  428. ifndef TF_FAIL_LIST
  429. ifeq ($(wildcard tf_fail*),tf_fail)
  430. TF_FAIL_LIST=$(shell cat tf_fail)
  431. export TF_FAIL_LIST
  432. endif
  433. endif
  434. ifndef EXEC_FAIL_LIST
  435. ifeq ($(wildcard ex_fail*),ex_fail)
  436. EXEC_FAIL_LIST=$(shell cat ex_fail)
  437. export EXEC_FAIL_LIST
  438. endif
  439. endif
  440. clean_fail :
  441. -rm -f $(addsuffix .res,$(TS_FAIL_LIST))
  442. -rm -f $(addsuffix .ref,$(TF_FAIL_LIST))
  443. -rm -f $(addsuffix .res,$(EXEC_FAIL_LIST))
  444. -rm -f $(addsuffix .elg,$(EXEC_FAIL_LIST))
  445. # Test all failure of last time
  446. # don't forget to try to run them again
  447. again :
  448. $(MAKE) internal_again LOG=again.log LONGLOG=again.llg
  449. internal_again : clean_fail $(addsuffix .res,$(TS_FAIL_LIST)) \
  450. $(addsuffix .ref,$(TF_FAIL_LIST)) \
  451. $(addsuffix .elg,$(EXEC_FAIL_LIST) $(TS_FAIL_LIST))
  452. grep fails $(LOG)
  453. all_compilations : allts alltbs allwebtbs alltf alltbf allwebtbf allto alltest alltesi alltis
  454. grep fails $(LOG)
  455. allexec : alltsexec alltbsexec allwebtbsexec alltestexec
  456. grep fails $(LOG)
  457. alltestexec: $(patsubst %.pp,%.elg,$(wildcard test/test*.pp))
  458. allfails :
  459. grep fails $(LOG) > fails.log
  460. # these test are interactive
  461. # no redirection !!!
  462. alltesiexec: $(patsubst %.pp,%.eli,$(wildcard tesi/tesi*.pp))
  463. alltsexec: $(patsubst %.pp,%.elg,$(wildcard ts/ts*.pp))
  464. alltbsexec: $(patsubst %.pp,%.elg,$(wildcard tbs/tbs*.pp))
  465. allwebtbsexec: $(patsubst %.pp,%.elg,$(wildcard webtbs/tbug*.pp))
  466. tbsexec0to99 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs00*.pp))
  467. tbsexec100to199 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs01*.pp))
  468. tbsexec200to299 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs02*.pp))
  469. tbsexec300to399 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs03*.pp))
  470. alltisexec: $(patsubst %.pp,%.eli,$(wildcard tis/tis*.pp))
  471. clean:
  472. -rm -f $(addsuffix /*.re*,$(DIRS))
  473. -rm -f $(addsuffix /*$(PPUEXT),$(DIRS))
  474. -rm -f $(addsuffix /*$(OEXT),$(DIRS))
  475. -rm -f $(addsuffix /*.log,$(DIRS))
  476. -rm -f $(addsuffix /*.elg,$(DIRS))
  477. -rm -f $(addsuffix /*.exc,$(DIRS))
  478. ifdef inlinux
  479. -rm -f $(patsubst %.pp,%$(EXEEXT),$(wildcard $(addsuffix /t*.pp,$(DIRS))))
  480. else
  481. -rm -f $(addsuffix /*$(EXEEXT),$(DIRS))
  482. endif
  483. -rm -f $(LOG) $(LONGLOG) faillist ts_fail tf_fail
  484. -rm -f fpcmaked ppas.sh ppas.bat retcode
  485. info :
  486. @echo This Makefile allows to test the compiler
  487. @echo compilation of 'ts*.pp' should succeed
  488. @echo compilation of 'tf*.pp' should fail
  489. @echo compilation of 'test*.pp' should succeed
  490. @echo 'to*.pp' files should also compile
  491. @echo simply run \'make tests\' to test all compilation
  492. @echo run \'make allexec\' to test also if the executables
  493. @echo created behave like the should
  494. @echo run \'make tesiexec\' to test executables
  495. @echo that require interactive mode