Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2
3 export DH_VERBOSE=1
4 include /usr/share/dpkg/default.mk
5
6 export XDG_CACHE_HOME=$(CURDIR)/.cache
7 export XDG_CONFIG_HOME=$(CURDIR)/.config
8 #export XDG_DATA_HOME=$(CURDIR)/.data
9
10 platform_tr = $(shell { grep '^$(1)\b' debian/platforms.table || echo ' unsupported:$(1)'; } | cut -f2)
11
12 NIMFLAGS = $(addprefix --passC:,$(CPPFLAGS)) $(addprefix --passC:,$(CFLAGS)) $(addprefix --passL:,$(LDFLAGS))
13 ifneq ($(DEB_HOST_ARCH),i386)
14 NIMFLAGS += -d:nimUse64BitCTime
15 endif
16
17 %:
18 dh $@
19
20 override_dh_auto_build:
21 echo "running make to build ./bin/nim from csources"
22 PATH=./bin/:$$PATH make -j
23 echo "building ./koch"
24 PATH=./bin/:$$PATH ./bin/nim c -d:release $(NIMFLAGS) koch
25 # Build until convergence; we must do this here, not dh_auto_test, to pick up
26 # any changes in debian/patches. see also https://github.com/nim-lang/csources/issues/12
27 echo "running koch boot to build ./bin/nim from .nim sources"
28 PATH=./bin/:$$PATH ./koch boot -d:release $(NIMFLAGS)
29 echo "running koch web to generate docs into doc/html"
30 PATH=./bin/:$$PATH ./koch docs --docCmd:skip
31 echo "running koch tools to build nimble, nimsuggest, nimgrep"
32 #PATH=./bin/:$$PATH ./koch tools
33 PATH=./bin/:$$PATH ./koch toolsnonimble
34 PATH=./bin/:$$PATH ./koch nimble
35 echo "generating manpages"
36 help2man --name="Nim Language Compiler" -s1 -N --version-string="$(DEB_VERSION)" -i debian/nim.h2m -o debian/nim.1 ./bin/nim
37 help2man --name="Nimsuggest" -s1 -N --version-string="$(DEB_VERSION)" -i debian/nim.h2m -o debian/nimsuggest.1 ./bin/nimsuggest
38 #nimgrep relies on old libpcre1 (a.k.a pcre3) at runtime through dlopen()
39 #help2man --name="Nimgrep" -s1 -N --version-string="$(DEB_VERSION)" -i debian/nim.h2m -o debian/nimgrep.1 ./bin/nimgrep
40 help2man --name="Nimpretty" -s1 -N --version-string="$(DEB_VERSION)" -i debian/nim.h2m -o debian/nimpretty.1 ./bin/nimpretty
41 PATH=./bin/:$$PATH help2man --name="Nim Package Installer" -s1 -N --version-string="$(DEB_VERSION)" -i debian/nim.h2m -o debian/nimble.1 ./bin/nimble
42 echo "running koch distrohelper to generate install.sh"
43 ./koch distrohelper
44
45 override_dh_auto_install:
46 echo "running install.sh to populate debian/tmp"
47 ./install.sh debian/tmp
48 # remove the compiler sources directory
49 # https://github.com/nim-lang/Nim/issues/4866#issuecomment-271194805
50 rm debian/tmp/nim/compiler -rf
51 for fn in nimble nimsuggest nimgrep nimpretty nim-gdb; do install ./bin/$$fn debian/tmp/nim/bin/; done
52 # Install tools
53 install -D -m 644 tools/dochack/dochack.nim debian/tmp/nim/tools/dochack/dochack.nim
54 install -D -m 644 tools/dochack/fuzzysearch.nim debian/tmp/nim/tools/dochack/fuzzysearch.nim
55 install -D -m 644 tools/dochack/dochack.js debian/tmp/nim/tools/dochack/dochack.js
56 install -D -m 644 tools/debug/nim-gdb.py debian/tmp/nim/tools/nim-gdb.py
57 # Install docs. There is no version number in the path.
58 install -d debian/html
59 install -D doc/html/*.html doc/html/*.css doc/html/*.js debian/html
60 find debian/html -name '*.idx' -delete
61 ln -sf manual.html debian/html/index.html
62 # install bash/zsh completion scripts
63 install -D -m 644 tools/nim.bash-completion debian/nim/usr/share/bash-completion/completions/nim
64 install -D -m 644 dist/nimble/nimble.bash-completion debian/nim/usr/share/bash-completion/completions/nimble
65 install -D -m 644 tools/nim.zsh-completion debian/nim/usr/share/zsh/vendor-completions/_nim
66 install -D -m 644 dist/nimble/nimble.zsh-completion debian/nim/usr/share/zsh/vendor-completions/_nimble
67 rm -f debian/tmp/nim/compiler.nimble debian/tmp/nim/doc/advopt.txt debian/tmp/nim/nim.nimble
68 rm -f debian/tmp/nim/doc/basicopt.txt debian/tmp/nim/doc/html/overview.html
69 install -D -m 644 doc/nimdoc.css debian/nim/usr/lib/nim/doc/nimdoc.css
70 rm debian/tmp/nim/doc/nimdoc.css
71 #nimgrep relies on pcre3, skip it until fixed (https://github.com/nim-lang/Nim/issues/23668)
72 rm debian/tmp/nim/bin/nimgrep
73
74 override_dh_auto_test:
75 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
76 #PATH=./bin:$$PATH ./koch test
77 if [ -f compiler/nim2 ]; then cmp ./bin/nim compiler/nim2; else cmp ./bin/nim compiler/nim1; fi
78 # TODO: do this with autopkgtest instead; it requires libsqlite3-0 and nodejs
79 #PATH=./bin:$$PATH ./koch test
80 endif
81
82 override_dh_auto_clean:
83 rm -f ./koch tools/nimweb tools/niminst/niminst compiler/nim compiler/nim0 compiler/nim1 compiler/nim2
84 rm -f lib/pure/strutils_examples.nim
85 rm -f bin/atlas bin/nim bin/nim_dbg bin/nimble bin/nimgrep bin/nimpretty bin/nimsuggest bin/testament
86 rm -rf rnimcache tools/dochack/dochack.js doc/html/ .cache
87 rm -rf web/upload/
88 rm -rf dist/nimble0 dist/nimble/src/nimble
89 # TODO: use this instead when https://github.com/nim-lang/Nim/issues/2127 is fixed
90 #PATH=./bin:$$PATH ./koch clean
91 find . -name nimcache \
92 -prune -execdir rm -rf nimcache \;
93 find . -name '*.o' -not -name 'koch_icon.o' -and -not -name 'nim_icon.o' \
94 -delete -print
95 find doc -name '*.idx' -delete -print
96 find doc -name '*.html' -delete -print
97 find lib tests -type f -executable -and -not -name '*.nim' \
98 -delete -print
99 rm -f tests/dll/libnimrtl.dylib
100 rm -f testament.db testresults.*
101
102 override_dh_dwz:
103 # dwz cannot handle all the binaries together
104 # dh_dwz --no-dwz-multifile
105 # dwz errors out when handling nim
106 true
107
108 override_dh_installdocs:
109 dh_installdocs -Xcopying.txt
110
111 override_dh_clean:
112 dh_clean
113 rm -f debian/nim.1 debian/nimble.1 debian/nimgrep.1 debian/nimsuggest.1 debian/nimpretty.1
114 rm -rf debian/html