rules 24.8 KB
Newer Older
1 2
#!/usr/bin/make -f
# debian/rules file for the Debian GNU/Linux r-base package
3
# Copyright 1997-2003  Douglas Bates <bates@stat.wisc.edu> 
4
# Copyright 1998-2014  Dirk Eddelbuettel <edd@debian.org>
5 6
#
# $Id: rules,v 1.3 2007/05/06 17:13:23 edd Exp edd $
7

8
corepackage	= r-base-core
9
devpackage	= r-base-dev
10
#latexpackage	= r-base-latex
11 12 13
pdfpackage	= r-doc-pdf
htmlpackage	= r-doc-html
nmathpackage	= r-mathlib
14
infopackage	= r-doc-info
15
recdpackage	= r-recommended
16
dbugpackage	= r-base-core-dbg
17 18 19 20 21 22 23 24

# for the standalone library, no sonames are assigned in the upstream Makefiles
somaj		= 1
somin		= 0
sorel		= 0
libver		= $(somaj).$(somin).$(sorel)

debbase		:= $(CURDIR)/debian
25
debtmp		:= $(debbase)/$(corepackage)
26 27
debdoc		:= $(debbase)/$(corepackage)/usr/share/doc/$(corepackage)
debmat		:= $(debbase)/$(nmathpackage)
28 29
debetc		:= $(debbase)/$(corepackage)/usr/lib/R/etc
debinf		:= $(debbase)/$(infopackage)
30
debcnf		:= $(debbase)/$(corepackage)/etc/R
31

32 33 34 35
## edd 24 Oct 2005 use DEB_BUILD_GNU_CPU, not DEB_BUILD_GNU_TYPE 
##                 updated rules throughout
arch		:= $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
buildarch	:= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
36 37
## edd 26 Jul 2013 also use DEB_HOST_ARCH_OS to catch kFreeBSD
buildos         := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
38 39
#export DH_VERBOSE = 1

40
# edd 15 Aug 2001  default to blas, atlas can override it 
41
#atlas		= --with-blas=blas
42
# dmb 04 Apr 2003  better to use no specify blas
43
# atlas			= --with-blas
44 45 46
# edd 28 Apr 2003  try configuring with atlas
# atlas		= --with-blas=atlas
# edd 16 Oct 2003  back to older default
47
#atlas		= --with-blas=blas
48
# edd 26 Feb 2004  point to refblas3 
49 50 51
#atlas		= --with-blas=-lblas-3
# edd 05 Feb 2008  default blas
atlas           = --with-blas
52 53 54 55 56

# edd 08 Mar 2003  use the new lapack feature
# edd 27 Apr 2003  Set this to =no as we currently see numerical errors
#lapack		= --with-lapack=no
# edd 26 Feb 2004  point to lapack3 
57 58
#lapack		= --with-lapack=-llapack-3
# edd 13 Oct 2004  Set this once again to =no as we still see numerical errors
59 60
#lapack		= --with-lapack=no
# edd 05 Feb 2008  switched back
61
# edd 05 Feb 2008  oh, no switch back to internal lapack -- see #464833
62 63 64
#lapack		= --with-lapack=no
# edd 05 Mar 2008  with lapack as we can now use lapack 3.1 in unstable
lapack		= --with-lapack
65 66 67

# edd 02 Sep 2001  default to g77 but let m68k use f2c
# edd 06 Mar 2003  enforce 3.2 versions explicitly 
68
#		   so that on testing we will pick them over 2.95
69
# edd 07 Jun 2003  let's fall back to the default compilers
70
# edd 08 Sep 2005  real defaults, i.e. remove -3.4 strings
71 72
# edd 03 Apr 2006  switch to gfortran
# edd 04 Apr 2006  use optimflags, build per-compiler flags later
73
# edd 26 Jun 2007  need 4.2 for fortran linking
74
# edd 26 Nov 2007  4.2 is now default, so no longer set -4.2 explictly; also add f95compiler
75
# edd 11 Oct 2011  setting -std=gnu99 with compiler (thanks, Kurt Hornik)
76 77
fortrancompiler	= F77=gfortran
f95compiler     = gfortran
78
compiler	= "gcc -std=gnu99"
79
cxxcompiler	= g++
80 81 82 83 84
# edd 31 Mar 2014
#optimflags	= -O3 -pipe 
optimflags      = $(shell dpkg-buildflags --get CFLAGS)
# edd 08 Apr 2014  add CPPFLAGS
optimflags      += $(shell dpkg-buildflags --get CPPFLAGS)
85

