rules 9.59 KB
Newer Older
1 2 3 4 5 6
#!/usr/bin/make -f
#
# build script for GROMACS

# export DH_VERBOSE=1

7 8
PACKAGE := gromacs

9 10 11 12
# OpenMPI is only supported on a subset of architectures at this time.
# This list should remain synced with the Build-Depends and the Architecture
# line of gromacs-openmpi in debian/control.

13
OPENMPI_ARCH    = alpha amd64 armel armhf i386 ia64 powerpc powerpcspe sparc sparc64 kfreebsd-i386 kfreebsd-amd64 hurd-i386
14
DEB_HOST_ARCH  ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
15

16 17 18
# add hardening flags, using hardening-wrapper
export DEB_BUILD_HARDENING=1

19
CFLAGS =
20
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
21
	CFLAGS += -g -Wall
22
endif
23 24 25
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
endif
26

27 28
LDFLAGS += -Wl,--as-needed

29
COMMON_CONFIG_PARAMS = \
Nicholas Breen's avatar
Nicholas Breen committed
30 31
	$(CURDIR) \
	-DCMAKE_INSTALL_PREFIX="/usr" \
32
	-DCMAKE_EXE_LINKER_FLAGS="$(LDFLAGS)" \
33 34
	-DCMAKE_SKIP_RPATH=TRUE \
	-DGMX_X11=ON
Nicholas Breen's avatar
Nicholas Breen committed
35 36 37

ifneq ($(CFLAGS),)
	COMMON_CONFIG_PARAMS += -DCMAKE_C_FLAGS="$(CFLAGS)"
38 39
endif

40 41 42 43 44 45 46
# Include "gpu" in DEB_BUILD_OPTIONS to build GPU-accelerated binaries as well.
# See INSTALL-GPU.  This build option is not tested, please send comments.
# You must have OpenMM development headers (not packaged) and "nvidia-cuda-dev"
# installed!
ifneq (,$(findstring gpu,$(DEB_BUILD_OPTIONS)))
	COMMON_CONFIG_PARAMS += -DGMX_OPENMM=ON -DGMX_THREADS=OFF
endif
Nicholas Breen's avatar
Nicholas Breen committed
47

48
MPICH_CONFIG_PARAMS = \
Nicholas Breen's avatar
Nicholas Breen committed
49 50
	-DGMX_MPI=ON \
	-DGMX_THREADS=OFF \
51 52
	-DGMX_X11=OFF \
	-DGMX_DEFAULT_SUFFIX=FALSE
53 54

OPENMPI_CONFIG_PARAMS = \
Nicholas Breen's avatar
Nicholas Breen committed
55 56
	-DGMX_MPI=ON \
	-DGMX_THREADS=OFF \
57
	-DGMX_DEFAULT_SUFFIX=FALSE \
Nicholas Breen's avatar
Nicholas Breen committed
58 59 60
	-DGMX_FORTRAN=OFF \
	-DGMX_X11=OFF \
	-DCMAKE_EXE_LINKER_FLAGS="-L/usr/lib/openmpi/lib $(LDFLAGS)"
61

62
# optional parallel build
63 64 65
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	MAKE += -j$(NUMJOBS)
66 67 68 69
endif

# gfortran transition: configure script looks for f77/g77 binaries, not f95/g95/gfortran
# FORTRAN inner loops are used on Alpha only
Nicholas Breen's avatar
Nicholas Breen committed
70
ifneq (,$(findstring alpha,$(DEB_HOST_ARCH)))
71 72 73
	export F77=/usr/bin/gfortran
endif

74 75
configure: configure-stamp
configure-stamp:
76
	dh_testdir
77 78
	(mkdir -p build/basic; cd build/basic; cmake $(COMMON_CONFIG_PARAMS) -DGMX_MPI=OFF)
	(mkdir -p build/basic-dp; cd build/basic-dp; cmake $(COMMON_CONFIG_PARAMS) -DGMX_MPI=OFF -DGMX_DOUBLE=ON)
