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


# Only do this in leaf directories (important, this)
sof's avatar
sof committed
11 12 13 14 15 16 17

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)/{} \; )

18 19 20 21 22 23 24 25 26 27
ifeq "$(SUBDIRS)" ""
all ::
	@echo HC = $(HC)
	@echo HC_OPTS = $(HC_OPTS)
	@echo RUNTEST_OPTS = $(RUNTEST_OPTS)


all :: runtests
endif

sof's avatar
sof committed
28 29
# Bogosity needed here to cope with .exe suffix for strip & size files.
# (shouldn't have to be our problem.)
sof's avatar
sof committed
30
ifneq "$(HC_FAIL)" "YES"
31
ifneq "$(NoFibWithGHCi)" "YES"
32
$(NOFIB_PROG_WAY) : $(OBJS)
33 34
	@echo ==nofib== $(NOFIB_PROG): time to link $(NOFIB_PROG) follows...
	@$(TIME) $(HC) $(HC_OPTS) -o $@ $^ $(LIBS)
sof's avatar
sof committed
35
endif
36 37 38
endif


39 40 41 42
ifeq "$(STDIN_FILE)" ""
STDIN_FILE = $(wildcard $(NOFIB_PROG).stdin)
endif

43
ifeq "$(NoFibWithGHCi)" "YES"
44 45 46
STDIN = $(NOFIB_PROG).stdin.tmp
GHCI_HC_OPTS = $(filter-out -l% -Rghc-timing,$(HC_OPTS))

47 48
runtests ::
	@echo "==nofib== $(NOFIB_PROG): time to compile & run $(NOFIB_PROG) follows..."
49 50 51
	@$(RM) $(STDIN)
	@echo ":set args $(PROG_ARGS)" > $(STDIN)
	@echo "Main.main" >>$(STDIN) 
52
	@cat /dev/null $(STDIN_FILE) >> $(STDIN)
53
	@$(TIME) $(RUNTEST) $(GHC_INPLACE) --interactive -v0 -Wnot \
54
			-i $(STDIN) \
55 56
	  		$(addprefix -o1 ,$(wildcard $(NOFIB_PROG).stdout*)) \
	  		$(addprefix -o2 ,$(wildcard $(NOFIB_PROG).stderr*)) \
57
			$(RUNTEST_OPTS) $(GHCI_HC_OPTS) Main
58
	@$(RM) $(STDIN)
59
else 
60

61
ifneq "$(NOFIB_PROG_WAY)" ""
62 63 64 65
ifeq "$(way)" "mp"
# The parallel prg is actually a Perl skript => can't strip it -- HWL
size :: $(NOFIB_PROG_WAY)
	@echo ==nofib== $(NOFIB_PROG): cannot strip parallel program, omitting size info
66 67 68 69

runtests :: $(NOFIB_PROG_WAY) size
	@echo ==nofib== $(NOFIB_PROG): cannot do an automatic check of stdout with the parallel system, sorry
	@echo ==nofib== $(NOFIB_PROG): run the following command by hand
70
	@echo                          ./$< $(RUNTEST_OPTS) $(PROG_ARGS)
71 72
	@echo ==nofib== $(NOFIB_PROG): output should be
	@cat $(wildcard $(NOFIB_PROG).stdout*)
73
else
74

75 76
size :: $(NOFIB_PROG_WAY)
	@$(STRIP) $(NOFIB_PROG_WAY)$(exeext)
77
	@echo ==nofib== $(NOFIB_PROG): size of $(NOFIB_PROG) follows...
78
	@$(SIZE) $(NOFIB_PROG_WAY)$(exeext)
79

80 81
runtests :: $(NOFIB_PROG_WAY) size
	@echo ==nofib== $(NOFIB_PROG): time to run $(NOFIB_PROG) follows...
82
	@$(TIME) $(RUNTEST) ./$< \
83
	  $(addprefix -i,  $(STDIN_FILE)) \
84 85
	  $(addprefix -o1 ,$(wildcard $(NOFIB_PROG).stdout*)) \
	  $(addprefix -o2 ,$(wildcard $(NOFIB_PROG).stderr*)) \
86
	  $(RUNTEST_OPTS) $(PROG_ARGS)
87 88
endif

sof's avatar
sof committed
89
else
90 91
size ::
	@:
sof's avatar
sof committed
92 93 94
runtests ::
	@:
endif
95

96 97
endif # GHCI

98 99 100 101 102
# 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

include $(FPTOOLS_TOP)/mk/target.mk