File: rules

package info (click to toggle)
fsl 5.0.7-4
  • links: PTS, VCS
  • area: non-free
  • in suites: jessie, jessie-kfreebsd
  • size: 23,384 kB
  • ctags: 17,864
  • sloc: cpp: 166,701; tcl: 25,434; sh: 14,545; ansic: 9,707; makefile: 1,332; python: 151; xml: 106; csh: 17
file content (264 lines) | stat: -rwxr-xr-x 7,880 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#!/usr/bin/make -f
# -*- makefile -*-

FSLMAJORVERSION = 5.0

# enable exented globbing in the shell to be able to use more
# sophisticated stuff in dh_install files
SHELL := /bin/bash -O extglob

# get octave paths (have to build-depend on octave-headers)
include /usr/share/octave/debian/defs.make

# This has to be exported to make some magic below work.
export DH_OPTIONS

# specify all FSL projects that shall be built
PROJECTS = \
  utils fslio miscmaths newimage libvis first_lib meshclass fslvtkio \
  misc_tcl basisfield warpfns bint shapeModel MVdisc fslsurface libmeshutils \
  avwutils basil bet2 cluster fast4 feat5 film filmbabe flirt fabber baycest \
  fslvbm mcflirt melodic misc_c miscvis mm gps randomise siena slicetimer susan \
  tbss fnirt fugue asl_mfree misc_scripts fdt first possum sgeutils flameo \
  oxford_asl qboot topup ptx2 lesions eddy

# specify FSL extras to be built
EXTRAS = libprob libcprob cprob

# set essential config vars for FSL build process
FSLDIR=$(CURDIR)
FSLCONFDIR=$(FSLDIR)/config

# apply to FSL as 'ARCHLDFLAGS'
# 'as-needed' kills everything -- symbols of C libs get confused
# and results change -- remember cprob:gamma()
#LDFLAGS = -Wl,--no-undefined -Wl,--as-needed -L/usr/lib/fsl/lib
LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS) \
         -Wl,--no-undefined -L/usr/lib/fsl/lib
# default compiler flags
# apply to FSL as 'ANSI_FLAGS'
CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) \
        $(shell dpkg-buildflags --get CPPFLAGS) \
        -DHAVE_LIBFREETYPE -fPIC \
        -I/usr/include/nifti \
        -I/usr/include/gifti \
        -I/usr/include/newmat \
        -I$(FSLDIR)/extras/src/libprob -I$(FSLDIR)/extras/src/libcprob \
        -I$(FSLDIR)/src

# where are the internal libs
FSL_LIBRARY_PATH=$(CURDIR)/lib

# install into this directory
DEB_DESTDIR=$(CURDIR)/debian/tmp

# don't compile GPU
COMPILE_GPU:=0

# define common environment setup for all make calls
# complicated LD_LIBRARY expression ensures that no
# trailing colon ends up in LD_LIBRARY_PATH
DEB_BUILD_ENV=LD_LIBRARY_PATH=$(FSL_LIBRARY_PATH)$${LD_LIBRARY_PATH:+:$${LD_LIBRARY_PATH}} \
		FSLDIR="$(FSLDIR)" \
		FSLDEVDIR="$(FSLDIR)" \
		FSLCONFDIR="$(FSLCONFDIR)" \
		DEB_DESTDIR="$(DEB_DESTDIR)" \
		OPTFLAGS="$(OPTFLAGS)" \
		ANSI_FLAGS="$(CFLAGS) $(CPPFLAGS)" \
		DEPENDFLAGS="$(CFLAGS)" \
		ARCHLDFLAGS="$(LDFLAGS)" \
		COMPILE_GPU="$(COMPILE_GPU)" \
		CUDA="/usr"

