File: Makefile

package info (click to toggle)
cfv 1.18.2-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 760 kB
  • ctags: 510
  • sloc: python: 3,502; sh: 147; makefile: 97
file content (84 lines) | stat: -rw-r--r-- 3,305 bytes parent folder | download | duplicates (4)
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
PYTHON=python
prefix=/usr/local
exec_prefix=${prefix}

#finds the site-packages dir that matches the selected prefix, or if none do, falls back to wherever it can find one..
pkgdir=`$(PYTHON) -c 'import sys,re; x=filter(lambda x: re.match("$(prefix).*site-packages",x),sys.path); y=filter(lambda y: re.search("site-packages",y),sys.path); x.sort(lambda x,y: cmp(len(x),len(y))); y.sort(lambda x,y: cmp(len(x),len(y))); x.extend(y); print x[0]'`
#nice little expression, huh? ;)

bindir=${exec_prefix}/bin
mandir=${prefix}/man
install=/usr/bin/install -c
install_dir=${install} -d
install_data=${install} -m 0644
install_script=${install} -m 0755

foo:
	@echo 'to install cfv, type make install or install-wrapper.'
	@echo "manpage will be installed to: $(mandir)/man1"
	@echo ""
	@echo '"make install" will install like a standard script in'
	@echo "$(bindir)"
	@echo ""
	@echo '"make install-wrapper" will install a byte-compiled version in'
	@echo "$(pkgdir)"
	@echo 'with a small wrapper script in $(bindir)'
	@echo 'this allows for faster loading time since python does not need'
	@echo 'to parse the entire script every load.'
	@echo ""
	@echo 'You may edit the Makefile if you want to install somewhere else.'
	@echo ""
	@echo "Note that this method does not change how fast cfv actually runs,"
	@echo "merely the time it takes from when you hit enter till it actually"
	@echo "starts doing something.  For processing lots of files, this amount"
	@echo "of time will be inconsequential."


#this will create a wrapper script that calls python directly (if we can find it), or using the bin/env trick.
#we don't need to check for PYTHON being set to something, since os.path.join handles the case of the component being an absolute path
cfv.wrapper:
	$(PYTHON) -c 'import string,os; py=filter(lambda x: os.path.isfile(x),map(lambda x: os.path.join(x,"$(PYTHON)"),string.split(os.environ["PATH"],":"))); py.append(" /usr/bin/env $(PYTHON)"); open("cfv.wrapper","w").write("#!%s\nimport cfv\ncfv.main()\n"%py[0])'

$(DESTDIR)$(mandir)/man1 $(DESTDIR)$(bindir):
	$(install_dir) $@

install-wrapper-only: $(DESTDIR)$(bindir) cfv.wrapper install_man
	$(install_data) cfv $(DESTDIR)$(pkgdir)/cfv.py
	$(install_script) cfv.wrapper $(DESTDIR)$(bindir)/cfv

install-wrapper: install-wrapper-only
	$(PYTHON) -c "import py_compile; py_compile.compile('$(DESTDIR)$(pkgdir)/cfv.py')" 
	$(PYTHON) -O -c "import py_compile; py_compile.compile('$(DESTDIR)$(pkgdir)/cfv.py')" 

install: $(DESTDIR)$(bindir) install_man
	$(install_script) cfv $(DESTDIR)$(bindir)/cfv

install_man: $(DESTDIR)$(mandir)/man1
	$(install_data) cfv.1 $(DESTDIR)$(mandir)/man1/cfv.1

clean:
	-rm *.py[co] cfv.wrapper

distclean: clean
	-rm -r cfv.nsi tags test/test.log `find . -regex '.*~\|.*/\.#.*' -o -name CVS -o -name .cvsignore`

distclean-unixsrc: distclean
	-rm cfv.bat cfv.txt

cfv.txt: %.txt: %.1
	LANG=C man -l $< | sed -e 's/.//g' > $@

distclean-winsrc: distclean cfv.txt
	-rm Makefile cfv.1
	mv cfv cfv.py
	todos *.txt COPYING README Changelog cfv.bat cfv.py test/*.py

PY2EXEDIR=~/mnt/temp/cfv
nsis-prepare: cfv.txt
	#hahaha, ugly hardcodedhackness
	cp cfv.txt cfv.nsi setup*.py $(PY2EXEDIR)
	cp Changelog $(PY2EXEDIR)/Changelog.txt
	cp COPYING $(PY2EXEDIR)/COPYING.txt
	cp cfv $(PY2EXEDIR)/cfv.py
	todos $(PY2EXEDIR)/*.txt