86 87 88 89 90
# edd 22 Apr 2012  gcc-4.7 needs -O2 to build R (also #67359)
ifneq "$(shell gcc --version | head -1 | cut -d' ' -f4 | grep '^4.7')" ""
optimflags = -O2 -pipe
endif

91
# edd 04 Sep 2001  default compiler flags, lowered for m68k
92
#compilerflags	= -O2 
93
# m68k barks when using g77, and when gcc use -O2
94 95 96
# edd 26 Nov 2002  switched back to g77
# edd 02 Jun 2003  switched back
# cts 04 Jun 2003  use -O1 on m68k
97 98 99 100
#ifeq ($(arch),m68k)
#fortrancompiler	= F2C=f2c
#compilerflags	= -O1
#endif
101

102
# edd 14 Nov 2003  turn blas off on arm
103 104 105 106
# edd 12 May 2010  no longer needed -- thx to Modestas Vainius
#ifeq ($(arch),arm)
#atlas		= --without-blas
#endif
107

108
## edd 09 Nov 2001  ia64 needs gcc-3.0, hppa gets it by default
109
#ifeq ($(arch),ia64)
110 111 112 113 114 115
#fortrancompiler = F77=g77-3.0
#compiler	= gcc-3.0
#cxxcompiler	= g++-3.0
#compilerflags	= -O2
#endif

116
## lamont@debian.org 06 Dec 2001  hppa needs -ffunction-sections  
117
ifeq ($(arch),hppa)
118
optimflags	= -O2 -ffunction-sections 
119
endif
120

121
## edd 20 Jun 2002	no optimisation or debugging on baby systems
122
## edd 02 Jun 2003	use this on arm only 
123
## edd 12 May 2010	no longer use it on arm either -- thx Modestas
124
## edd 04 Aug 2010	on mips and mipsel, don't use -g
125 126
##ifneq "$(findstring $(arch), m68k arm)" ""
#ifneq "$(findstring $(arch), arm)" ""
127 128
ifneq "$(findstring $(arch), mips mipsel)" ""
optimflags	= -g0 
129
#optimflags	= -O0 -g0 
130
endif
131

132 133 134 135 136 137
## edd 04 Apr 2009	Alpha dies on deriv.c, trying will less optimisation
## edd 16 Apr 2009      commented-out as Kurt Roeckx applied a gcc patch
#ifeq ($(arch),alpha)
#optimflags	= -O2 -g0
#endif

138 139 140 141 142
## edd 09 Apr 2006	per patch from Andreas Jochens in #361604
ifeq ($(arch),powerpc64)
optimflags	+= -mminimal-toc
endif

143 144 145 146 147 148
## edd 26 Jul 2013	kFreeBSD wants -O2 per #714506
ifeq ($(buildos),kfreebsd)
optimflags	= -O2 -pipe
endif


149
## edd 04 Apr 2006	generalize from old compilerflags to per-compiler
150 151
## edd 11 Oct 2011      -std=gnu goes to CC (thanks to Kurt Hornik)
cflags		= $(optimflags)
152
cxxflags	= $(optimflags)
153 154 155
## edd 31 Mar 2014      with thanks to Julian Gilbey in #726913
#fcflags		= $(optimflags)
fcflags 	= $(shell dpkg-buildflags --get FFLAGS)
156

157 158
## edd 17 Sep 2006	suggested by Brian Ripley in email dated 15 Sep 2006
#ldflags		= -Wl,-O1,-Bdirect,--hash-style=both
159
#ldflags		= -Wl,-O1
160
## edd 06 May 2007  try it
161
## edd 05 Feb 2008  still no go under gcc 4.3
162
#ldflags		= -Wl,-O1,-Bdirect,--hash-style=both
163 164
## edd 31 Mar 2014
ldflags		= $(shell dpkg-buildflags --get LDFLAGS)
165

166 167 168
## edd 16 Apr 2008	add -g to optim flags to allow for -dbg package
optimflags	+= -g

169 170 171 172 173 174
## 12 Jan 2015
## Support for #774031 uncomment the two assignment to pass a non-empty string for this to hold
#builttime       := $(shell dpkg-parsechangelog -l$(CURDIR)/debian/changelog | awk -F': ' '/Date/ {print $$2}')
#builttimestamp  := "$(builttime)"
buildtimestamp  := ""

175
#arch = kfreebsd-amd64
176 177 178
maketest:
	@echo "Hi $(arch)"
	@echo "$(findstring $(arch), i486 hppa arm)" 