controlfiles:
	# inject current FSL major version into all templates
	for f in debian/templates/*; do \
		sed -e "s/#FSLMVERSION#/$(FSLMAJORVERSION)/g" $$f \
			> debian/$$(basename $$f) ; \
	done
	# renamed files that need to have a version-specific name
	for suffix in 1 desktop dirs install links lintian-overrides manpages menu docs; do \
		for prefix in 'core' 'gpu'; do \
		[ -f debian/fsl-$$prefix.$$suffix ] &&  \
			mv debian/fsl-$$prefix.$$suffix debian/fsl-$(FSLMAJORVERSION)-$$prefix.$$suffix || true ; \
		done ; \
	done
	# and rename the meta-package files
	for f in debian/meta.*; do \
		target=$$(basename $$f); suffix=$${target#*.} ; \
		mv $$f debian/fsl-core.$$suffix; \
	done

cleancontrolfiles:
	# clean sed'ed files and intermediate rubbish
	for f in debian/templates/*; do\
		rm -f debian/$$(basename $$f) ; \
	done
	rm -f debian/fsl-core.preinst
	# versioned files
	rm -f debian/fsl-$(FSLMAJORVERSION)-{core,gpu}.{1,desktop,dirs,install,links,lintian-overrides,manpages,menu,preinst,docs}

# build and install extra
biextra-%:
	$(DEB_BUILD_ENV) $(MAKE) -C extras/src/$*
	$(DEB_BUILD_ENV) $(MAKE) -C extras/src/$* install

# cleanup extra
cextra-%:
	$(DEB_BUILD_ENV) $(MAKE) -C extras/src/$* distclean

# build and install sub-project
biproj-%:
	$(DEB_BUILD_ENV) $(MAKE) -C src/$*
	$(DEB_BUILD_ENV) $(MAKE) -C src/$* install

# cleanup sub-project
cproj-%:
	$(DEB_BUILD_ENV) $(MAKE) -C src/$* distclean

# build and install all extras
biextras: $(EXTRAS:%=biextra-%)

# clean all extras
cextras: $(EXTRAS:%=cextra-%)
	find extras/src -name '*.o' -delete


instdir:
# FSL does not separate build and install properly
# create temporary install dir now
	if [ ! -d $(DEB_DESTDIR) ]; then mkdir -p $(DEB_DESTDIR); fi
	dh_installdirs

# build and install all sub-projects
biprojs: $(PROJECTS:%=biproj-%)

# cleanup all sub-projects
cprojs: $(PROJECTS:%=cproj-%)


#Architecture
build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp: instdir biextras biprojs
	dh_testdir

	# fix permissions
	find debian/tmp/tcl/BWidget -type f -exec chmod -x {} \;
	chmod 644 debian/tmp/tcl/*.{tcl,xbm,ppm,ico}
	chmod -x debian/tmp/etc/flirtsch/*

	# cleanup TCL stuff
	rm -r debian/tmp/tcl/BWidget/BWMan/
	find debian/tmp/tcl/BWidget/ -name '*.txt' -delete

	# generate debhelper file to create /usr/bin symlinks and manpage links
	# for all relevant binaries installed by the versioned FSL package
	for f in $$(find debian/tmp/bin \! -type d \! -name Runtcl | sort); do \
		bname=$$(basename $$f); \
		[[ "$$bname" = *gpu* ]] && ptype="gpu" || ptype="core" ; \
		echo "/usr/lib/fsl/$(FSLMAJORVERSION)/fsl_app_wrapper /usr/bin/fsl$(FSLMAJORVERSION)-$$bname" >> debian/fsl-$(FSLMAJORVERSION)-$$ptype.links ; \
		echo "/usr/share/man/man1/fsl-$(FSLMAJORVERSION).1.gz /usr/share/man/man1/fsl$(FSLMAJORVERSION)-$${bname}.1.gz" >> debian/fsl-$(FSLMAJORVERSION)-$$ptype.links ; \
	done
	touch $@


clean: cleancontrolfiles controlfiles cextras cprojs
	dh_testdir
	dh_testroot

	# remove leftovers
	find $(CURDIR) -name '*.so' -delete
	-rm src/fdt/{xfibres,fdt_matrix_ops,indexer,replacevols,probtrackx,reord_OM,sausages,probtrack_old,xfibres_pred,rearrange}
	-rm src/feat5/doc/{top.html,feat.tcl}
	-rm -r etc/standard lib

	# clean the remaining temp dir
	rm -rf include

	# finally clean package
	dh_clean

	# fix permissions in the source
	find src/ -name '*.fig' -or -name '*.gif' -exec chmod -x {} \;

	-rm build-stamp


# checks that the included desktop files are ok
validate-desktop-files:
	for f in $(CURDIR)/debian/desktop/*.desktop; do \
		desktop-file-validate $${f} ; \
	done


install: build
	# make FSL logo for menu entries
	convert debian/tmp/tcl/fsl-logo-tiny.ppm \
		-resize x32 -crop 32x32+6+0 debian/tmp/fsl-$(FSLMAJORVERSION).xpm

	# install fsl config
	cp -r -t debian/tmp etc
	# clean useless pieces
	rm debian/tmp/etc/fslconf/fslmachtype.sh
	# do not install license files
	rm debian/tmp/etc/js/LICENSE.txt



# Must not depend on anything. This is to be called by
# binary-arch/binary-indep
# in another 'make' thread.
binary-common:
	dh_testdir
	dh_testroot
	dh_install
	dh_installchangelogs
	dh_installman
	dh_installdocs
	dh_installmenu
	# fixup duplicate GPU tools
	rm -f debian/fsl-$(FSLMAJORVERSION)-core/usr/lib/fsl/$(FSLMAJORVERSION)/*gpu*
	rm -f debian/fsl-$(FSLMAJORVERSION)-core/usr/lib/fsl/$(FSLMAJORVERSION)/*cuda*
	dh_lintian
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	# dh_shlibdeps needs access to the private libs
	dh_shlibdeps -l $(FSL_LIBRARY_PATH)
	# get the correct dependency for older octave
	[ -e /usr/bin/octave-depends ] \
        && octave-depends || true
	dh_gencontrol
	dh_md5sums
	dh_builddeb


# Build architecture independent packages using the common target.
binary-indep: install
	dh_installdirs -i

	$(MAKE) -f debian/rules DH_OPTIONS=-i binary-common


# Build architecture dependant packages using the common target.
binary-arch: install
	dh_installdirs -a

	# install the stylesheet
	cp -r doc/fsl.css debian/fsl-$(FSLMAJORVERSION)-core/usr/share/fsl/$(FSLMAJORVERSION)/doc

	# remove previous link to make repeated builds work
	-rm debian/fsl-$(FSLMAJORVERSION)-core/usr/share/fsl/$(FSLMAJORVERSION)/etc/fslconf/{feat.tcl,fsl.sh}

	# set execute permission for GUI application wrapper
	chmod +x debian/fsl_app_wrapper

	$(MAKE) -f debian/rules DH_OPTIONS=-a binary-common


binary: binary-arch binary-indep
.PHONY: build clean binary-indep binary-arch binary