Makefile.fw 7.04 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#-*- Makefile -*-
#
# ${R_HOME}/Makefile.fw

top_builddir = .

include $(top_builddir)/Makeconf

install install-strip: install-R-framework
		@(sed 's|^LIBR =.*|LIBR = -F$(R_FRAMEWORK_DIR)/.. -framework R|' \
		  $(top_builddir)/etc/Makeconf > "$(rhome)/etc${R_ARCH}/Makeconf")
		@(sed 's/Versions\/$(FW_VERSION)\/Resources/Resources/' \
13 14 15 16 17
		  "$(DESTDIR)$(R_FRAMEWORK_DIR)/Resources/bin/R" > \
		  "$(DESTDIR)$(R_FRAMEWORK_DIR)/Resources/bin/RR")
		@(mv "$(DESTDIR)$(R_FRAMEWORK_DIR)/Resources/bin/RR" "$(DESTDIR)$(R_FRAMEWORK_DIR)/Resources/bin/R")
		@(chmod a+x "$(DESTDIR)$(R_FRAMEWORK_DIR)/Resources/bin/R")
		@(chmod -R g+w "$(DESTDIR)$(R_FRAMEWORK_DIR)")
18 19 20 21


install-R-framework:
	@$(ECHO) "Creating R framework ..."
22
	@(cd "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)" && \
23 24
	  ln -f -s -n Resources/include Headers && \
	  ln -f -s -n Resources/lib/libR.dylib R)
25 26 27
	@if [ ! -e "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/PrivateHeaders" ]; then \
	 mkdir "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/PrivateHeaders"; fi
	@(cd "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions" && \
28
	  ln -f -s -n $(FW_VERSION) Current)
29 30
	@(if [ -e "$(DESTDIR)$(R_FRAMEWORK_DIR)/Resources" -a ! -L "$(DESTDIR)$(R_FRAMEWORK_DIR)/Resources" ]; then \
	  rm -rf "$(DESTDIR)$(R_FRAMEWORK_DIR)/Resources.old"; mv "$(DESTDIR)$(R_FRAMEWORK_DIR)/Resources" "$(DESTDIR)$(R_FRAMEWORK_DIR)/Resources.old"; \
31
	  fi)
32
	@(cd "$(DESTDIR)$(R_FRAMEWORK_DIR)"  && \
33 34 35 36 37 38
	  ln -f -s -n Versions/Current/PrivateHeaders PrivateHeaders&& \
	  ln -f -s -n Versions/Current/Headers Headers&& \
	  ln -f -s -n Versions/Current/R R && \
	  ln -f -s -n Versions/Current/Resources/lib Libraries && \
	  ln -f -s -n Versions/Current/Resources Resources)
	@## the resulting libR will point dyld to the fat libR regardless of its origin
39
	@(cd "$(DESTDIR)$(R_FRAMEWORK_DIR)/Resources/lib" && \
40
	  install_name_tool -id "$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/lib/libR.dylib" $(Rexeclibdir)/libR.dylib)
41
	@( otool=otool ; if otool -D "$(DESTDIR)$(Rexeclibdir)/libR.dylib"|grep 'not an object'>/dev/null; then otool=otool64; fi; \
42
	   for lib in Rlapack Rblas R; do \
43 44
	   if test -e "$(DESTDIR)$(Rexeclibdir)/lib$${lib}.dylib"; then $(ECHO) "  lib$${lib}"; \
	    find "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/" -name '*.so' -or -name '*.dylib' | \
45
	    xargs -n 1 install_name_tool -change \
46
	    `$${otool} -L "$(DESTDIR)$(Rexeclibdir)/lib$${lib}.dylib" |sed -n -e '2 s/.\(.*\) (compat.*/\1/p'` \
47
	    "$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/lib/lib$${lib}.dylib" ; \
48
	    find "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/" -name '*.so' -or -name '*.dylib' | \
49 50 51
	    xargs -n 1 install_name_tool -change lib$${lib}.dylib \
	    "$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/lib/lib$${lib}.dylib" ; \
	    install_name_tool -id "$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/lib/lib$${lib}.dylib" \
52
	    "$(DESTDIR)$(Rexeclibdir)/lib$${lib}.dylib"; \
53
	    if [ "$(Rexeclibdir)" != "$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/lib" ]; then \
54
	      $(top_srcdir)/tools/updatefat "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/lib/lib$${lib}.dylib" "$(DESTDIR)$(Rexeclibdir)/lib$${lib}.dylib"; \
55
	      install_name_tool -id "$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/lib/lib$${lib}.dylib" \
56
	      "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/lib/lib$${lib}.dylib"; \
57
	    fi; \
58
	    for rexe in `ls "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)"/Resources/bin/exec/*/R "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/bin/exec/R" 2>/dev/null`; do \
59 60 61 62 63
	     install_name_tool -change lib$${lib}.dylib \
	     "$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/lib/lib$${lib}.dylib" "$$rexe" ; \
	    done; \
           fi; \
          done)
