File: rules

package info (click to toggle)
nim 0.19.4-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 462,356 kB
  • sloc: sh: 11,089; ansic: 4,699; makefile: 706; python: 309; sql: 297; asm: 141; xml: 13
file content (97 lines) | stat: -rwxr-xr-x 4,244 bytes parent folder | download
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
#!/usr/bin/make -f

export DH_VERBOSE=1
include /usr/share/dpkg/default.mk

export XDG_CACHE_HOME=$(CURDIR)/.cache
export XDG_CONFIG_HOME=$(CURDIR)/.config
#export XDG_DATA_HOME=$(CURDIR)/.data

platform_tr = $(shell { grep '^$(1)\b' debian/platforms.table || echo '	unsupported:$(1)'; } | cut -f2)

NIMFLAGS = $(addprefix --passC:,$(CPPFLAGS)) $(addprefix --passC:,$(CFLAGS)) $(addprefix --passL:,$(LDFLAGS))
ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
	# work around https://github.com/nim-lang/Nim/issues/3165
	NIMFLAGS += --parallelBuild:1
endif

%:
	dh $@

override_dh_auto_build:
	PATH=./bin/:$$PATH  ./build.sh --os $(call platform_tr,$(DEB_HOST_ARCH_OS)) --cpu $(call platform_tr,$(DEB_HOST_ARCH_CPU))
	PATH=./bin/:$$PATH ./bin/nim c $(NIMFLAGS) koch
	# Build until convergence; we must do this here, not dh_auto_test, to pick up
	# any changes in debian/patches. see also https://github.com/nim-lang/csources/issues/12
	echo "running koch boot"
	PATH=./bin/:$$PATH ./koch boot -d:release $(EXTRA_KOCHFLAGS) $(NIMFLAGS)
	#PATH=./bin/:$$PATH ./koch web
	echo "running koch web to generate docs into doc/html"
	PATH=./bin/:$$PATH ./koch docs
	echo "running koch tools to build nimble, nimsuggest, nimgrep"
	PATH=./bin/:$$PATH ./koch tools
	echo "generating manpages"
	help2man --name="Nim Language Compiler" -s1 -N --version-string="$(DEB_VERSION)" -i debian/nim.h2m -o debian/nim.1 ./bin/nim
	help2man --name="Nimsuggest"            -s1 -N --version-string="$(DEB_VERSION)" -i debian/nim.h2m -o debian/nimsuggest.1 ./bin/nimsuggest
	help2man --name="Nimgrep"               -s1 -N --version-string="$(DEB_VERSION)" -i debian/nim.h2m -o debian/nimgrep.1 ./bin/nimgrep
	PATH=./bin/:$$PATH help2man --name="Nim Package Installer" -s1 -N --version-string="$(DEB_VERSION)" -i debian/nim.h2m -o debian/nimble.1 ./bin/nimble
	echo "running koch distrohelper to generate install.sh"
	./koch distrohelper

override_dh_auto_install:
	echo "running install.sh to populate debian/tmp"
	./install.sh debian/tmp
	# remove the compiler sources directory
	# https://github.com/nim-lang/Nim/issues/4866#issuecomment-271194805
	rm debian/tmp/nim/compiler -rf
	for fn in nimble nimsuggest nimgrep; do cp ./bin/$$fn debian/tmp/nim/bin/; done
	# Install docs. There is no version number in the path.
	install -d debian/html
	install -D doc/html/*.html debian/html
	find debian/html -name '*.idx' -delete
	ln -sf manual.html debian/html/index.html
	# install bash/zsh completion scripts
	install -D -m 644 tools/nim.bash-completion          debian/nim/usr/share/bash-completion/completions/nim
	install -D -m 644 dist/nimble/nimble.bash-completion debian/nim/usr/share/bash-completion/completions/nimble
	install -D -m 644 tools/nim.zsh-completion           debian/nim/usr/share/zsh/vendor-completions/_nim
	install -D -m 644 dist/nimble/nimble.zsh-completion  debian/nim/usr/share/zsh/vendor-completions/_nimble

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	#PATH=./bin:$$PATH ./koch test
	if [ -f compiler/nim2 ]; then cmp ./bin/nim compiler/nim2; else cmp ./bin/nim compiler/nim1; fi
	# TODO: do this with autopkgtest instead; it requires libsqlite3-0 and nodejs
	#PATH=./bin:$$PATH ./koch test
endif

override_dh_auto_clean:
	rm -f ./koch tools/nimweb tools/niminst/niminst compiler/nim compiler/nim0 compiler/nim1 compiler/nim2
	rm -f lib/pure/strutils_examples.nim
	rm -rf bin rnimcache
	rm -rf web/upload/
	rm -rf dist/nimble0
	rm -rf dist/nimble/src/nimble
	# TODO: use this instead when https://github.com/nim-lang/Nim/issues/2127 is fixed
	#PATH=./bin:$$PATH ./koch clean
	find . -name nimcache \
		-prune -execdir rm -rf nimcache \;
	find . -name '*.o' -not -name 'koch_icon.o' -and -not -name 'nim_icon.o' \
		-delete -print
	find doc -name '*.idx' -delete -print
	find doc -name '*.html' -delete -print
	find examples lib tests -type f -executable -and -not -name '*.nim' \
		-delete -print
	rm -f tests/dll/libnimrtl.dylib
	rm -f testament.db testresults.*

override_dh_dwz:
	# dwz cannot handle all the binaries together
	dh_dwz --no-dwz-multifile

override_dh_installdocs:
	dh_installdocs -Xcopying.txt

override_dh_clean:
	dh_clean
	rm -f debian/nim.1 debian/nimble.1 debian/nimgrep.1 debian/nimsuggest.1
	rm -rf debian/html