File: rules

package info (click to toggle)
gmt 4.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 29,960 kB
  • ctags: 12
  • sloc: makefile: 133
file content (181 lines) | stat: -rwxr-xr-x 5,422 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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#! /usr/bin/make -f

RELEASE		:= 4.5.2
PARTS		:= doc share src suppl 
ARCHIVES	:= $(PARTS:%=upstream/GMT$(RELEASE)_%.tar.bz2)

CFLAGS := -fPIC -ansi -pedantic

# Some special build options
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
   CFLAGS += -g -O0
   LDFLAGS += -g
else
   CFLAGS += -O2
endif

ifneq (,$(findstring verbose,$(DEB_BUILD_OPTIONS)))
   DH_VERBOSE=1
   export DH_VERBOSE
endif

unpack:		stamps/unpack-stamp
patch:		stamps/patch-stamp
build:		stamps/build-stamp
install:	stamps/install-stamp
binary:		binary-arch binary-indep

download-upstream:	$(ARCHIVES)

create-orig-tar:	$(ARCHIVES)
	dh_testdir
	mkdir -p gmt-$(RELEASE)/upstream
	ln -f $(ARCHIVES) gmt-$(RELEASE)/upstream
	tar cf - gmt-$(RELEASE)|gzip -9 > gmt-$(RELEASE).orig.tar.gz
	mv gmt-$(RELEASE).orig.tar.gz ..
	rm -R gmt-$(RELEASE)

upstream/%:
	dh_testdir
	mkdir -p upstream
	wget -O upstream/$*.partial ftp://ibis.grdl.noaa.gov/pub/gmt/$*
	mv upstream/$*.partial upstream/$*

stamps/unpack-stamp: 
	dh_testdir
	for i in $(ARCHIVES); do \
		tar xjf $$i || exit 1; \
	done
	mkdir -p stamps
	touch $@

stamps/patch-stamp:	stamps/unpack-stamp
	dh_testdir
	ln -sf GMT$(RELEASE) GMT
	QUILT_PATCH_OPTS="-p1" QUILT_PATCHES=debian/patches quilt push -a --color=auto || [ $$? = 2 ]
	touch $@

unpatch:
	dh_testdir
	QUILT_PATCH_OPTS="-p1" QUILT_PATCHES=debian/patches quilt pop -a || true
	rm -rf stamps/patch-stamp GMT .pc

PATHCONFIG	:= --prefix=/usr/lib/gmt
DESTDIR		:= $(CURDIR)/debian/tmp
PATHVARS	:= prefix=$(DESTDIR)/usr/lib/gmt

stamps/build-stamp: stamps/patch-stamp
	dh_testdir
	dh_prep
	cd GMT$(RELEASE) && ./configure \
		--enable-shared $(PATHCONFIG) --disable-mex --enable-netcdf=/usr
	$(MAKE) -C GMT$(RELEASE) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" all suppl 
	touch $@

stamps/install-stamp: stamps/build-stamp
	dh_testdir
	dh_testroot
	
	# Very tricky: GMT does not conform to FHS. As it proved to be very
	# time consuming to bend this beast I'll create a fake GMT tree
	# which links to the Debian accepted locations and install into
	# that tree.
	mkdir -p  $(DESTDIR)/usr/lib/gmt $(DESTDIR)/usr/share/gmt \
		$(DESTDIR)/usr/share/man $(DESTDIR)/usr/include/gmt \
		$(DESTDIR)/usr/share/doc $(DESTDIR)/etc/gmt $(DESTDIR)/usr/bin
	ln -fs ../../share/man $(DESTDIR)/usr/lib/gmt/man
	ln -fs ../../include/gmt $(DESTDIR)/usr/lib/gmt/include
	ln -fs ../../share/gmt $(DESTDIR)/usr/lib/gmt/share
	
	$(MAKE) -C GMT$(RELEASE) $(PATHVARS) install-all
	
	# Okay, we still have to move the documentation (the trick above does
	# not work because the Makefile would try to overwrite the link with
	# a directory). So move the docs and link them to where GMT will look
	# for them. 
	mv $(DESTDIR)/usr/lib/gmt/share/doc/gmt $(DESTDIR)/usr/share/doc/
	ln -fs ../../../share/doc/gmt $(DESTDIR)/usr/lib/gmt/share/doc/gmt
	
	# Move stuff from the doc directory up one level and replace the dir
	# with a symlink to .