179
ifeq "$(findstring $(arch), kfreebsd-amd64 x86_64 hppa arm)" ""
180 181
	@echo "**** TRUE if the arch is NOT in the list as !find == '' ***"
endif
182
ifneq "$(findstring $(arch), kfreebsd-amd64 x86_64 i486 hppa arm)" ""
183 184 185 186
	@echo "**** TRUE if the arch is in list as find != '' is TRUE ***"
endif
	@echo Bye

187 188
get-orig-source: upstream
upstream:
189
        #links http://cran.us.r-project.org/src/base
190
	links http://cran.r-project.org/src/base/?M=D
191 192 193

upstreamdevel:
	links ftp://ftp.stat.math.ethz.ch/Software/R
194 195
        #links http://cran.us.r-project.org/src/base
        #rsync -vaC rsync.r-project.org::r-devel .
196

197
prerelease:
198 199
	links http://cran.r-project.org/src/base-prerelease

200 201 202
denmark:
	links http://www.biostat.ku.dk/~pd/R-release

203

204
## edd 24 Oct 2003  build is invoked by the buildd, so we would prefer to
205
##		    not imply build-indep; unfortunately R does not build
206 207
##		    properly without it, so we have to stick with it
## edd 15 Jan 2004  trying again on build only build: build-arch build-indep
208
##		    the main hook is to then have binary depend on both
209 210
##		    binary-arch and binary-indep, and those on their builds
build: build-arch 
211

212 213 214 215
build-arch: make-arch
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
build-arch: check
endif
216

217
build-indep: make-indep 
218 219 220 221

configure: configure-stamp
configure-stamp:	
	@echo "*** configure ***"
222 223 224 225 226

        # we have to disable use of the expanded R_LD_LIBRARY_PATH as it
        # conflicts with Debian's Atlas-can-replace-Blas scheme
        # so set R_LD_LIBRARY_PATH to the minimal value R_HOME/bin
        # and discard what configure finds for it on this machine
227 228
        ## edd 06 May 2007  no longer used in R.sh.in
        #perl -p -i -e 's|:\@R_LD_LIBRARY_PATH\@||' src/scripts/R.sh.in
229

230 231 232 233 234 235 236 237
        # edd 15 Dec 2009  the sh4 architecture needs newer configure than 
        #                  R Core uses, so following Kurt's recommendation to
        #                  simply re-run configure here
        # edd 03 Apr 2010  added automake
        #                  nope, commented both out
	#automake
	#autoconf

238
	dh_testdir
239
	R_PAPERSIZE=letter				\
240
	R_BROWSER=xdg-open				\
241 242
	PAGER=/usr/bin/pager				\
	PERL=/usr/bin/perl				\
243 244
	R_UNZIPCMD=/usr/bin/unzip			\
	R_ZIPCMD=/usr/bin/zip				\
245
	R_PRINTCMD=/usr/bin/lpr				\
246
	LIBnn=lib					\
247
	AWK=/usr/bin/awk                                \
248
	CC=$(compiler)					\
249
	CXX=${cxxcompiler}						\
250
	${fortrancompiler}					\
251
	FC=${f95compiler}					\
252 253 254 255
	CFLAGS="$(cflags)"				\
	CXXFLAGS="$(cxxflags)"				\
	FFLAGS="$(fcflags)"				\
	FCFLAGS="$(fcflags)"				\
256
	CPPFLAGS=					\
257
	LDFLAGS="$(ldflags)"				\
258
	FLIBS=						\
259 260 261
	rsharedir=/usr/share/R/share			\
	rincludedir=/usr/share/R/include		\
	rdocdir=/usr/share/R/doc			\
262
	./configure --prefix=/usr			\
263 264
		    --with-cairo			\
		    --with-jpeglib			\
265
		    --with-readline			\
266
		    --with-tcltk			\
267 268
		    --with-system-bzlib			\
		    --with-system-pcre			\
269
		    --with-system-zlib			\
270 271
		    --mandir=/usr/share/man		\
		    --infodir=/usr/share/info		\
272 273
		    --datadir=/usr/share/R/share	\
		    --includedir=/usr/share/R/include	\
274
		    $(atlas)		\
275
		    $(lapack)		\
276 277
		    --enable-R-profiling		\
		    --enable-R-shlib			\
278
		    --enable-memory-profiling		\
279
		    --without-recommended-packages	\
280
		    --build $(buildarch)
281

