1# 2# ${R_HOME}/src/scripts/Makefile 3 4VPATH = @srcdir@ 5srcdir = @srcdir@ 6top_srcdir = @top_srcdir@ 7 8top_builddir = ../.. 9subdir = src/scripts 10 11include $(top_builddir)/Makeconf 12 13## don't add '#! R_SHELL' for scripts intend to be run by 'R CMD script' 14SCRIPTS_S = BATCH COMPILE INSTALL LINK REMOVE Rd2pdf Rdconv Rdiff Rprof \ 15 SHLIB Stangle Sweave build check config 16## <NOTE> 17## Need target rules for all elements of SCRIPTS_B_IN/SCRIPTS_B. 18SCRIPTS_B_IN = Rcmd.in javareconf.in mkinstalldirs.in pager.in rtags.in 19SCRIPTS_B = $(SCRIPTS_B_IN:.in=) 20## </NOTE> 21 22distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) 23DISTFILES = Makefile.in Makefile.win $(SCRIPTS_S) $(SCRIPTS_B_IN) R.sh.in 24 25CLEANFILES = 26DISTCLEANFILES = Makefile R.fe R.sh $(SCRIPTS_B) 27 28all: Makefile R 29 30Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 31 @cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 32 33R: $(SCRIPTS_B) R.fe 34 @$(MAKE) rhome=$(top_builddir) install-cmds 35 @$(INSTALL_SCRIPT) R.fe $(top_builddir)/bin/R 36 37## <NOTE> 38## Seems we need target rules for creating FOO from FOO.in: pattern 39## rules ('%:%.in') are not portable, and some versions of Make do not 40## allow separated dependencies for single suffix rules. 41Rcmd: $(srcdir)/Rcmd.in $(top_builddir)/config.status 42 @cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 43javareconf: $(srcdir)/javareconf.in $(top_builddir)/config.status 44 @cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 45makeinstalldirs: $(srcdir)/makeinstalldirs.in $(top_builddir)/config.status 46 @cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 47pager: $(srcdir)/pager.in $(top_builddir)/config.status 48 @cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 49rtags: $(srcdir)/rtags.in $(top_builddir)/config.status 50 @cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 51## The following target helps in automatically generating the above 52## target rules (provided that $(ECHO) understands backslash escapes). 53Makerules: 54 @(dep="\$$(top_builddir)/config.status"; \ 55 cmd="@cd \$$(top_builddir)"; \ 56 cmd="$${cmd} && \$$(SHELL) ./config.status \$$(subdir)/\$$@"; \ 57 for f in $(SCRIPTS_B); do \ 58 $(ECHO) "$${f}: \$$(srcdir)/$${f}.in $${dep}"; \ 59 $(ECHO) " $${cmd}"; \ 60 done) 61## </NOTE> 62 63## <NOTE> 64## The front-end shell script now (2000-08-02) also contains the version 65## information. As we keep this information outside configure (as 66## otherwise developers would have to reconfigure and hence rebuild 67## every day), we now first create 'R.sh' from 'R.sh.in' via configure, 68## and then use sed to create the front end ('R.fe') which gets 69## installed as 'R'. 70R.sh: $(srcdir)/R.sh.in $(top_builddir)/config.status 71 @cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 72R.fe: R.sh $(top_srcdir)/VERSION $(top_builddir)/SVN-REVISION 73 @$(ECHO) "creating $(subdir)/$@" 74 @(v=`cat $(top_srcdir)/VERSION`; \ 75 dat=`sed -e 1d -e 's/^Last Changed Date: //' $(top_builddir)/SVN-REVISION`; \ 76 v="$${v} ($${dat})"; \ 77 y=`$(ECHO) $${dat} | cut -d- -f1`; \ 78 d=`$(ECHO) "$(abs_top_builddir)" | sed 's,/,\\\/,g'`; \ 79 sed "1,/R_HOME_DIR/s/\\(R_HOME_DIR=\\).*/\\1\"$${d}\"/; \ 80 s@REPLACE_BY_VERSION@$${v}@; \ 81 s@REPLACE_BY_YEAR@$${y}@" < R.sh > $@) 82 @chmod +x $@ 83## </NOTE> 84 85$(top_builddir)/libtool: 86 @(cd $(@D); $(MAKE) $(@F)) 87 88install: installdirs install-cmds 89 @rm -f $(DESTDIR)$(bindir)/R 90 @(d=`$(ECHO) '$(rhome)' | sed 's,/,\\\/,g';`; \ 91 d2=`$(ECHO) '$(rsharedir)' | sed 's,/,\\\/,g';`; \ 92 d3=`$(ECHO) '$(rincludedir)' | sed 's,/,\\\/,g';`; \ 93 d4=`$(ECHO) '$(rdocdir)' | sed 's,/,\\\/,g';`; \ 94 sed -e "1,/R_HOME_DIR=/s/\\(R_HOME_DIR=\\).*/\\1$${d}/;" -e "s/\\(R_SHARE_DIR=\\).*/\\1$${d2}/;" -e "s/\\(R_INCLUDE_DIR=\\).*/\\1$${d3}/;" -e "s/\\(R_DOC_DIR=\\).*/\\1$${d4}/;"\ 95 < R.fe > "$(DESTDIR)$(Rexecbindir)/R") 96 @$(INSTALL_SCRIPT) "$(DESTDIR)$(Rexecbindir)/R" "$(DESTDIR)$(bindir)/R" 97 @chmod 755 "$(DESTDIR)$(bindir)/R" "$(DESTDIR)$(Rexecbindir)/R" 98## why of all the scripts does this alone chmod just one copy? 99installdirs: 100 @$(MKINSTALLDIRS) $(DESTDIR)$(bindir) 101install-cmds: 102 @$(MKINSTALLDIRS) "$(DESTDIR)$(Rexecbindir)" 103 @for f in $(SCRIPTS_S); do \ 104 source="$(srcdir)/$${f}"; \ 105 target="$(DESTDIR)$(Rexecbindir)/$${f}"; \ 106 (test -r "$${target}" && \ 107 cmp "$${source}" "$${target}" > /dev/null) || \ 108 $(INSTALL_SCRIPT) "$${source}" "$${target}"; \ 109 done 110 @for f in $(SCRIPTS_B); do \ 111 $(INSTALL_SCRIPT) $${f} "$(DESTDIR)$(Rexecbindir)"; \ 112 done 113 @$(INSTALL_SCRIPT) $(top_builddir)/libtool "$(DESTDIR)$(Rexecbindir)" 114## there are no programs to install in this dir 115install-strip: 116 @$(MAKE) INSTALL_PROGRAM="${INSTALL_PROGRAM} -s" install 117uninstall: 118 @for f in $(SCRIPTS_S) $(SCRIPTS_B) libtool R; do \ 119 rm -f "$(DESTDIR)$(Rexecbindir)/$${f}"; \ 120 done 121 @rm -f $(DESTDIR)$(bindir)/R 122 123mostlyclean: clean 124clean: 125 -@test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) 126distclean: clean 127 -@test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) 128maintainer-clean: distclean 129 130TAGS info dvi check: 131 132distdir: $(DISTFILES) 133 @for f in $(DISTFILES); do \ 134 test -f $(distdir)/$${f} \ 135 || ln $(srcdir)/$${f} $(distdir)/$${f} 2>/dev/null \ 136 || cp -p $(srcdir)/$${f} $(distdir)/$${f}; \ 137 done 138