79 80 81 82
	(mkdir -p build/mpich; cd build/mpich; CC=/usr/bin/mpicc.mpich2 cmake \
	$(COMMON_CONFIG_PARAMS) $(MPICH_CONFIG_PARAMS) -DGMX_BINARY_SUFFIX="_mpi.mpich" -DGMX_LIBS_SUFFIX="_mpi.mpich")
	(mkdir -p build/mpich-dp; cd build/mpich-dp; CC=/usr/bin/mpicc.mpich2 cmake \
	$(COMMON_CONFIG_PARAMS) $(MPICH_CONFIG_PARAMS) -DGMX_DOUBLE=ON -DGMX_BINARY_SUFFIX="_mpi_d.mpich" -DGMX_LIBS_SUFFIX="_mpi_d.mpich")
83
ifneq (,$(findstring $(DEB_HOST_ARCH),$(OPENMPI_ARCH)))
84 85 86 87
	(mkdir -p build/openmpi; cd build/openmpi; CC=/usr/bin/mpicc.openmpi cmake \
	$(COMMON_CONFIG_PARAMS) $(OPENMPI_CONFIG_PARAMS) -DGMX_BINARY_SUFFIX="_mpi.openmpi" -DGMX_LIBS_SUFFIX="_mpi.openmpi")
	(mkdir -p build/openmpi-dp; cd build/openmpi-dp; CC=/usr/bin/mpicc.openmpi cmake \
	$(COMMON_CONFIG_PARAMS) $(OPENMPI_CONFIG_PARAMS) -DGMX_DOUBLE=ON -DGMX_BINARY_SUFFIX="_mpi_d.openmpi" -DGMX_LIBS_SUFFIX="_mpi_d.openmpi")
88 89 90 91
endif
	touch $@


92
build: configure-stamp build-basic build-mpich build-openmpi
93

94 95 96
build-arch: build
build-indep: build

97 98 99 100 101 102 103 104 105 106
build-basic: configure-stamp
	dh_testdir
	$(MAKE) -C build/basic
	$(MAKE) -C build/basic-dp
	touch $@

build-mpich: configure-stamp
	dh_testdir
	$(MAKE) -C build/mpich mdrun 
	$(MAKE) -C build/mpich-dp mdrun
107
	sed -e 's/#MPIABBR#/mpich/g' -e 's/#MPIPROG#/MPICH2/g' \
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
	    < debian/gromacs-parallel.README.Debian.in \
	    > debian/gromacs-mpich.README.Debian
	touch $@
	
build-openmpi: configure-stamp
	dh_testdir
ifneq (,$(findstring $(DEB_HOST_ARCH),$(OPENMPI_ARCH)))
	$(MAKE) -C build/openmpi mdrun
	$(MAKE) -C build/openmpi-dp mdrun
	sed -e 's/#MPIABBR#/openmpi/g' -e 's/#MPIPROG#/OpenMPI/g' \
	    < debian/gromacs-parallel.README.Debian.in \
	    > debian/gromacs-openmpi.README.Debian
endif
	touch $@	


124
clean: 
125
	dh_testdir
126 127
	dh_testroot
	rm -rf build
128
	dh_clean build-basic build-mpich build-openmpi configure-stamp \
129
	         debian/gromacs-mpich.README.Debian debian/gromacs-openmpi.README.Debian
130 131


132
install: build install-basic install-mpich install-openmpi
133 134
	dh_testdir
	dh_testroot
135
	dh_prep -pgromacs-data -pgromacs-dev
136
	
137 138 139 140 141
	dh_installdirs -pgromacs-data
	mv $(CURDIR)/debian/gromacs/usr/share/gromacs/top \
	   $(CURDIR)/debian/gromacs-data/usr/share/gromacs
	mv $(CURDIR)/debian/gromacs/usr/share/gromacs/html \
	   $(CURDIR)/debian/gromacs-data/usr/share/doc/gromacs
