| 1 |
#!/usr/bin/make -f |
| 2 |
|
| 3 |
export DEB_BUILD_MAINT_OPTIONS = hardening=+all |
| 4 |
|
| 5 |
DPKG_EXPORT_BUILDFLAGS = 1 |
| 6 |
include /usr/share/dpkg/default.mk |
| 7 |
|
| 8 |
export CGO_CFLAGS = $(CFLAGS) |
| 9 |
export CGO_CPPFLAGS = $(CPPFLAGS) |
| 10 |
export CGO_CXXFLAGS = $(CXXFLAGS) # probably irrelevant |
| 11 |
export CGO_FFLAGS = $(FFLAGS) # even more so |
| 12 |
export CGO_LDFLAGS = $(LDFLAGS) |
| 13 |
|
| 14 |
export DH_GOPKG = main |
| 15 |
|
| 16 |
%: |
| 17 |
dh $@ --with=golang,python3 |
| 18 |
|
| 19 |
PACKAGE = ncbi-entrez-direct |
| 20 |
LIB_DIR = /usr/lib/$(PACKAGE) |
| 21 |
PKG_BIN_DIR = debian/$(PACKAGE)/usr/bin |
| 22 |
|
| 23 |
WRAPPERS = $(filter-out bin/edict.sh, $(GO_APPS:%=bin/%.sh)) |
| 24 |
AS_IS_SCRIPTS = accn-at-a-time amino-acid-composition asn2ref \ |
| 25 |
between-two-genes blst2tkns bsmp2info combine-uid-lists \ |
| 26 |
csv2xml custom-index difference-uid-lists \ |
| 27 |
disambiguate-nucleotides download-* ds2pme esample \ |
| 28 |
exclude-uid-lists expand-current filter-columns \ |
| 29 |
filter-record filter-stop-words find-in-gene fsa2xml \ |
| 30 |
fuse-ranges fuse-segments gbf2* gene2range gff-sort gff2xml \ |
| 31 |
gm2segs hgvs2spdi ini2xml intersect-uid-lists \ |
| 32 |
join-into-groups-of json2xml jsonl2xml just-top-hits \ |
| 33 |
pair-at-a-time pm-collect pm-refresh pma2apa pma2pme pmc2bioc \ |
| 34 |
pmc2info print-columns print-missing-subranges \ |
| 35 |
quote-grouped-elements ref2pmid refseq-nm-cds reorder-columns \ |
| 36 |
scn2xml skip-if-file-exists snp2hgvs snp2tbl \ |
| 37 |
sort-by-length sort-table sort-uniq-count* spdi2tbl \ |
| 38 |
split-at-intron systematic-mutations tbl2prod tbl2xml \ |
| 39 |
uniq-table word-at-a-time xml2fsa xml2tbl xy-plot yaml2xml |
| 40 |
PERL_SCRIPTS = run-ncbi-converter xml2json |
| 41 |
BIN_PERL_SCRIPTS = $(PERL_SCRIPTS:%=bin/%) |
| 42 |
ECOMMON_SCRIPTS = ecollect efetch efilter einfo elink epost esearch |
| 43 |
BIN_ECOMMON_SCRIPTS = $(ECOMMON_SCRIPTS:%=bin/%) |
| 44 |
XCOMMON_SCRIPTS = cit2pmid pm-clean pm-prepare pm-setup \ |
| 45 |
xfetch xfilter xinfo xlink xsearch |
| 46 |
BIN_XCOMMON_SCRIPTS = $(XCOMMON_SCRIPTS:%=bin/%) |
| 47 |
OTHER_SCRIPTS = $(wildcard archive-*) esummary nquire |
| 48 |
BIN_OTHER_SCRIPTS = $(OTHER_SCRIPTS:%=bin/%) |
| 49 |
FIX_PERL_SHEBANG = 1s,^\#!/usr/bin/env perl$$,\#!/usr/bin/perl, |
| 50 |
|
| 51 |
GOCODE = /usr/share/gocode |
| 52 |
GH = github.com |
| 53 |
GL = golang.org |
| 54 |
GOLIBSRC_ = $(GH)/fatih/color $(GH)/gabriel-vasile/mimetype \ |
| 55 |
$(GH)/gedex/inflector $(GH)/gin-contrib/sse $(GH)/gin-gonic/gin \ |
| 56 |
$(GH)/go-playground/locales \ |
| 57 |
$(GH)/go-playground/universal-translator \ |
| 58 |
$(GH)/go-playground/validator/v10 $(GH)/goccy/go-yaml \ |
| 59 |
$(GH)/klauspost/compress $(GH)/klauspost/cpuid \ |
| 60 |
$(GH)/klauspost/pgzip $(GH)/komkom/toml $(GH)/leodido/go-urn \ |
| 61 |
$(GH)/mattn/go-colorable $(GH)/mattn/go-isatty \ |
| 62 |
$(GH)/pbnjay/memory $(GH)/pelletier/go-toml/v2 $(GH)/pkg/errors \ |
| 63 |
$(GH)/rainycape/unidecode $(GH)/shirou/gopsutil \ |
| 64 |
$(GH)/stretchr/objx $(GH)/stretchr/testify \ |
| 65 |
$(GH)/surgebase/porter2 $(GH)/ugorji/go/codec \ |
| 66 |
$(GL)/x/crypto $(GL)/x/net $(GL)/x/sys $(GL)/x/text \ |
| 67 |
$(GL)/x/xerrors google.golang.org/protobuf gopkg.in/yaml.v2 |
| 68 |
GOLIBSRC = $(GOLIBSRC_:%=$(GOCODE)/src/%) |
| 69 |
|
| 70 |
export GO111MODULE = off |
| 71 |
export GOCACHE = $(CURDIR)/go-build |
| 72 |
export GOPATH = $(CURDIR)/obj-$(DEB_HOST_GNU_TYPE) |
| 73 |
GOLIBS = $(GOPATH)/src/eutils $(GOLIBSRC:$(GOCODE)/%=$(GOPATH)/%) |
| 74 |
|
| 75 |
GO_APPS = edict rchive transmute xtract |
| 76 |
BIN_GO_APPS = $(GO_APPS:%=bin/%) |
| 77 |
|
| 78 |
GOVERSION := $(word 3,$(shell go version)) # go version **goX.Y.Z** OS/CPU |
| 79 |
GO_IS_OLD := $(shell dpkg --compare-versions 0$(GOVERSION) ge 0go1.10 || echo $$?) |
| 80 |
ifneq (,$(GO_IS_OLD)) |
| 81 |
export PATH := /usr/lib/go-1.10/bin:$(PATH) |
| 82 |
endif |
| 83 |
|
| 84 |
USE_LIB_DIR = s,\"$$pth\(\"*\)/,\"$(LIB_DIR)\1/,g |
| 85 |
|
| 86 |
$(GOPATH)/%: # /usr/share/gocode/% |
| 87 |
mkdir -p $(dir $@) |
| 88 |
ln -s /usr/share/gocode/$* $@ |
| 89 |
|
| 90 |
$(GOPATH)/src/eutils: |
| 91 |
mkdir -p $(GOPATH)/src |
| 92 |
ln -s $(CURDIR)/eutils $@ |
| 93 |
|
| 94 |
$(GOPATH)/src/%: debian/vendor/% |
| 95 |
mkdir -p $(dir $@) |
| 96 |
ln -s $(CURDIR)/$< $@ |
| 97 |
|
| 98 |
# Needed by 4/7 archive-* scripts as of 23.7.20250401, harmless for the rest |
| 99 |
bin/archive-%: archive-% |
| 100 |
mkdir -p bin |
| 101 |
sed -e '$(USE_LIB_DIR)' $< > $@ |
| 102 |
chmod +x $@ |
| 103 |
|
| 104 |
bin/esummary: esummary |
| 105 |
mkdir -p bin |
| 106 |
sed -e 's/efetch/&.ncbi/' $< > $@ |
| 107 |
chmod +x $@ |
| 108 |
|
| 109 |
bin/nquire: nquire |
| 110 |
mkdir -p bin |
| 111 |
sed -e '$(USE_LIB_DIR); s/ --no-check-certificate / /' $< > $@ |
| 112 |
chmod +x $@ |
| 113 |
|
| 114 |
bin/%.sh: % |
| 115 |
mkdir -p bin |
| 116 |
sed -e 's,xml2json,$(LIB_DIR)/&,; s/python/&3/; /to precompiled/q' \ |
| 117 |
$< > $@ |
| 118 |
echo 'exec $(LIB_DIR)/$< "$$@"' >> $@ |
| 119 |
chmod +x $@ |
| 120 |
|
| 121 |
$(BIN_PERL_SCRIPTS): bin/%: % |
| 122 |
mkdir -p bin |
| 123 |
sed -e '$(FIX_PERL_SHEBANG)' $< > $@ |
| 124 |
chmod +x $@ |
| 125 |
|
| 126 |
$(BIN_ECOMMON_SCRIPTS) $(BIN_XCOMMON_SCRIPTS): bin/%: % |
| 127 |
mkdir -p bin |
| 128 |
sed -e '$(USE_LIB_DIR)' $< > $@ |
| 129 |
chmod +x $@ |
| 130 |
|
| 131 |
ifneq (,$(wildcard /usr/share/gocode/src/$(GH)/klauspost/cpuid/v2)) |
| 132 |
$(GOPATH)/src/$(GH)/klauspost/cpuid: $(GOLIBS) |
| 133 |
mkdir -p $(GOPATH)/src/$(GH)/klauspost |
| 134 |
ln -s /usr/share/gocode/src/$(GH)/klauspost/cpuid/v2 \ |
| 135 |
$(GOPATH)/src/$(GH)/klauspost/cpuid |
| 136 |
endif |
| 137 |
|
| 138 |
$(BIN_GO_APPS): bin/%: cmd/%.go $(GOLIBS) |
| 139 |
# Always use gccgo? The resulting binary would be much smaller, but |
| 140 |
# pull in a large shared library with few other reverse dependencies. |
| 141 |
go build -v -gccgoflags '$(CFLAGS) $(LDFLAGS)' -o $@ \ |
| 142 |
$(GOPATH)/src/$(DH_GOPKG)/$*.go |
| 143 |
|
| 144 |
override_dh_auto_configure: |
| 145 |
mkdir -p $(GOPATH)/src/$(DH_GOPKG) |
| 146 |
ln -sv $(CURDIR)/cmd/*.go $(GOPATH)/src/$(DH_GOPKG) |
| 147 |
|
| 148 |
override_dh_auto_build: $(WRAPPERS) $(BIN_PERL_SCRIPTS) \ |
| 149 |
$(BIN_ECOMMON_SCRIPTS) $(BIN_XCOMMON_SCRIPTS) \ |
| 150 |
$(BIN_OTHER_SCRIPTS) $(BIN_GO_APPS) |
| 151 |
dh_auto_build |
| 152 |
install $(AS_IS_SCRIPTS) bin/ |
| 153 |
mv bin/efetch bin/efetch.ncbi |
| 154 |
mv bin/einfo bin/einfo.ncbi |
| 155 |
install debian/efetch debian/einfo bin/ |
| 156 |
# It's spuriously executable, and dh_python3's practice of making hard links |
| 157 |
# interferes with correcting permissions only for the installed copy. |
| 158 |
install -m644 edirect.py debian/ |
| 159 |
|
| 160 |
override_dh_install: |
| 161 |
dh_install |
| 162 |
mv $(PKG_BIN_DIR)/xml2json debian/$(PACKAGE)/$(LIB_DIR)/ |
| 163 |
for x in $(GO_APPS); do \ |
| 164 |
test -f $(PKG_BIN_DIR)/$$x.sh || continue ; \ |
| 165 |
mv -v $(PKG_BIN_DIR)/$$x debian/$(PACKAGE)/$(LIB_DIR)/ ; \ |
| 166 |
mv -v $(PKG_BIN_DIR)/$$x.sh $(PKG_BIN_DIR)/$$x ; \ |
| 167 |
done |
| 168 |
|
| 169 |
override_dh_installexamples: |
| 170 |
dh_installexamples |
| 171 |
sed -i '$(FIX_PERL_SHEBANG)' debian/*/usr/share/doc/*/examples/* |
| 172 |
|
| 173 |
override_dh_auto_clean: |
| 174 |
dh_auto_clean |
| 175 |
rm -rf bin debian/edirect.py $(GOCACHE) $(GOPATH) |