282 283
        ## Old options now ignore: --with-pango, --with-png, --without-gnome

284 285 286 287 288
	touch configure-stamp

make-arch: configure make-arch-stamp 
make-arch-stamp: 
	@echo "*** make-arch ***"
289 290 291
	$(MAKE)		CFLAGS="$(cflags)"			\
			CXXFLAGS="$(cxxflags)"			\
			FFLAGS="$(fcflags)"			\
292
			FCFLAGS="$(fcflags)"			\
293
			CC=${compiler}				\
294
			CXX=${cxxcompiler}			\
295
			${fortrancompiler}			\
296
			LDFLAGS="$(ldflags)"			\
297
			PKG_BUILT_STAMP="$(buildtimestamp)"	\
298
			R
299 300 301 302 303 304 305

        # the top-level 'make stamp-recommended' target implies 'make docs'
        # which (for the buildds) implies a lot of time wasted generating 
        # output we already take from the initial i386 build
#	$(MAKE)		CFLAGS="$(compilerflags)"		\
#			CXXFLAGS="$(compilerflags)"		\
#			FFLAGS="$(compilerflags)"		\
306
#			CC=${compiler}				\
307 308 309
#			CXX=${cxxcompiler}			\
#			${fortrancompiler}			\
#			stamp-recommended
310 311

        # make standalone math lib
312
	(cd src/nmath/standalone;				\
313 314 315
		$(MAKE)	CFLAGS="$(cflags) -D_REENTRANT"		\
			CXXFLAGS="$(cxxflags) -D_REENTRANT"	\
			FFLAGS="$(fcflags) -D_REENTRANT"	\
316 317
			CC=${compiler}				\
			CXX=${cxxcompiler}			\
318
			${fortrancompiler}			\
319
			libRmath_la_LDFLAGS=-Wl,-soname,libRmath.so.$(somaj) \
320
			shared static )
321 322 323 324 325 326 327 328 329

        # edd 25 Jan 2004  make install needs html docs
        # edd 03 Feb 2004  new test, try without 
        #make docs
        # edd 15 Jan 2004  make install needs html docs
        # edd 25 Jan 2004  not needed as we have 'make docs'
        ## make html
	$(MAKE) docs R_CMD_BUILD_HELP_OPTS="--txt --example"

330 331 332
        # edd 26 Mar 2013
	$(MAKE) javaconf

333 334 335 336 337
	touch make-arch-stamp

make-indep: configure make-indep-stamp
make-indep-stamp:
	@echo "*** make-indep ***"
338
        ## edd 12 Jan 2004 uncommenting 'make docs' to split binary all/any
339
        ##	  now that recommended packages aren't made
340 341
        ## edd 25 Jan 2004 make docs and make html are made in make-arch
        ## edd 05 Feb 2004 finally, this works in pre-1.9.0 with Kurt's
342
        ##		   R_CMD_BUILD_HELP_OPTS
343
	$(MAKE) docs
344 345
#	$(MAKE) html
#	$(MAKE) help
346
	$(MAKE) info
347 348 349
	(cd doc/manual && \
		$(MAKE) refman.pdf R-admin.pdf R-data.pdf R-exts.pdf \
			R-FAQ.pdf R-intro.pdf R-ints.pdf R-lang.pdf)
350
	$(MAKE) pdf
351
	$(MAKE) vignettes
352 353
	touch make-indep-stamp

354 355
make: make-stamp
make-stamp: make-arch make-indep 
356

357
check: make-arch check-stamp
358 359
check-stamp: 
	@echo "*** check ***"
360 361
#ifneq	($(arch),arm)
## edd 11 Oct 2005  also disable on hppa
362
## edd 15 Apr 2008  call inside of xvfb-run for virtual x11, and switch to check-all
363
ifeq "$(findstring $(arch), hppa arm)" ""
364 365
## edd 29 Jul 2013  also disable on kFreeBSD
ifneq ($(buildos),kfreebsd)
366
	-xvfb-run make check-all
367
endif
368 369
endif
	touch check-stamp
370 371

clean:
372
	@echo "*** clean ***"
373
	dh_testdir
374
	dh_testroot
375
	rm -f	configure-stamp \
376 377 378 379
		build-stamp build-indep-stamp build-arch-stamp \
		make-stamp make-arch-stamp make-indep-stamp \
		install-indep-stamp install-arch-stamp \
		check-stamp 
380
	[ ! -f Makefile ] || $(MAKE) distclean
