summaryrefslogtreecommitdiffstats
path: root/src/Makefile-files
blob: 490ff3152eb1aeacb9955eda55221108bb3c2080 (plain)
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
# -*- makefile -*-

if HAVE_PYTHON

nodist_nbblib_PYTHON += src/nbblib/package.py
CLEANFILES  += src/nbblib/package.py

nbblib_PYTHON += src/nbblib/__init__.py
nbblib_PYTHON += src/nbblib/bs.py
nbblib_PYTHON += src/nbblib/commands.py
nbblib_PYTHON += src/nbblib/main.py
nbblib_PYTHON += src/nbblib/nbbcommands.py
nbblib_PYTHON += src/nbblib/plugins.py
nbblib_PYTHON += src/nbblib/progutils.py
nbblib_PYTHON += src/nbblib/vcs.py

lint: lint-local

lint-local: lint-local-pylint
lint-local: lint-local-pychecker

lint-local-pylint:
	cd src && pylint --zope=y --acquired-members=name,plugins nbb nbblib

lint-local-pychecker:
	cd src && pychecker --limit=500 $$(for f in nbblib/*.py; do echo nbblib.$$(basename "$$f" .py); done)

# Put all python source files, whether changed or verbatim,
# into builddir, such that we can run tests in builddir.
ALL_LOCAL += all-local-nbblib
all-local-nbblib:
	@for f in $(nbblib_PYTHON); do \
		if test -f "$(top_builddir)/$$f" && test "$(top_srcdir)/$$f" -ot "$(top_builddir)/$$f"; then :; else \
			echo "INFO: Updating $$f in $(top_builddir) from $(top_srcdir)"; \
			cp -f "$(top_srcdir)/$$f" "$(top_builddir)/$$f"; \
		fi; \
	done

if HAVE_PYDOC

#SUFFIXES = html py
#.py.html:
#	cd src && $(PYDOC) -w ""
#	mkdir -p pydoc
#	mv src/$<

ALL_LOCAL += all-local-nbblib-pydoc
all-local-nbblib-pydoc: all-local-nbblib
	@mkdir -p pydoc && \
	echo "Entering directory '$$PWD'"; \
	for modfile in src/nbblib/*.py; do \
		mod="nbblib.$$(basename "$$modfile" .py)"; \
		test "$$mod" = "nbblib.__init__" && mod="nbblib"; \
		htmlfile="pydoc/$${mod}.html"; \
		: ls -l --full-time "$$htmlfile" "$$modfile"; \
		: "Darn. Better let MAKE calculate the deps, perhaps?" ; \
                rebuild="no"; \
		if test -f "$$htmlfile"; then \
			if test "$$modfile" -nt "$$htmlfile"; then \
				rebuild="yes"; \
			fi; \
		else \
			rebuild="yes"; \
		fi; \
		if test "$$rebuild" = "yes"; then \
			echo $(PYDOC) -w "$${mod}"; \
			( cd src && $(PYDOC) -w "$${mod}" ); \
			if test -f "$$htmlfile" && cmp "src/$${mod}.html" "$$htmlfile" > /dev/null; \
			then rm -f "src/$${mod}.html"; \
			else echo "INFO: Updating pydoc/$${mod}.html"; \
			     mv -f "src/$${mod}.html" "$$htmlfile"; fi; \
		fi; \
	done; \
	echo "Leaving directory '$$PWD'"

install-data-local:
	$(INSTALL) -d -m 0755 $(DESTDIR)$(htmldir)
	$(INSTALL) -m 0644 pydoc/*.html $(DESTDIR)$(htmldir)/

uninstall-local:
	rm -f $(DESTDIR)$(htmldir)/*.html
endif

bin_SCRIPTS += src/nbb
CLEANFILES  += src/nbb

# We cannot create src/nbb from src/nbb.in in configure.ac/config.status.
# pythondir is defined as ${something}foobar, and that needs expansion.
EXTRA_DIST += src/nbb.in
src/nbb: src/nbb.in $(nodist_nbblib_PYTHON) $(nbblib_PYTHON) Makefile
	$(SED) \
		-e 's&[@]pkgpythondir@&$(pkgpythondir)&g' \
		-e 's&[@]PYTHON@&$(PYTHON)&g' \
		-e 's&[@]PACKAGE_VERSION@&$(PACKAGE_VERSION)&g' \
		< $(srcdir)/src/nbb.in > src/nbb.new
	@if test "x$$($(GREP) '@[a-zA-Z0-9_]\{1,\}@' src/nbb.new)" = "x"; then :; \
	else \
		echo "FATAL: Unsubstituted markers remain in src/nbb.new."; \
		$(GREP) '@[a-zA-Z0-9_]\{1,\}@' src/nbb.new; \
		exit 1; \
	fi
	@if test -f src/nbb && cmp src/nbb.new src/nbb > /dev/null; \
	then rm -f src/nbb.new; \
	else mv -f src/nbb.new src/nbb; echo "INFO: Updating src/nbb"; fi
	@chmod +x src/nbb

endif

clean-local: clean-local-nbblib clean-local-nbblib-pydoc
clean-local-nbblib:
	rm -f src/nbblib/*.pyc
	@top_srcdir="$$(cd "$(top_srcdir)" > /dev/null 2>&1 && pwd)"; \
	top_builddir="$$(cd "$(top_builddir)" > /dev/null 2>&1 && pwd)"; \
	if test "x$${top_srcdir}" = "x$${top_builddir}"; then :; else \
		for f in $(nbblib_PYTHON); do \
			echo rm -f "$(top_builddir)/$$f"; \
			rm -f "$(top_builddir)/$$f"; \
		done; \
	fi

clean-local-nbblib-pydoc:
	rm -rf pydoc

# End of Makefile-files.