summaryrefslogtreecommitdiff
path: root/debian/rules
blob: c6a2ab98ae34e6b796fcfdd9685adc30c3ba82e2 (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
#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS  = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

%:
	dh $@

MODES = address citmatch contact filter link notify post proxy search spell
STD_WRAPPERS = $(MODES:%=bin/e%)
WRAPPERS = $(STD_WRAPPERS) bin/esummary
AS_IS_SCRIPTS = amino-acid-composition between-two-genes edirutil \
	        entrez-phrase-search filter-stop-words ftp-* gbf2xml \
	        join-into-groups-of nquire reorder-columns sort-uniq-count* \
	        word-at-a-time xy-plot

GOCODE   = /usr/share/gocode
GOLIBSRC = $(wildcard $(GOCODE)/src/golang.org/x/text)

ifneq (,$(GOLIBSRC))
  export GOPATH = $(CURDIR)/debian/gopath
  GOLIBS = $(GOLIBSRC:$(GOCODE)/%=$(GOPATH)/%)

  GOVERSION := $(word 3,$(shell go version)) # go version **goX.Y.Z** OS/CPU
  GO_IS_OLD := $(shell dpkg --compare-versions 0$(GOVERSION) ge 0go1.8 || echo $$?)
  ifneq (,$(GO_IS_OLD))
    export PATH := /usr/lib/go-1.8/bin:$(PATH)
  endif

  $(GOLIBS): $(GOPATH)/%: /usr/share/gocode/%
	mkdir -p $(dir $@)
	ln -s $< $@
endif

bin/edirect: edirect.pl
	mkdir -p bin
	install $< $@

$(STD_WRAPPERS): bin/e%: bin/edirect
	echo '#!/bin/sh' > $@
	echo 'exec /usr/bin/edirect -$* "$$@"' >> $@
	chmod +x $@

bin/esummary: bin/edirect
	echo '#!/bin/sh' > $@
	echo 'exec /usr/bin/edirect -fetch -format docsum "$$@"' >> $@
	chmod +x $@

override_dh_auto_build: $(WRAPPERS) $(GOLIBS)
	dh_auto_build
	install $(AS_IS_SCRIPTS) debian/efetch debian/einfo bin/
# Always use gccgo?  The resulting binary would be much smaller, but
# pull in a large shared library with few other reverse dependencies.
	go build -v -gccgoflags '$(CFLAGS) $(LDFLAGS)' -o bin/xtract xtract.go

override_dh_auto_clean:
	dh_auto_clean
	rm -rf bin $(GOPATH)