381 382
	-rm -f `find . -name "*~"`
	-rm -rf debian/tmp debian/files* core debian/substvars
383
	-rm -f doc/html/function.html doc/html/packages.html
384
	-rm -f modules/*.so src/unix/Rscript
385
        # left over in CVS from r-base --> r-base-core transition
386 387
        #(cd debian; rm -vf r-base.dirs r-base.files r-base.lintian \
        #		r-base.menu r-base.postinst)	
388
	dh_clean
389

390
install: install-arch install-indep 
391

392
install-arch: build-arch install-arch-stamp
393 394
install-arch-stamp: 
	@echo "*** install-arch ***"
395 396
	dh_testdir
	dh_testroot
397
	dh_prep -a
398
	dh_installdirs -A
399 400 401
	@echo $(debtmp)

	$(MAKE) DESTDIR=$(debtmp) install
402

403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
        # edd 16 Apr 2008  make Rscript _again_ as the build is broken
        #                  and we need an explicit RHOME
	(cd src/unix; 						\
		rm -vf Rscript $(debtmp)/usr/bin/Rscript;	\
		$(MAKE)	CFLAGS="$(cflags) -D_REENTRANT"		\
			CXXFLAGS="$(cxxflags) -D_REENTRANT"	\
			FFLAGS="$(fcflags) -D_REENTRANT"	\
			CC=${compiler}				\
			CXX=${cxxcompiler}			\
			${fortrancompiler}			\
			RHOME=/usr/lib/R			\
			DESTDIR=$(debtmp)			\
			install-Rscript )
	#ls -ltr $(debtmp)/usr/bin/
	#strings src/unix/Rscript					
	cp -vax src/unix/Rscript $(debtmp)/usr/bin/
	#ls -ltr $(debtmp)/usr/bin/
	#strings $(debtmp)/usr/bin/Rscript

422 423
	(cd src/nmath/standalone;				\
		$(MAKE) DESTDIR=$(debtmp) install )
424 425

        # fix permissions (Lintian)
426
        # edd 15 Jan 2006 now under /usr/share/R
427 428 429 430
        # edd 13 Oct 2009 no longer have help-{links,print}.sh
	chmod a+x	$(debtmp)/usr/share/R/share/sh/echo.sh		
#			$(debtmp)/usr/share/R/share/sh/help-links.sh	\
#			$(debtmp)/usr/share/R/share/sh/help-print.sh
431

432 433
        # remove unneeded license file, but link them back
	rm -v	$(debtmp)/usr/lib/R/COPYING  		
434
	(cd $(debtmp)/usr/lib/R/; \
435
		ln -s ../../share/common-licenses/GPL-2 COPYING)
436
	rm -v	$(debtmp)/usr/share/R/doc/COPYING  	
437
	(cd $(debtmp)/usr/share/R/doc; \
438
		ln -s ../../../share/common-licenses/GPL-2 COPYING)
439

440
        # edd 15 Jul 2002 reduce compile load on small machines
441 442 443
#ifneq "$(findstring $(arch), m68k arm)" ""
#	perl -p -i -e 's/-g -O2/-g0 -O0/g' $(debtmp)/usr/lib/R/etc/Makeconf
#endif
444

445
        # edd 10 Jan 2003 fix Perl interpreter path
446 447 448 449 450 451
        # edd 05 May 2005  no longer needed
# 	(cd $(debtmp)/usr/lib/R/bin;					\
# 	    for file in Rdconv Rprof Sd2Rd build check; do	\
# 		perl -p -i -e "s|/usr/local/bin/perl|/usr/bin/perl|"	\
# 		   $${file};						\
# 	done)
452

453
        # edd 25 Sep 2005  link TeX files into texmf
454
	# edd 03 Oct 2006  use link into /usr/share/, not /usr/lib/
455
	(cd $(debtmp)/usr/share/texmf/tex/latex && 	\
456 457
	    ln -s ../../../R/share/texmf R)

458 459 460 461
        # that being done, now install in different sub-packages

        # move files for r-recommended

462 463
        # move the html manual files in r-doc-html.files into r-doc-html 
        # these get built in make-arch too ...
464 465
	dh_movefiles	--sourcedir=debian/$(corepackage) -p$(htmlpackage)

466
        # move files for r-base-html
467
	dh_movefiles	--sourcedir=debian/$(corepackage) -pr-base-html
468
        # move files for r-base-latex
469
	dh_movefiles	--sourcedir=debian/$(corepackage) -pr-base-latex
470

471 472 473
	make		prefix=$(debtmp)/usr			\
			rdocdir=$(debtmp)/usr/share/R/doc	\
			install-pdf
474 475

        # the indep package r-doc-info is made now 
476
	make		prefix=$(debtmp)/usr  \
477 478 479
			infodir=$(debtmp)/usr/share/info	install-info

        # move the pdf manual files listed in r-doc-pdf.files into r-doc-pdf 
480 481
	dh_movefiles	--sourcedir=debian/$(corepackage) -p$(pdfpackage)

482
        # move the html manual files in r-doc-html.files into r-doc-html 
483 484
	dh_movefiles	--sourcedir=debian/$(corepackage) -p$(htmlpackage)

485
	touch install-indep-stamp
486 487
        # edd 06 Dec 2006 lintian wants them compressed with -9, and R
        #                 seems to pre-zip them lower
488
	gunzip -9v $(debtmp)/usr/share/info/*.gz
489
        # move files for r-doc-info
490
	dh_movefiles	--sourcedir=debian/$(corepackage) -p$(infopackage)
491
        # deal with stupid automake / install-info issue (cf #235713)
492 493
	rm -vf	$(debinf)/usr/share/info/dir		\
		$(debinf)/usr/share/info/dir.old	
494 495

        # move all the rest into r-base-core
496 497
        # edd 10 Sep 2005  no longer needed as we install into r-base-core
        # dh_movefiles	-p$(corepackage)
498 499

        # for the standalone library package, move the two libs
500 501
        # as 'make install' ignores these, we have to do it by hand
	dh_installdirs -p$(nmathpackage) usr/include usr/lib \
502 503
					usr/share/lintian/overrides \
					usr/lib/pkgconfig
504 505 506
        # move the libraries made and installed by R, and the pkgconfig file
	dh_movefiles	--sourcedir=debian/$(corepackage) -p$(nmathpackage)
        # move the library to a lib*.so.major.0.0, then link
507
	(cd $(debmat)/usr/lib; \
508 509 510 511 512
			ls -l ; \
			mv -v  libRmath.so 	     libRmath.so.$(libver); \
			ln -sv libRmath.so.$(libver) libRmath.so.$(somaj); \
			ln -sv libRmath.so.$(somaj)  libRmath.so)

513
        # and create a link for Rmath.h 
514 515 516
        # rather copy directly into the more independent package r-mathlib
	install -m 0644 src/include/Rmath.h			\
			$(debmat)/usr/include
517

518 519 520
        # now deal with $R_HOME/etc <--> /etc/R
        # edd 03 Apr 2003  patch Renviron for new R_LIBS standard
        # edd 24 Apr 2004  patch Renviron for R_PAPERSIZE (bug #245525)
521
        # edd 16 Jun 2004	 nope, doesn't work
522
        # edd 09 Apr 2005  also move the new file repositories to /etc/R
523
        # edd 24 Sep 2006  idem for ldpaths
524 525
        # edd 21 Jun 2008  do not move Renviron to /etc/R as ucf will handle this, 
        #                  but still provide the softlink from /etc/R here
526 527 528
        # edd 13 Sep 2008  install Rprofile.site and Renviron.site and link back
	install -m 0644 debian/Rprofile.site $(debcnf)
	install -m 0644 debian/Renviron.site $(debcnf)
529 530
	(cd $(debetc); \
		cat $(debbase)/Renviron-R_LIBS.patch | patch --verbose;	\
531 532
		mv Makeconf repositories ldpaths ../../../../etc/R/;	\
		mv Renviron Renviron.ucf;				\
533
		ln -s  /etc/R/Makeconf	.;				\
534
		ln -s  /etc/R/Renviron	.;				\
535 536
		ln -s  /etc/R/Renviron.site .;				\
		ln -s  /etc/R/Rprofile.site .;				\
537
		ln -s  /etc/R/ldpaths   .;                              \
538
		ln -s  /etc/R/repositories .				)
539
#		cat $(debbase)/Renviron-R_PAPERSIZE.patch | patch --verbose; 
540 541

        # deal with build.help.pl's --htmllists argument
542 543 544
        # edd 29 Jan 2009  Not needed as of R 2.9.0
        #(cd $(debtmp)/usr/share/R/share/perl; \
        #	cat $(debbase)/build-help.pl.patch | patch --verbose )
545 546

        # edd 28 Sep 2006  patch javareconf to modify in /etc/R
547 548 549
        # edd 24 Feb 2013  disabled for R 2.15.3
        #(cd $(debtmp)/usr/lib/R/bin; \
        #	cat $(debbase)/javareconf.patch | patch --verbose )
550

551 552
        # edd 24 Jan 2006  deal with old postinst/postrm scripts 
        #                  calling the old /usr/lib/R/share/perl path
553 554
        #(cd $(debtmp)/usr/lib/R && ln -s ../../share/R/share . )
        # edd 06 Feb 2006  softlink fails with upgrades from older versions
555 556 557 558
        # edd 29 Jan 2009  Not needed as of R 2.9.0
        # dh_installdirs -p$(corepackage) usr/lib/R/share/perl
        # install -m 0644 debian/build-help.pl	\
        #	debian/$(corepackage)/usr/lib/R/share/perl/
559

560
        # add tab completion by Deepayan
561 562 563 564
        #install -m 0644 debian/R.bash_completion	\
        #	debian/$(corepackage)/etc/bash_completion.d/R
        # edd 24 Mar 2014  now installs via dh_bash-completion
	dh_bash-completion	
565

566
        # edd 02 May 2007  add libR.conf for ld.so
567 568 569
        # edd 13 Sep 2009  no more under Policy 3.8.3
#	install -m 0644 debian/libR.conf \
#		debian/$(corepackage)/etc/ld.so.conf.d/libR.conf
570 571 572
        # edd 03 Apr 2010  add a link from usr/lib
	(cd $(debtmp)/usr/lib/; \
		ln -sv R/lib/libR.so . )
573

574
        # edd 21 Jun 2012  add icon and desktop file from Philip Johnson's patch
575 576 577 578 579 580 581
	(cd debian/icon-class-patch && munpack rlogo_icon.png.mpack)
	install -m 0644 debian/icon-class-patch/rlogo_icon.png	\
		debian/$(corepackage)/usr/share/icons/hicolor/48x48/apps
	install -m 0644 debian/icon-class-patch/R.desktop		\
		debian/$(corepackage)/usr/share/applications
	rm debian/icon-class-patch/rlogo_icon.png

582 583 584 585 586 587
	touch install-arch-stamp

#install-indep: make-arch make-indep install-arch install-indep-stamp
install-indep: make-indep install-indep-stamp
install-indep-stamp: 
	@echo "*** install-indep ***"
588 589
	dh_testdir
	dh_testroot
590
	dh_prep -a
591 592
	dh_installdirs -A

593
#	make		prefix=$(debtmp)/usr			install-pdf
594
#
595 596
#	 # the indep package r-doc-info is made now 
#	make		prefix=$(debtmp)/usr  \
597 598
#			infodir=$(debtmp)/usr/share/info	install-info
#
599
#	 # move the pdf manual files listed in r-doc-pdf.files into r-doc-pdf 
600
#	dh_movefiles	-p$(pdfpackage)		
601
#	 # move the html manual files in r-doc-html.files into r-doc-html 
602 603
#	dh_movefiles	-p$(htmlpackage)		
#	touch install-indep-stamp
604
#	 # move files for r-doc-info
605
#	dh_movefiles	-p$(infopackage)
606

607
        # but clean up dir and old.dir	
608
	rm -vf		$(debbase)/$(infopackage)/usr/share/info/dir \
609
			$(debbase)/$(infopackage)/usr/share/info/dir.old
610

611 612 613
	touch install-indep-stamp


614
# Build architecture-independent files here.
615
# edd 5 Feb 2004 binary-indep: build-indep install-indep
616 617 618 619
binary-indep: build-indep install-indep
	@echo "*** binary-indep ***"
	dh_testdir -i
	dh_testroot -i
620
	dh_link -i 
621 622
        #dh_installdebconf -i
	dh_installdocs -i
623
	dh_installdocs -v -p$(htmlpackage)				
624 625 626 627 628 629 630 631 632 633 634 635
        #dh_installexamples -i
        #dh_installmenu -i
        #dh_installemacsen -i
        #dh_installpam -i
        #dh_installmime -i
        #dh_installinit -i
        #dh_installcron -i
        #dh_installmanpages -i
        #dh_installinfo -i
        #dh_undocumented -i
	dh_installchangelogs -i	
        # install lintian "silencer"
636 637
        # edd 13 Oct 2009  this package is no longer needed / created
#	install -p -m 0644  debian/$(latexpackage).lintian $(debbase)/$(latexpackage)/usr/share/lintian/overrides/$(latexpackage)
638 639 640 641 642

	dh_installdirs -p$(devpackage) usr/share/R/debian
	install -p -m 0755  debian/r-cran.mk \
		$(debbase)/$(devpackage)/usr/share/R/debian

643 644 645 646 647 648
	dh_compress -i
	dh_fixperms -i
        #dh_suidregister -i
	dh_installdeb -i
        #dh_perl -i
	dh_gencontrol -i
649
	dh_md5sums -i
650 651 652
	dh_builddeb -i

# Build architecture-dependent files here.
653
binary-arch: build-arch install-arch
654 655 656 657
	@echo "*** binary-arch ***"
	dh_testdir -a
	dh_testroot -a
        #dh_installdebconf -a
658
        # edd 04 Apr 2006	AUTHORS RESOURCES THANKS Y2K FAQ all gone
659
	dh_installdocs -p$(corepackage) doc/NEWS.* README \
660 661
					debian/README.Atlas \
					debian/README.mathlib
662
	dh_installdocs -p$(nmathpackage)  doc/NEWS.* README \
663
					debian/README.mathlib
664
	dh_installdocs -p$(dbugpackage)				
665 666 667
        #dh_installexamples -a
        #dh_installexamples -p$(corepackage)	src/nmath/standalone/test.c
	dh_installexamples -p$(nmathpackage)	src/nmath/standalone/test.c
668 669 670 671 672 673
	dh_installmenu -a
        #dh_installemacsen -a
        #dh_installpam -a
        #dh_installmime -a
        #dh_installinit -a
        #dh_installcron -a
674
        #dh_installmanpages -a	-p$(corepackage) getline.3
675
        #dh_installman		-p$(corepackage) doc/R.1
676
        ## dh_installinfo -a	-n doc/manual/R-*.info*
677 678 679 680
        ## edd 04 Apr 2004 manual is dangling unless r-doc-pdf is installed ...
        ##(cd $(debdoc)/doc && ln -s ../../../../lib/R/doc/html .)
        ##(cd $(debdoc)/doc && ln -s ../../../../lib/R/doc/manual .)
        # ... so install doc as a link, as we already did with library
681 682
	# (cd $(debdoc) && ln -s ../../../lib/R/doc .)
	(cd $(debdoc) && ln -s ../../R/doc .)
683
	(cd $(debdoc) && ln -s ../../../lib/R/library .)
684 685 686
        # install lintian "silencer"
	install -p -m 0644  debian/$(corepackage).lintian \
	   $(debbase)/$(corepackage)/usr/share/lintian/overrides/$(corepackage)
687 688
	install -p -m 0644  debian/$(recdpackage).lintian \
	   $(debbase)/$(recdpackage)/usr/share/lintian/overrides/$(recdpackage)
689 690
	install -p -m 0644  debian/$(nmathpackage).lintian \
	   $(debbase)/$(nmathpackage)/usr/share/lintian/overrides/$(nmathpackage)
691 692
#	install -p -m 0644  debian/$(dbugpackage).lintian \
#	   $(debbase)/$(dbugpackage)/usr/share/lintian/overrides/$(dbugpackage)
693
        #dh_undocumented -a
694
	dh_installchangelogs -a	-k doc/NEWS 
695 696 697
#	dh_strip -a
	dh_strip	--sourcedir=$(debtmp) --dbg-package=r-base-core-dbg
	dh_strip 	--sourcedir=$(debmat)
698 699 700
	dh_compress -a
	dh_fixperms -a
        #dh_suidregister -a
701
	dh_link -a
702 703 704
	dh_makeshlibs -a
	dh_installdeb -a
	dh_perl -a
705
	dh_shlibdeps -a -l $(debbase)/$(corepackage)/usr/lib/R/lib
706 707 708 709 710 711 712 713 714
#	@echo "*** Pruning shlibdeps result from double atlas entry ***"
#	cat debian/r-base-core.substvars
#	perl -p -i -e 's/atlas2-base, //' debian/r-base-core.substvars
#	cat debian/r-base-core.substvars
#	@echo "*** Pruning atlas from r-recommended shlibdeps ***"
#	cat debian/r-recommended.substvars
#	perl -p -i -e 's/atlas2-base, //' debian/r-recommended.substvars
#	cat debian/r-recommended.substvars
#	echo "*** Done ***"
715
	dh_gencontrol -a
716
	dh_md5sums -a
717 718
	dh_builddeb -a

719 720 721
#binary: binary-indep binary-arch install-arch install-indep 
binary: make-stamp check binary-arch binary-indep

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