64 65 66 67
	@(cp -R $(top_srcdir)/src/include/* "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/Current/PrivateHeaders/" && \
	  cp src/include/config.h "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/Current/PrivateHeaders/" && \
	  chmod a+r "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/Current/PrivateHeaders/config.h"; \
	  find "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/Current/PrivateHeaders" -name .svn | xargs rm -rf)
68 69
	@(install_name_tool -change libR.dylib \
	    "$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/lib/libR.dylib" \
70
	    "$(DESTDIR)$(Rexecbindir2)/R")
71
	@(if [ -n "${R_ARCH}" ]; then \
72 73 74 75 76 77 78 79
	  rm -rf "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/Current/PrivateHeaders${R_ARCH}" && \
	  mkdir "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/Current/PrivateHeaders${R_ARCH}" && \
	  cp src/include/config.h "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/Current/PrivateHeaders${R_ARCH}/config.h"; \
	  chmod a+r "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/Current/PrivateHeaders${R_ARCH}/config.h"; \
	  sed -e "s|R_ARCH=${R_ARCH}|R_ARCH=/\`arch\`|" "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/bin/R" \
	  > "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/bin/.tmp.R" && \
	  chmod a+x "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/bin/.tmp.R" && \
	  mv "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/bin/.tmp.R" "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/bin/R"; \
80 81 82 83
	  if [ "${R_ARCH}" != /ppc -a "${R_ARCH}" != /i386 -a "${R_ARCH}" != /ppc64 -a "${R_ARCH}" != /x86_64 -a "${R_ARCH}" != /arm ]; then \
	    $(ECHO) "\
	*** WARNING: The architecture name is incompatible with Apple's naming~              convention. This may prevent applications from using the R~              framework. Please use i386, x86_64, ppc, ppc64 or arm as architecture~              names to allow universal builds."|sed 'y/~/\n/' >&2; \
	  else \
84
	    for f in `ls "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Headers/${R_ARCH}/"*.h|xargs basename` config.h; do \
85
	      fn="Headers/$$f"; if [ "$$f" = "config.h" ]; then fn="PrivateHeaders/config.h"; fi; \
86
	      $(ECHO) "/* This is an automatically generated universal stub for architecture-dependent headers. */~#ifdef __i386__~#include \"i386/$$f\"~#elif defined __ppc__~#include \"ppc/$$f\"~#elif defined __ppc64__~#include \"ppc64/$$f\"~#elif defined __x86_64__~#include \"x86_64/$$f\"~#elif defined __arm__~#include \"arm/$$f\"~#else~#error \"Unsupported architecture.\"~#endif" |sed -e 'y/~/\n/' > "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/$$fn"; \
87 88 89
	    done; \
	  fi; \
	fi )
90 91 92
	@( rm -f "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/R" && \
	   ln -s bin/R "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/R" )
	@( $(ECHO) "<?xml version=\"1.0\" encoding=\"UTF-8\"?>~<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">~<plist version=\"1.0\">~<dict>~ <key>CFBundleIdentifier</key>~ <string>org.r-project.R-framework</string>~ <key>CFBundleInfoDictionaryVersion</key>~ <string>6.0</string>~ <key>CFBundleName</key>~ <string>R</string>~ <key>CFBundlePackageType</key>~ <string>FMWK</string>~ <key>CFBundleVersion</key>~ <string>$(VERSION)</string>~</dict>~</plist>" |sed -e 'y/~/\n/' > "$(DESTDIR)$(R_FRAMEWORK_DIR)/Versions/$(FW_VERSION)/Resources/Info.plist")