Makefile.win 3.06 KB
Newer Older
Radford Neal's avatar
Radford Neal committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#-*- Makefile -*-
include ../gnuwin32/MkRules
R_HOME=../..

VER=$(shell sed -e 's/\([^ ]*\).*/\1/' ../../VERSION)

## keep these in step with ./Makefile.in
SRC_HEADERS = R.h S.h Rdefines.h Rembedded.h Rinternals.h
## this deliberately does not include Rinterfaces.h, which is Unix-only
OBJ_HEADERS = Rconfig.h Rmath.h Rversion.h
GW32_HEADERS = iconv.h psignal.h

all: fixh config.h
	@echo 'installing C headers'
	@mkdir -p $(R_HOME)/include/R_ext
	@cp -p $(SRC_HEADERS) $(OBJ_HEADERS) iconv.h $(R_HOME)/include
17
	@cp -p ../extra/sggc/sggc.h ../extra/sggc/sggc-app.h \
18
	       ../extra/sggc/sbset.h ../extra/sggc/sbset-app.h R_ext
Radford Neal's avatar
Radford Neal committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
	@cp -p R_ext/*.h $(R_HOME)/include/R_ext
	@cp -p ../extra/graphapp/graphapp.h ../extra/graphapp/ga.h \
	  $(R_HOME)/include

version: Rversion.h

fixh: $(GW32_HEADERS) $(OBJ_HEADERS)
	@$(ECHO) done > fixh

config.h: ../gnuwin32/fixed/h/config.h ../../VERSION
	@$(SED) 's/@VERSION@/$(VER)/' $< > $@

iconv.h: ../gnuwin32/fixed/h/iconv.h
	@cp $< $@

psignal.h: ../gnuwin32/fixed/h/psignal.h
	@cp $< $@

Rconfig.h: config.h $(R_HOME)/tools/GETCONFIG
38
	@sh $(R_HOME)/tools/GETCONFIG $(WIN) > Rconfig.h
Radford Neal's avatar
Radford Neal committed
39 40 41 42

Rversion.h: $(R_HOME)/VERSION $(R_HOME)/SVN-REVISION $(R_HOME)/tools/GETVERSION
	@sh $(R_HOME)/tools/GETVERSION > $@

Radford Neal's avatar
Radford Neal committed
43
Rmath.h0: Rmath.h0.in $(R_HOME)/VERSION Makefile.win
Radford Neal's avatar
Radford Neal committed
44
	@$(SED) -e 's/@RMATH_HAVE_LOG1P@/# define HAVE_LOG1P 1/'  \
Radford Neal's avatar
Radford Neal committed
45 46
	  -e 's/@RMATH_HAVE_EXPM1@/# define HAVE_EXPM1 1/'  \
	  -e 's/@RMATH_HAVE_HYPOT@/# define HAVE_HYPOT 1/'  \
Radford Neal's avatar
Radford Neal committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
	  -e  's/@RMATH_HAVE_WORKING_LOG1P@/# define HAVE_WORKING_LOG1P 1/' \
	  -e "s/@PACKAGE_VERSION@/`sed 's/\([^ ]*\).*/\1/' < $(R_HOME)/VERSION`/" $< > Rmath.h0

Rmath.h: Rmath.h0
	@sh $(R_HOME)/tools/copy-if-change $< $@

## If we do not have svn, get the old file from SVN-REVISION.bak (if poss).
## This needs to be copy-on-change.
## The date from svn info is not in GMT, but we have decided to live
## with that as they changed the format in svn 1.4.x
## <FIXME> USE_SVNVERSION does not work if there is no 'svnversion'
FORCE:
$(R_HOME)/SVN-REVISION: FORCE
	@if test -f  $(R_HOME)/SVN-REVISION ; then \
	  cp -p $(R_HOME)/SVN-REVISION $(R_HOME)/SVN-REVISION.bak ; \
	fi
ifdef USE_SVNVERSION
	@LC_ALL=C svnversion ../.. | sed -n 's/^/Revision: /p' > svn-tmp || rm -f svn-tmp
65
	@grep -v exported svn-tmp > $(R_BIT_BUCKET) || rm -f svn-tmp
Radford Neal's avatar
Radford Neal committed
66
else
67
	@(cd ../..; LC_ALL=C svn info || echo "Revision: unknown") 2> $(R_BIT_BUCKET) \
Radford Neal's avatar
Radford Neal committed
68
	  | sed -n '/^Revision/p' > svn-tmp
69
	@if grep unknown svn-tmp > $(R_BIT_BUCKET) ; then \
Radford Neal's avatar
Radford Neal committed
70 71 72 73
	  rm svn-tmp; \
	fi
endif
	@if test -f svn-tmp ; then \
74
	  (cd ../..; LC_ALL=C TZ=GMT svn info || echo "Last Changed Date: unknown") 2> $(R_BIT_BUCKET) \
Radford Neal's avatar
Radford Neal committed
75 76 77 78 79 80
	    | sed -n '/^Last Changed Date:/p' | sed 's/[0-9][0-9]:.*//' \
	    >> svn-tmp ; \
	else \
	  rm -f svn-tmp ; \
	fi
	@if test -f svn-tmp; then \
81
	  if test ! -f $@ || ! cmp svn-tmp $@ > $(R_BIT_BUCKET) ; then\
Radford Neal's avatar
Radford Neal committed
82 83 84
	    cp svn-tmp $@; \
	  fi ; \
	else \
85
	  cp -p $(R_HOME)/SVN-REVISION.bak $@ 2> $(R_BIT_BUCKET) || \
Radford Neal's avatar
Radford Neal committed
86 87 88 89 90 91 92
	  (echo "Revision: 00000" > $@; \
	   echo "Last Changed Date: 2006-00-00" >> $@) ; \
	fi 
	@rm -f svn-tmp $(R_HOME)/SVN-REVISION.bak

distclean:
	$(RM) -f Rmath.h0 fixh