irc bot for announcing rss/atom feeds (http://hackage.haskell.org/package/rss2irc)

root / Makefile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
REPOURL=http://joyful.com/repos/rss2irc
MAIN=rss2irc.hs
SOURCEFILES=*hs
PKG=rss2irc
EXE=$(PKG)

BUILDFLAGS=-rtsopts -Wall -fno-warn-orphans -fno-warn-unused-do-bind -threaded -O2

#HEAPPROFFLAGS=-hc
HEAPPROFFLAGS=-ht
#HEAPPROFFLAGS=-hT

# command to run during make auto or auto2
AUTOCMD=--help
AUTO2CMD='http://losangeles.craigslist.org/cpg/index.rss' 'rss2irctestbot@irc.freenode.net/smtest' -i1 --author --link --replace '(&.*?;|<.*?>)/' -r2

# command to run during make prof, heap, coverage
REPORTCMD=-n4 -i0 http://losangeles.craigslist.org/cpg/index.rss

# viewers
VIEWHTMLCMD=open
VIEWPSCMD=open


########################################
# GENERIC - reuse across projects

TIME:=$(shell date +"%Y%m%d%H%M")

install:
	cabal install

build:
	cabal configure && cabal build

# auto-recompile and run whenever a module changes.
# sp is from searchpath.org, you might need the http://joyful.com/repos/searchpath version.
auto:
	sp --no-exts --no-default-map -o $(EXE) ghc $(BUILDFLAGS) --make $(MAIN) --run $(AUTOCMD)

auto2:
	sp --no-exts --no-default-map -o $(EXE) ghc $(BUILDFLAGS) --make $(MAIN) --run $(AUTO2CMD)

# build the -p binary used for performance and heap profiles.
# You may need to cabal install --reinstall -p some libs.
# Keep these .o files separate.
$(EXE)p: $(SOURCEFILES)
	ghc --make $(MAIN) -prof -auto-all $(BUILDFLAGS) -o $@

# build the -hpc binary used for coverage reports.
# Keep these .o files separate.
$(EXE)hpc: $(SOURCEFILES)
	ghc --make $(MAIN) -fhpc -outputdir .hpcobjs $(BUILDFLAGS) -o $@

ghci:
	ghci $(MAIN)

profs:
	mkdir -p profs

tag: emacstags

emacstags:
	@rm -f TAGS; hasktags -e $(SOURCEFILES) *.cabal

clean:
	rm -f `find . -name "*.o" -o -name "*.hi" -o -name "*~" -o -name "darcs-amend-record*"`

Clean: clean
	rm -f TAGS tags $(EXE) $(EXE)p $(EXE)hpc
	cabal clean

reports: profile heap coverage
	@echo Reports are at $(REPOURL)/profs

# generate, save and display a standard profile
profile: $(EXE)p profs
	@echo "Profiling $(REPORTCMD)"
	@./$(EXE)p +RTS -p -RTS $(REPORTCMD) #>/dev/null
	@mv $(EXE)p.prof profs/$(TIME).prof #-orig.prof #	tools/simplifyprof.hs profs/$(TIME)-orig.prof >profs/$(TIME).prof
	@(cd profs; rm -f latestprof*.txt; ln -s $(TIME).prof latestprof.txt) # ; ln -s $(TIME)-orig.prof latestprof-orig.prof
	@echo; cat profs/latestprof.txt

# generate, save and display a graphical heap profile
heap: $(EXE)p profs
	@echo "Profiling heap with $(REPORTCMD)"
	./$(EXE)p +RTS $(HEAPPROFFLAGS) -RTS $(REPORTCMD) #>/dev/null
	mv $(EXE)p.hp profs/$(TIME).hp
	(cd profs; hp2ps $(TIME).hp; rm -f latestheap.ps; ln -s $(TIME).ps latestheap.ps; rm -f *.aux)
# 	$(VIEWPSCMD) profs/latestheap.ps

# generate and display a code coverage report
coverage: $(EXE)hpc resettix profs
	@echo "Generating coverage report with $(REPORTCMD)"
	./$(EXE)hpc $(REPORTCMD) #>/dev/null
	hpc markup --destdir=profs $(EXE)hpc
	cd profs; rm -f latestcoverage.html; ln -s hpc_index.html latestcoverage.html
# 	cd profs; rm -f index.html; ln -s hpc_index.html index.html
# 	$(VIEWHTMLCMD) profs/coverage/index.html

# clear the old tick counts from a prior coverage run
resettix:
	rm -f $(EXE)hpc.tix

# misc stats reports

unreleasedcodechanges unreleased:
	@echo "code changes since last release:"
	@darcs changes --from-tag . --matches "not (name docs: or name doc: or name site: or name tools:)" | grep '*'
	@echo

codechanges:
	@echo "code changes:"
	@darcs changes --matches "not (name docs: or name site: or name tools:)" | egrep '^ +(\*|tagged)'
	@echo

########################################
# THIS PROJECT

deploy: buildonly /usr/local/bin/$(EXE)

buildonly:
	cabal build

/usr/local/bin/$(EXE): dist/build/$(PKG)/$(EXE)
	rm -f $@
	cp $< $@

listbinaries:
	ls -lt rss2irc rss2irc-*

########################################
# THIS REPO

-include Makefile.local