File: rules

package info (click to toggle)
gnucap 1:0.36~20171003-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 9,336 kB
  • sloc: cpp: 29,323; sh: 319; makefile: 172
file content (154 lines) | stat: -rwxr-xr-x 4,917 bytes parent folder | download | duplicates (2)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

#export DH_VERBOSE=1
upstream_commit = $(shell v="$(DEB_VERSION_UPSTREAM)"; echo $${v\#\#*~})

# take from control?
SOVERSION = 0
SONAME = libgnucap.so.${SOVERSION}

# upstream_commit_short = $(shell echo $(upstream_commit) | sed -e 's/\(........\).*/\1/')
#
UPSTREAM_REPO=git://git.savannah.gnu.org/gnucap.git
ORIG_TARBALL=../gnucap_${DEB_VERSION_UPSTREAM}.orig.tar.gz

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

CFLAGS := $(shell dpkg-buildflags --get CFLAGS)
CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS)
LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)

LN_S = ln -sf

libdir = /usr/lib/$(DEB_HOST_MULTIARCH)
pkglibdir = ${libdir}/gnucap${SOVERSION}
pcdir	= ${libdir}/pkgconfig

%:
	dh $@

override_dh_auto_configure:
	./configure --prefix=/usr
	sed -e '/GNUCAP_PLUGPATH/s#/lib/gnucap#'/lib/${DEB_HOST_MULTIARCH}/gnucap0'#' -i main/config.h

	sed -e '/^$$/s##triplet=$$\( g++ --print-multiarch \)#' -i main/gnucap.conf
	sed -e '/^libdir/s#=.*#=/usr/lib/$${triplet}#' -i main/gnucap.conf
	sed -e '/^pkglibdir/s#=.*#=$${libdir}/gnucap'${SOVERSION}'#' -i main/gnucap.conf
	sed -e '/^sysconfdir/s#=.*#=/etc#' -i main/gnucap-conf
	sed -e '/^sysconfdir/s#=.*#=/etc#' -i main/gnucap.conf

	sed -e 's#-ltermcap##' -i lib/Make2

	sed -i '/SYSTEMSTARTPATH/s/OS::getenv("PATH")/"\/etc"/' main/config.h

# workaround: these are hardwired, need to pass them back
LIB_LDFLAGS = -shared
EXEC_LDFLAGS = -rdynamic -L../../lib/O

override_dh_auto_build:
	$(MAKE) -C lib \
	        LDFLAGS="$(LIB_LDFLAGS) \
	                 -Wl,-soname -Wl,${SONAME} \
	                  $(LDFLAGS)" \
	        CPPFLAGS="$(CPPFLAGS)" \
	        CXXFLAGS="$(CXXFLAGS)"
	cd $(CURDIR)/lib/O; $(LN_S) libgnucap.so ${SONAME}

	$(MAKE) -C modelgen \
	        LDFLAGS="$(EXEC_LDFLAGS) $(LDFLAGS)" \
	        CPPFLAGS="$(CPPFLAGS)" \
	        CXXFLAGS="$(CXXFLAGS)"

	$(MAKE) -C apps \
	        LDFLAGS="$(LIB_LDFLAGS) $(LDFLAGS)" \
	        CPPFLAGS="$(CPPFLAGS)" \
	        CXXFLAGS="$(CXXFLAGS)"

	dh_auto_build --parallel -- \
	            LDFLAGS="$(EXEC_LDFLAGS) $(LDFLAGS)" \
	            CPPFLAGS="$(CPPFLAGS)" \
	            CXXFLAGS="$(CXXFLAGS)"
#	#$(MAKE) -C man html/index.html

# pick subdirectories one by one. options do not propagate correctly
# (this is a terrible mess...)

override_dh_auto_install:
	$(MAKE) install -C lib \
	        DESTDIR=$(CURDIR)/debian/tmp
	mkdir -p $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)
	mv $(CURDIR)/debian/tmp/usr/lib/libgnucap.so \
	   $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/${SONAME}
	cd $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH); $(LN_S) ${SONAME} libgnucap.so

	$(MAKE) install -C modelgen \
	        DESTDIR=$(CURDIR)/debian/tmp

	$(MAKE) install -C apps \
	        INSTALL_DIR=${pkglibdir} install \
	        DESTDIR=$(CURDIR)/debian/tmp

	$(MAKE) install -C include \
	        DESTDIR=$(CURDIR)/debian/tmp

	$(MAKE) install -C main \
	        DESTDIR=$(CURDIR)/debian/tmp

	mkdir -p $(CURDIR)/debian/tmp/etc
	mv $(CURDIR)/debian/tmp/usr/etc/gnucap.conf \
	    $(CURDIR)/debian/tmp/etc/gnucap.conf

	# mv $(CURDIR)/debian/tmp/usr/bin/gnucap-conf $(CURDIR)/debian/tmp/${pkglibdir}/
	
	mkdir -p $(CURDIR)/debian/tmp/usr/share/doc/gnucap/examples
	cp tests/*.gc $(CURDIR)/debian/tmp/usr/share/doc/gnucap/examples
	cp tests/*.ckt $(CURDIR)/debian/tmp/usr/share/doc/gnucap/examples

	# workaround: some are duplicate (reported upstream, trivial),
	# remove a superset, for now.
	rm $(CURDIR)/debian/tmp/usr/share/doc/gnucap/examples/d_mos6*.ckt
	rm $(CURDIR)/debian/tmp/usr/share/doc/gnucap/examples/d_mos49.nand1.ckt

override_dh_auto_clean:
	dh_auto_clean
	rm -rf main/gnucap-conf
	rm -rf main/gnucap.conf
	rm -rf main/config.h
	rm -rf */Makefile -f
	rm -rf */Make2 -f
	rm -rf */O/ -rf

override_dh_installdocs:
	dh_installdocs
	# Remove LaTeX sources from HTML documentation:
	##rm debian/gnucap/usr/share/doc/gnucap/html/*.hi??
	# Remove un-necessary docs installed by upstream:
	#rm debian/gnucap/usr/share/doc/gnucap/COPYING
	#rm debian/gnucap/usr/share/doc/gnucap/INSTALL
	#rm debian/gnucap/usr/share/doc/gnucap/history

override_dh_compress:
	dh_compress -X.pdf -X.ckt

# disable debugging symbol packages, for now
# - these don't really help (-O2)
# - and they do not work with the current build system
#   (switch to autotools planned anyways..)
override_dh_strip:
	dh_strip --no-ddebs

# create tarball equivalent to upstream. use
# tar -xOzf ../gnucap-20171003.tar.gz | sort | sha1sum
# to check.
get-orig-source:
	@echo creating tarball from ${upstream_commit}
	[ -d .git ] && git archive ${upstream_commit} | \
	               gzip > $(ORIG_TARBALL) || :
	[ -d .git ] || git archive --format=tar \
		--remote=$(UPSTREAM_REPO) ${upstream_commit}  | \
	             tar -xzf > $(ORIG_TARBALL)

.PHONY: get-orig-source