142
	mv $(CURDIR)/debian/gromacs/usr/share/man \
143
	   $(CURDIR)/debian/gromacs-data/usr/share/man
144 145 146 147
	# some of the default installation directories for documentation and
	# example shell scripts are not FHS-friendly; move them appropriately
	mv $(CURDIR)/debian/gromacs/usr/bin/GMXRC* \
	   $(CURDIR)/debian/gromacs/usr/bin/completion* \
148 149 150 151
	   $(CURDIR)/debian/gromacs-data/usr/share/gromacs/shell-specific
	chmod 644 $(CURDIR)/debian/gromacs-data/usr/share/gromacs/shell-specific/*
	dh_link -pgromacs-data usr/share/doc/gromacs/html usr/share/doc/gromacs-data/html
	dh_link -pgromacs-data usr/share/doc/gromacs/html usr/share/doc/gromacs-dev/html
152 153
	# one lintian warning is overridden:
	# - script-not-executable: demo scripts outside of $PATH
154
	dh_lintian -pgromacs-data
155 156 157
	# rename a pair of Perl scripts to drop the .pl extension (Policy 10.4)
	mv $(CURDIR)/debian/gromacs/usr/bin/demux.pl     $(CURDIR)/debian/gromacs/usr/bin/demux
	mv $(CURDIR)/debian/gromacs/usr/bin/xplor2gmx.pl $(CURDIR)/debian/gromacs/usr/bin/xplor2gmx
158 159 160 161

	dh_installdirs -pgromacs-dev
	mv $(CURDIR)/debian/gromacs/usr/include $(CURDIR)/debian/gromacs-dev/usr/include
	# catch normal libraries plus all applicable MPI variants
162 163
	mv $(CURDIR)/debian/gromacs/usr/lib/*.so $(CURDIR)/debian/gromacs/usr/lib/pkgconfig $(CURDIR)/debian/gromacs-dev/usr/lib
	mv $(CURDIR)/debian/gromacs-mpich/usr/lib/*.so $(CURDIR)/debian/gromacs-dev/usr/lib
164
ifneq (,$(findstring $(DEB_HOST_ARCH),$(OPENMPI_ARCH)))
165
	mv $(CURDIR)/debian/gromacs-openmpi/usr/lib/*.so $(CURDIR)/debian/gromacs-dev/usr/lib
166 167
endif
	mv $(CURDIR)/debian/gromacs/usr/share/gromacs/template $(CURDIR)/debian/gromacs-dev/usr/share/gromacs/template
168 169
	# remaining documentation catch-all
	mv $(CURDIR)/debian/gromacs/usr/share/gromacs/* $(CURDIR)/debian/gromacs-data/usr/share/doc/gromacs
170
	-rmdir $(CURDIR)/debian/gromacs/usr/share/gromacs
171 172 173 174 175


install-basic: build
	dh_testdir
	dh_testroot
176
	dh_prep -pgromacs
177 178 179 180
	dh_installdirs -pgromacs
	$(MAKE) -C build/basic install DESTDIR=$(CURDIR)/debian/gromacs
	$(MAKE) -C build/basic-dp install DESTDIR=$(CURDIR)/debian/gromacs
	rm -f $(CURDIR)/debian/gromacs/usr/share/man/man1/*_d.1
181
	dh_installman -pgromacs debian/man/g_*.1
182 183
	for manpage in $(CURDIR)/debian/gromacs/usr/share/man/man1/*.1; do \
		dh_link -pgromacs usr/share/man/man1/`basename $${manpage}` usr/share/man/man1/`basename $${manpage} .1`_d.1 ; \
184
	done
185 186 187
	# man pages for a pair of Perl scripts are installed *after* the _d duplication,
	# as they have no double-precision variants.
	dh_installman -pgromacs debian/man/demux.1 debian/man/xplor2gmx.1
188 189
	# this program is currently broken - keep it from shipping until fixed
	rm $(CURDIR)/debian/gromacs/usr/bin/g_pme_error $(CURDIR)/debian/gromacs/usr/bin/g_pme_error_d
190
	# two lintian warnings are overridden:
191 192 193
	# - package-name-doesnt-match-sonames: the libraries are private to
	#   GROMACS, and it's unlikely that any new package will start using
	#   them; therefore, separate lib packages would just be bloat.
194
	#   This is also overridden for the -mpich and -openmpi packages.
195 196
	# - shlib-with-executable-stack: it's a side effect of the ASM inner
	#   loops (i386/amd64 only)
197
	dh_lintian -pgromacs
198

199
install-mpich: build
200
	dh_testdir
201
	dh_testroot
202
	dh_prep -pgromacs-mpich
203
	dh_installdirs -pgromacs-mpich
204 205 206 207
	$(MAKE) -C build/mpich install-mdrun DESTDIR=$(CURDIR)/debian/gromacs-mpich
	$(MAKE) -C build/mpich-dp install-mdrun DESTDIR=$(CURDIR)/debian/gromacs-mpich
	dh_installman -pgromacs-mpich debian/man/mdrun_mpi.mpich.1
	dh_link -pgromacs-mpich usr/share/man/man1/mdrun_mpi.mpich.1.gz usr/share/man/man1/mdrun_mpi_d.mpich.1.gz
208
	dh_lintian -pgromacs-mpich
209

210
install-openmpi: build
211
	dh_testdir
212
	dh_testroot
213
	dh_prep -pgromacs-openmpi
214
ifneq (,$(findstring $(DEB_HOST_ARCH),$(OPENMPI_ARCH)))
215
	dh_installdirs -pgromacs-openmpi
216 217 218 219
	$(MAKE) -C build/openmpi install-mdrun DESTDIR=$(CURDIR)/debian/gromacs-openmpi
	$(MAKE) -C build/openmpi-dp install-mdrun DESTDIR=$(CURDIR)/debian/gromacs-openmpi
	dh_installman -pgromacs-openmpi debian/man/mdrun_mpi.openmpi.1
	dh_link -pgromacs-openmpi usr/share/man/man1/mdrun_mpi.openmpi.1.gz usr/share/man/man1/mdrun_mpi_d.openmpi.1.gz
220
	dh_lintian -pgromacs-openmpi
221
endif
222

223
binary-indep: build install
224 225
	dh_testdir
	dh_testroot
226
	dh_installchangelogs -i
227
	dh_installdocs -pgromacs-data
228
	dh_compress -i
229 230 231 232 233 234
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

235
binary-arch: build install
236 237 238
	dh_testdir -s
	dh_testroot -s
	dh_installchangelogs -s
239
	dh_installdocs -s
240 241
	dh_strip -A
	dh_link -s
242
	dh_compress -s
243 244
	dh_fixperms -s
	dh_makeshlibs -s
245 246
	dh_shlibdeps -pgromacs -L gromacs -l debian/gromacs/usr/lib
	dh_shlibdeps -pgromacs-mpich -L gromacs-mpich -l debian/gromacs-mpich/usr/lib
247
ifneq (,$(findstring $(DEB_HOST_ARCH),$(OPENMPI_ARCH)))
248
	dh_shlibdeps -pgromacs-openmpi -L gromacs-openmpi -l debian/gromacs-openmpi/usr/lib
249 250 251 252 253 254 255 256
endif
	dh_gencontrol -s
	dh_installdeb -s
	dh_md5sums -s
	dh_builddeb -s

binary: binary-indep binary-arch

257
.PHONY: binary binary-arch binary-indep build clean install install-basic install-mpich install-openmpi
258 259 260 261 262

# Because multiple versions of the same programs are created using the same source tree,
# the various build-* targets can't be compiled simultaneously.
# Passing down -j# to child make processes remains unaffected.
.NOTPARALLEL: