File: rules

package info (click to toggle)
gmt 4.5.12-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 71,528 kB
  • ctags: 12,619
  • sloc: ansic: 138,042; sh: 4,992; csh: 1,085; makefile: 1,034; asm: 38
file content (157 lines) | stat: -rwxr-xr-x 4,995 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
#! /usr/bin/make -f

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

build:		build-stamp
install:	install-stamp
binary:		binary-arch binary-indep

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

build-stamp: 
	dh_testdir
	dh_prep
	
	# Use current autotools helpers
	-test -r /usr/share/misc/config.sub && \
		mv config.sub config.sub.original && \
		cp -f /usr/share/misc/config.sub config.sub
	-test -r /usr/share/misc/config.guess && \
		mv config.guess config.guess.original && \
		cp -f /usr/share/misc/config.guess config.guess
	
	$(CURDIR)/configure \
		--enable-shared $(PATHCONFIG) --disable-mex --enable-netcdf=/usr \
		--enable-octave \
	    --enable-mex-mdir=$(shell octave-config -p LOCALFCNFILEDIR)/gmt \
		--enable-mex-xdir=$(shell octave-config -p LOCALOCTFILEDIR)/gmt
	$(MAKE) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" all suppl 
	touch $@

install-stamp: 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) $(PATHVARS) install-all
	$(MAKE) -C src/mex DESTDIR=$(DESTDIR) install
	-find $(DESTDIR)/usr/lib/octave -name "*.mex" -exec rename 's/\.mex/.oct/' {} \;
	
	# 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
	
	# 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: install-stamp
	dh_testdir -a
	dh_testroot -a
	dh_install --list-missing 
	dh_installchangelogs -a
	dh_installchangelogs -pgmt 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: install-stamp
	dh_testdir -i
	dh_testroot -i
	dh_install --list-missing 
	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 -f install-stamp build-stamp
	# Reset upstream autotools helpers
	[ ! -f config.sub.original ] || mv -f config.sub.original config.sub 
	[ ! -f config.guess.original ] || mv -f config.guess.original config.guess
	[ ! -f Makefile ] || $(MAKE) distclean || true
	# Remove a few files still around after upstream cleaning
	rm -f src/mgg/libgmt_mgg.a \
		  share/conf/gmt.conf \
		  share/conf/gmtdefaults_SI \
		  share/conf/gmtdefaults_US src/isogmt
	dh_clean