#	mv $(DESTDIR)/usr/share/doc/gmt/doc/* $(DESTDIR)/usr/share/doc/gmt/
#	rmdir $(DESTDIR)/usr/share/doc/gmt/doc
#	ln -fs . $(DESTDIR)/usr/share/doc/gmt/doc
	
	# Configuration files are still at the wrong place, let's fix this
	mv $(DESTDIR)/usr/share/gmt/conf/*.conf $(DESTDIR)/etc/gmt/
	install -m644 debian/coastline.conf $(DESTDIR)/etc/gmt/
	for file in $(DESTDIR)/etc/gmt/*.conf; do \
		ln -fs /etc/gmt/`basename $$file` $(DESTDIR)/usr/share/gmt/`basename $$file`; \
	done
	
	# GMT wrapper does not help in /usr/lib/gmt/bin (not in path by default)
	# So: Move it to /usr/bin and patch it a bit locally to alter the PATH var.
	# Also use 'pager' instead of more as default pager in the script.
	sed -e 's/^exec /PATH=\$$PATH:\$${exec_prefix}\/bin exec /' \
	    -e 's/:-more/:-pager/' \
	    	$(DESTDIR)/usr/lib/gmt/bin/GMT >$(DESTDIR)/usr/bin/GMT
	rm -f $(DESTDIR)/usr/lib/gmt/bin/GMT
	
	# Move the manpages directory into the right place...
	for section in 1 3 5; do \
		mkdir -p $(DESTDIR)/usr/share/man/man$${section}; \
		for manpage in $(DESTDIR)/usr/lib/gmt/share/man/man$${section}/*.$${section}; do \
			sed -e "s/^\.TH \(.*\) $${section}/\.TH \1 $${section}gmt/" $${manpage}|gzip \
			       >$(DESTDIR)/usr/share/man/man$${section}/`basename $${manpage}`gmt.gz; \
			rm -f $${manpage}; \
		done; \
	done
	rm -rf $(DESTDIR)/usr/share/gmt/man
	
	touch $@

binary-arch: stamps/install-stamp
	dh_testdir -a
	dh_testroot -a
	dh_install --list-missing --sourcedir=$(DESTDIR)
	dh_installchangelogs -a
	dh_installchangelogs -pgmt GMT$(RELEASE)/ChangeLog
	dh_installdocs -a
	dh_installexamples -a
	dh_installmenu -a
	dh_installman -a
	dh_strip -a
	dh_link -a
	dh_compress -a -X.pdf
	dh_fixperms -a
	dh_makeshlibs -a
	dh_shlibdeps -a -l$(DESTDIR)/usr/lib/gmt/lib
	dh_installdeb -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a
	

binary-indep: stamps/install-stamp
	dh_testdir -i
	dh_testroot -i
	dh_install --list-missing --sourcedir=$(DESTDIR)
	dh_installchangelogs -i
	dh_installdocs -i
	dh_installexamples -i
	dh_installmenu -i
	dh_installman -i
	dh_strip -i
	dh_link -i
	dh_compress -i -X.pdf
	# Uncompress examples stuff 
	find  $(CURDIR)/debian/gmt-examples/usr/share/doc/gmt-examples/examples -name "*.gz" -exec gunzip {} \;
	# Remove +x 
	find  $(CURDIR)/debian/gmt-examples/usr/share/doc/gmt-examples/examples -name "*.bat" -exec chmod -x {} \;
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

clean:
	dh_testdir
	dh_testroot
	rm -Rf stamps GMT$(RELEASE) GMT .pc
	dh_clean