# # Makefile generated by fpcmake v0.99.13 [2000/01/18] # defaultrule: info ##################################################################### # Autodetect OS (Linux or Dos or Windows NT) # define inlinux when running under linux # define inWinNT when running under WinNT ##################################################################### # We need only / in the path override PATH:=$(subst \,/,$(PATH)) # Search for PWD and determine also if we are under linux PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH))))) ifeq ($(PWD),) PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH))))) ifeq ($(PWD),) nopwd: @echo You need the GNU utils package to use this Makefile! @echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip @exit else inlinux=1 endif else PWD:=$(firstword $(PWD)) endif # Detect NT - NT sets OS to Windows_NT ifndef inlinux ifeq ($(OS),Windows_NT) inWinNT=1 endif endif # Detect OS/2 - OS/2 has OS2_SHELL defined ifndef inlinux ifndef inWinNT ifdef OS2_SHELL inOS2=1 endif endif endif # The extension of executables ifdef inlinux EXEEXT= else EXEEXT=.exe endif # The path which is searched separated by spaces ifdef inlinux SEARCHPATH=$(subst :, ,$(PATH)) else SEARCHPATH=$(subst ;, ,$(PATH)) endif # Base dir ifdef PWD BASEDIR:=$(shell $(PWD)) else BASEDIR=. endif ##################################################################### # FPC version/target Detection ##################################################################### # What compiler to use ? ifndef FPC # Compatibility with old makefiles ifdef PP FPC=$(PP) else ifdef inOS2 FPC=ppos2$(EXEEXT) else FPC=ppc386$(EXEEXT) endif endif endif override FPC:=$(subst \,/,$(FPC)) # Target OS ifndef OS_TARGET OS_TARGET:=$(shell $(FPC) -iTO) endif # Source OS ifndef OS_SOURCE OS_SOURCE:=$(shell $(FPC) -iSO) endif # Target CPU ifndef CPU_TARGET CPU_TARGET:=$(shell $(FPC) -iTP) endif # Source CPU ifndef CPU_SOURCE CPU_SOURCE:=$(shell $(FPC) -iSP) endif # FPC version ifndef FPC_VERSION FPC_VERSION:=$(shell $(FPC) -iV) endif export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION ##################################################################### # FPCDIR Setting ##################################################################### # Test FPCDIR to look if the RTL dir exists ifdef FPCDIR override FPCDIR:=$(subst \,/,$(FPCDIR)) ifeq ($(wildcard $(FPCDIR)/rtl),) override FPCDIR=wrong endif else override FPCDIR=wrong endif # Detect FPCDIR ifeq ($(FPCDIR),wrong) ifdef inlinux override FPCDIR=/usr/lib/fpc/$(FPC_VERSION) else override FPCDIR:=$(subst /$(FPC)$(EXEEXT),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC)$(EXEEXT),$(SEARCHPATH)))))) endif endif ##################################################################### # User Settings ##################################################################### # Targets # Clean # Install ZIPTARGET=install # Defaults # Directories # Packages # Libraries ##################################################################### # Default extensions ##################################################################### # Default needed extensions (Go32v2,Linux) LOADEREXT=.as PPLEXT=.ppl PPUEXT=.ppu OEXT=.o ASMEXT=.s SMARTEXT=.sl STATICLIBEXT=.a SHAREDLIBEXT=.so RSTEXT=.rst FPCMADE=fpcmade # Go32v1 ifeq ($(OS_TARGET),go32v1) PPUEXT=.pp1 OEXT=.o1 ASMEXT=.s1 SMARTEXT=.sl1 STATICLIBEXT=.a1 SHAREDLIBEXT=.so1 FPCMADE=fpcmade.v1 endif # Go32v2 ifeq ($(OS_TARGET),go32v2) FPCMADE=fpcmade.dos endif # Linux ifeq ($(OS_TARGET),linux) FPCMADE=fpcmade.lnx endif # Win32 ifeq ($(OS_TARGET),win32) PPUEXT=.ppw OEXT=.ow ASMEXT=.sw SMARTEXT=.slw STATICLIBEXT=.aw SHAREDLIBEXT=.dll FPCMADE=fpcmade.w32 endif # OS/2 ifeq ($(OS_TARGET),os2) PPUEXT=.ppo ASMEXT=.so2 OEXT=.oo2 SMARTEXT=.so STATICLIBEXT=.ao2 SHAREDLIBEXT=.dll FPCMADE=fpcmade.os2 endif # library prefix LIBPREFIX=lib ifeq ($(OS_TARGET),go32v2) LIBPREFIX= endif ifeq ($(OS_TARGET),go32v1) LIBPREFIX= endif # determine which .pas extension is used ifndef PASEXT ifdef EXEOBJECTS override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS))))) else override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS))))) endif ifeq ($(TESTPAS),) PASEXT=.pp else PASEXT=.pas endif endif ##################################################################### # Default Directories ##################################################################### # set the prefix directory where to install everything ifndef PREFIXINSTALLDIR ifdef inlinux PREFIXINSTALLDIR=/usr else PREFIXINSTALLDIR=/pp endif endif export PREFIXINSTALLDIR # Where to place the resulting zip files ifndef DESTZIPDIR DESTZIPDIR:=$(BASEDIR) endif export DESTZIPDIR ##################################################################### # Redirection ##################################################################### # Release ? Then force OPT and don't use extra opts via commandline ifndef REDIRFILE REDIRFILE=log endif ifdef REDIR ifndef inlinux override FPC=redir -eo $(FPC) endif # set the verbosity to max override FPCOPT+=-va override REDIR:= >> $(REDIRFILE) endif ##################################################################### # Standard rules ##################################################################### ##################################################################### # Local Makefile ##################################################################### ifneq ($(wildcard fpcmake.loc),) include fpcmake.loc endif ##################################################################### # Users rules ##################################################################### DIRS=tf ts tbs tbf test tesi to webtbs webtbf all : info tests : clean all_compilations cont_tests : all_compilations getret$(EXEEXT) : getret.pp $(FPC) getret getreturncode : getret$(EXEEXT) ifndef inlinux redir -ea $(FILE).log -oa $(FILE).log getret $(COMMAND) cp retcode $(FILE).$(RESEXT) else getret $(COMMAND) > $(FILE).log 2>$(FILE).log cp retcode $(FILE).$(RESEXT) # @echo "Return code of $(FILE) is $(cat retcode)" endif # retcode should be between 0 and 255 # 256 is for halt # 512+doserror if doserror<>0 # 1024 RESFILE does not exist # 2048 RESFILE is not set ifndef RESFILE RETVAL=2048 else ifeq ($(wildcard $(RESFILE)*),$(RESFILE)) RETVAL=$(shell cat $(RESFILE)) else RETVAL=1024 endif endif ifeq ($(RETVAL),0) testsuccess: @echo "Test for $(FILE) success (compiles)" @echo "Test for $(FILE) success (compiles)" >>$(LOG) else testsuccess: @echo "Test for $(FILE) fails (does not compile) error $(RETVAL)" @echo "Test for $(FILE) fails (does not compile) error $(RETVAL)" >>$(LOG) ifdef LONGLOG @echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $(LONGLOG) @echo "Test for $(FILE) fails (does not compile) error $(RETVAL)" >> $(LONGLOG) @echo "" >> $(LONGLOG) cat $(FILE).log >> $(LONGLOG) @echo "" >> $(LONGLOG) endif @echo $(FILE) >> ts_fail @echo $(FILE) >> faillist endif ifdef EXCFILE ifeq ($(wildcard $(EXCFILE)*),$(EXCFILE)) EXERETVAL:=$(shell cat $(EXCFILE)) else EXERETVAL=$(EXCFILE) does not exist endif else EXERETVAL=No EXCFILE variable defined endif ifeq ($(EXERETVAL),0) testexecsuccess: @echo "Test for exec $(FILE) success (runs without error)" @echo "Test for $(FILE) success (runs without error)" >> $(LOG) else testexecsuccess: @echo "Test for exec $(FILE) fails exec error $(EXERETVAL)" @echo "Test for exec $(FILE) fails exec error $(EXERETVAL)" >> $(LOG) ifdef LONGLOG @echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $(LONGLOG) @echo "Test for exec $(FILE) fails exec error $(EXERETVAL)" >> $(LONGLOG) @echo "" >> $(LONGLOG) cat $(FILE).elg >> $(LONGLOG) @echo $(FILE) >> ex_fail endif endif ifeq ($(wildcard $(FILE)$(EXEEXT)),$(FILE)$(EXEEXT)) testexec: @echo "Testing $(FILE)$(EXEEXT)" ifdef NOREDIR getret $(FILE)$(EXEEXT) else ifndef inlinux redir -e $(FILE).elg -o $(FILE).elg getret $(FILE)$(EXEEXT) else getret $(FILE)$(EXEEXT) > $(FILE).elg 2>$(FILE).elg endif endif cp -f retcode $(FILE).exc $(MAKE) testexecsuccess 'FILE=$(FILE)' 'EXCFILE=$(FILE).exc' else testexec: ifeq ($(wildcard $(FILE)$(PPUEXT)),$(FILE)$(PPUEXT)) @echo "file is a unit $(FILE)$(PPUEXT)" else @echo "No exefile $(FILE)$(EXEEXT)" @echo $(FILE) >> faillist ifdef LONGLOG @echo "No exefile $(FILE)$(EXEEXT) was generated" >> $(LONGLOG) endif endif endif test_exc : @echo $(wildcard $(FILE).exc*) @echo xx$(wildcard $(EXCFILE)*)xx xx$(EXCFILE)xx cat $(FILE).exc ifneq ($(RETVAL),0) testfail: @echo "Test for $(FILE) success (does not compile) error $(RETVAL)" @echo "Test for $(FILE) success (does not compile) error $(RETVAL)" >> $(LOG) else testfail: @echo "Test for $(FILE) fails (does compile and should not)" @echo "Test for $(FILE) fails (does compile and should not)" >> $(LOG) ifdef LONGLOG @echo "Test for $(FILE) fails (does compile and should not)" >> $(LONGLOG) endif @echo $(FILE) >> tf_fail @echo $(FILE) >> faillist endif ifndef LONGLOG export LONGLOG:=longlog endif ifndef LOG export LOG:=log endif ifdef FILE OPTFILE=$(wildcard $(FILE).opt) endif ifdef OPTFILE override OPT+=$(OPTFILE) endif ifndef FILE FILE=ts/ts00001.pp endif testone : $(MAKE) getreturncode 'COMMAND=$(FPC) $(OPT) $(FILE).pp' 'RESEXT=$(RESEXT)' 'FILE=$(FILE)' %.res : %.pp $(MAKE) testone 'FILE=$*' 'RESEXT=res' $(MAKE) testsuccess 'FILE=$*' 'RESFILE=$*.res' %.ref : %.pp $(MAKE) testone 'FILE=$*' 'RESEXT=ref' $(MAKE) testfail 'FILE=$*' 'RESFILE=$*.ref' # exec log files # creates two files # *.elg log file # *.exc exicode of program %.elg : %.res $(MAKE) testexec 'FILE=$*' %.eli : %.res $(MAKE) testexec 'FILE=$*' 'NOREDIR=YES' allts : $(patsubst %.pp,%.res,$(wildcard ts/ts*.pp)) alltbs : $(patsubst %.pp,%.res,$(wildcard tbs/tbs*.pp)) allwebtbs : $(patsubst %.pp,%.res,$(wildcard webtbs/tbug*.pp)) tbs0to99 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs00*.pp)) tbs100to199 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs01*.pp)) tbs200to299 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs02*.pp)) tbs300to399 : $(patsubst %.pp,%.res,$(wildcard tbs/tbs03*.pp)) alltest : $(patsubst %.pp,%.res,$(wildcard test/test*.pp)) alltesi : $(patsubst %.pp,%.res,$(wildcard tesi/tesi*.pp)) alltis : $(patsubst %.pp,%.res,$(wildcard tis/tis*.pp)) alltf : $(patsubst %.pp,%.ref,$(wildcard tf/tf*.pp)) alltbf : $(patsubst %.pp,%.ref,$(wildcard tbf/tbf*.pp)) allwebtbf : $(patsubst %.pp,%.ref,$(wildcard webtbf/tbug*.pp)) allto : $(patsubst %.pp,%.res,$(wildcard to/to*.pp)) ifndef TS_FAIL_LIST ifeq ($(wildcard ts_fail*),ts_fail) TS_FAIL_LIST=$(shell cat ts_fail) export TS_FAIL_LIST endif endif ifndef TF_FAIL_LIST ifeq ($(wildcard tf_fail*),tf_fail) TF_FAIL_LIST=$(shell cat tf_fail) export TF_FAIL_LIST endif endif ifndef EXEC_FAIL_LIST ifeq ($(wildcard ex_fail*),ex_fail) EXEC_FAIL_LIST=$(shell cat ex_fail) export EXEC_FAIL_LIST endif endif clean_fail : -rm -f $(addsuffix .res,$(TS_FAIL_LIST)) -rm -f $(addsuffix .ref,$(TF_FAIL_LIST)) -rm -f $(addsuffix .res,$(EXEC_FAIL_LIST)) -rm -f $(addsuffix .elg,$(EXEC_FAIL_LIST)) # Test all failure of last time # don't forget to try to run them again again : $(MAKE) internal_again LOG=again.log LONGLOG=again.llg internal_again : clean_fail $(addsuffix .res,$(TS_FAIL_LIST)) \ $(addsuffix .ref,$(TF_FAIL_LIST)) \ $(addsuffix .elg,$(EXEC_FAIL_LIST) $(TS_FAIL_LIST)) grep fails $(LOG) all_compilations : allts alltbs allwebtbs alltf alltbf allwebtbf allto alltest alltesi alltis grep fails $(LOG) allexec : alltsexec alltbsexec allwebtbsexec alltestexec grep fails $(LOG) alltestexec: $(patsubst %.pp,%.elg,$(wildcard test/test*.pp)) allfails : grep fails $(LOG) > fails.log # these test are interactive # no redirection !!! alltesiexec: $(patsubst %.pp,%.eli,$(wildcard tesi/tesi*.pp)) alltsexec: $(patsubst %.pp,%.elg,$(wildcard ts/ts*.pp)) alltbsexec: $(patsubst %.pp,%.elg,$(wildcard tbs/tbs*.pp)) allwebtbsexec: $(patsubst %.pp,%.elg,$(wildcard webtbs/tbug*.pp)) tbsexec0to99 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs00*.pp)) tbsexec100to199 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs01*.pp)) tbsexec200to299 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs02*.pp)) tbsexec300to399 : $(patsubst %.pp,%.elg,$(wildcard tbs/tbs03*.pp)) alltisexec: $(patsubst %.pp,%.eli,$(wildcard tis/tis*.pp)) clean: -rm -f $(addsuffix /*.re*,$(DIRS)) -rm -f $(addsuffix /*$(PPUEXT),$(DIRS)) -rm -f $(addsuffix /*$(OEXT),$(DIRS)) -rm -f $(addsuffix /*.log,$(DIRS)) -rm -f $(addsuffix /*.elg,$(DIRS)) -rm -f $(addsuffix /*.exc,$(DIRS)) ifdef inlinux -rm -f $(patsubst %.pp,%$(EXEEXT),$(wildcard $(addsuffix /t*.pp,$(DIRS)))) else -rm -f $(addsuffix /*$(EXEEXT),$(DIRS)) endif -rm -f $(LOG) $(LONGLOG) faillist ts_fail tf_fail -rm -f fpcmaked ppas.sh ppas.bat retcode info : @echo This Makefile allows to test the compiler @echo compilation of 'ts*.pp' should succeed @echo compilation of 'tf*.pp' should fail @echo compilation of 'test*.pp' should succeed @echo 'to*.pp' files should also compile @echo simply run \'make tests\' to test all compilation @echo run \'make allexec\' to test also if the executables @echo created behave like the should @echo run \'make tesiexec\' to test executables @echo that require interactive mode