target.mk 3.92 KB
Newer Older
1 2 3 4 5 6 7 8
#################################################################################
#
#			target.mk
#
#		nofib standard target rules
#
#################################################################################

9 10 11 12 13
# Urk!  We have to do this here because $(OBJS) is meaningless until
# we set this (see fptools/mk/paths.mk and the top of
# fptools/mk/target.mk).  We'd like to include fptools/mk/target.mk
# earlier, but we don't for cosmetic reasons (see end of file).
PRE_SRCS := $(ALL_SRCS)
14 15

# Only do this in leaf directories (important, this)
sof's avatar
sof committed
16 17 18 19 20 21 22

nofib-dist-pre::
	-rm -rf $(SRC_DIST_DIR)
	-rm -f $(SRC_DIST_NAME).tar.gz
	(cd $(FPTOOLS_TOP_ABS)/nofib; find $(SRC_DIST_DIRS) -type d \( -name CVS -prune -o -name SRC -prune -o -name tests -prune -o -exec $(MKDIRHIER) $(SRC_DIST_DIR)/{} \; \) ; )
	(cd $(FPTOOLS_TOP_ABS)/nofib; find $(SRC_DIST_DIRS) -name CVS -prune -o -name SRC -prune -o -name tests -prune -o -name "*~" -prune -o -name ".cvsignore" -prune -o -type l -exec $(LN_S) $(FPTOOLS_TOP_ABS)/nofib/{} $(SRC_DIST_DIR)/{} \; )

23 24 25 26 27 28 29 30 31 32
ifeq "$(SUBDIRS)" ""
all ::
	@echo HC = $(HC)
	@echo HC_OPTS = $(HC_OPTS)
	@echo RUNTEST_OPTS = $(RUNTEST_OPTS)


all :: runtests
endif

33 34 35 36 37 38
ifeq "$(STDIN_FILE)" ""
STDIN_FILE = $(wildcard $(NOFIB_PROG).$(mode)stdin)
ifeq "$(STDIN_FILE)" ""
STDIN_FILE = $(wildcard $(NOFIB_PROG).stdin)
endif
endif
rje's avatar
rje committed
39 40


sof's avatar
sof committed
41 42
# Bogosity needed here to cope with .exe suffix for strip & size files.
# (shouldn't have to be our problem.)
sof's avatar
sof committed
43
ifneq "$(HC_FAIL)" "YES"
44
ifneq "$(NoFibWithGHCi)" "YES"
45
$(NOFIB_PROG_WAY) : $(OBJS)
46
	@echo ==nofib$(_way)== $(NOFIB_PROG): time to link $(NOFIB_PROG) follows...
47
	@$(TIME) $(HC) $(HC_OPTS) -o $@ $^ $(LIBS)
sof's avatar
sof committed
48
endif
49 50 51 52
endif


ifeq "$(NoFibWithGHCi)" "YES"
53
STDIN = $(NOFIB_PROG).stdin.tmp
54
GHCI_HC_OPTS = $(filter-out -l% -Rghc-timing -O%,$(HC_OPTS))
55

56
runtests ::
57
	@echo "==nofib$(_way)== $(NOFIB_PROG): time to compile & run $(NOFIB_PROG) follows..."
58 59 60
	@$(RM) $(STDIN)
	@echo ":set args $(PROG_ARGS)" > $(STDIN)
	@echo "Main.main" >>$(STDIN) 
61
	@cat /dev/null $(STDIN_FILE) >> $(STDIN)
62
	echo $(GHCI_HC_OPTS)
63
	@$(TIME) $(RUNTEST) $(HC) $(RUNTEST_OPTS) \
64
			-i $(STDIN) \
65 66
	  		$(addprefix -o1 ,$(wildcard $(NOFIB_PROG).$(mode)stdout*)) \
	  		$(addprefix -o2 ,$(wildcard $(NOFIB_PROG).$(mode)stderr*)) \
67 68
			-- --interactive -v0 -Wnot \
			$(GHCI_HC_OPTS) Main
69
	@$(RM) $(STDIN)
70
else 
71

72 73 74 75 76 77 78 79 80
time_runtest = \
	$(TIME) $(RUNTEST) ./$< \
	  $(addprefix -i  ,$(STDIN_FILE)) \
	  $(addprefix -o1 ,$(wildcard $(NOFIB_PROG).$(mode)stdout*) $(wildcard $(NOFIB_PROG).stdout*)) \
	  $(addprefix -o2 ,$(wildcard $(NOFIB_PROG).$(mode)stderr*) $(wildcard $(NOFIB_PROG).stderr*)) \
	  $(RUNTEST_OPTS) $(PROG_ARGS)

enum = $(strip $(shell perl -e 'for ($$i = 1; $$i <= $(1); $$i++) { print "$$i "; }'))

81
ifneq "$(NOFIB_PROG_WAY)" ""
82 83 84
ifeq "$(way)" "mp"
# The parallel prg is actually a Perl skript => can't strip it -- HWL
size :: $(NOFIB_PROG_WAY)
85
	@echo ==nofib$(_way)== $(NOFIB_PROG): cannot strip parallel program, omitting size info
86 87

runtests :: $(NOFIB_PROG_WAY) size
88 89
	@echo ==nofib$(_way)== $(NOFIB_PROG): cannot do an automatic check of stdout with the parallel system, sorry
	@echo ==nofib$(_way)== $(NOFIB_PROG): run the following command by hand
90
	@echo                          ./$< $(RUNTEST_OPTS) $(PROG_ARGS)
91
	@echo ==nofib$(_way)== $(NOFIB_PROG): output should be
rje's avatar
rje committed
92
	@cat $(wildcard $(NOFIB_PROG).$(mode)stdout*)
93
else
94

95 96
size :: $(NOFIB_PROG_WAY)
	@$(STRIP) $(NOFIB_PROG_WAY)$(exeext)
97
	@echo ==nofib$(_way)== $(NOFIB_PROG): size of $(NOFIB_PROG) follows...
98
	@$(SIZE) $(NOFIB_PROG_WAY)$(exeext)
99

100
runtests :: $(NOFIB_PROG_WAY) size
101
	@echo ==nofib$(_way)== $(NOFIB_PROG): time to run $(NOFIB_PROG) follows...
102
	$(foreach $i, $(call enum, $(NoFibRuns)), $(time_runtest);)
103 104
endif

sof's avatar
sof committed
105
else
106 107
size ::
	@:
sof's avatar
sof committed
108 109 110
runtests ::
	@:
endif
111

112 113
endif # GHCI

114 115 116 117
# Include standard boilerplate
# We do this at the end for cosmetic reasons: it means that the "normal-way"
# runtests will precede the "other-way" recursive invocations of make

118
include $(TOP)/mk/ghc-target.mk
119 120

# Override suffix rules
121
include $(TOP)/mk/suffix.mk