#-*- Makefile -*- # $(R_HOME}/etc$(R_ARCH)/Makeconf # Substituted by fixed/Makefile USE_LLVM = # Hand-edited version for gnuwin32. ifdef DEBUG DLLFLAGS= DEBUGFLAG=$(if $(USE_LLVM),-g3,-gdwarf-2) FDEBUGFLAG=$(if $(USE_LLVM),,-gdwarf-2) else DLLFLAGS=-s DEBUGFLAG= FDEBUGFLAG= endif DLLFLAGS += -static-libgcc LINKFLAGS += -static-libgcc ## Things which are substituted by fixed/Makefile (and also -O3 -> -O2) WIN = 64 MINGW_PREFIX = /mingw$(WIN) BINPREF = COMPILED_BY = # SYMPAT = 's/^.* [BCDRT] / /p' for 64-bit SYMPAT = @SYMPAT@ IMPDIR = bin # flags for multilib builds, for compilers, dlltool and windres M_ARCH = DT_ARCH = RC_ARCH = # Used by packages tcltk and tkrplot TCL_HOME = $(R_HOME)/Tcl # automatically rewritten to assign value from MkRules LOCAL_SOFT ?= R_INSTALLER_BUILD = no # INSTALLER-BUILD: R_INSTALLER_BUILD = yes ifeq ($(R_INSTALLER_BUILD), yes) ifneq ($(strip $(R_CUSTOM_TOOLS_SOFT)),) LOCAL_SOFT = $(R_CUSTOM_TOOLS_SOFT) else ## The rtools43 installer sets RTOOLS43_HOME (or RTOOLS43_AARCH64_HOME) # INSTALLER-BUILD-x86_64: RTOOLS43_HOME ?= c:/rtools43 # INSTALLER-BUILD-x86_64: LOCAL_SOFT = $(subst \,/,$(RTOOLS43_HOME))/x86_64-w64-mingw32.static.posix # INSTALLER-BUILD-aarch64: RTOOLS43_HOME ?= c:/rtools43-aarch64 # INSTALLER-BUILD-aarch64: LOCAL_SOFT = $(subst \,/,$(RTOOLS43_AARCH64_HOME))/aarch64-w64-mingw32.static.posix endif endif R_TOOLS_SOFT ?= $(LOCAL_SOFT) NM_FILTER = ifneq ($(strip $(LOCAL_SOFT)),) LOCAL_CPPFLAGS = -I"$(LOCAL_SOFT)/include" LOCAL_LIBS = -L"$(LOCAL_SOFT)/lib$(R_ARCH)" -L"$(LOCAL_SOFT)/lib" endif LLVMPREF = $(if $(USE_LLVM),llvm-,) CCBASE = $(if $(USE_LLVM),clang,gcc) DLLTOOL = $(BINPREF)$(LLVMPREF)dlltool --as $(BINPREF)$(LLVMPREF)as $(DT_ARCH) DLLTOOLFLAGS = -k NM = $(BINPREF)$(LLVMPREF)nm RESCOMP = $(BINPREF)$(LLVMPREF)windres $(RC_ARCH) ## MAIN_LD needs to be set by the package LINKER = $(MAIN_LD) ## as a default DLL = $(CC) ## Things defined in Renviron on Unix SED = sed TAR ?= tar TAR_OPTIONS ?= --force-local ## Things defined in MkRules CAT = cat CP = cp MKDIR = mkdir RM = rm -f SORT = sort ## For use in packages GRAPHAPP_LIB = -lRgraphapp TCL_VERSION = 86 # was a reference to Rzlib.dll in R < 3.2.0 ZLIB_LIBS = -lz AR = $(BINPREF)$(LLVMPREF)ar BLAS_LIBS = -L"$(R_HOME)/$(IMPDIR)" -lRblas C_VISIBILITY = CC = $(BINPREF)$(CCBASE) $(M_ARCH) CFLAGS = -O3 -Wall $(DEBUGFLAG) @EOPTS@ $(LTO) CPICFLAGS = CPPFLAGS = CC17 = $(BINPREF)$(CCBASE) $(M_ARCH) C17FLAGS = -O3 -Wall $(DEBUGFLAG) -std=gnu17 @EOPTS@ $(LTO) CC23 = $(BINPREF)$(CCBASE) $(M_ARCH) C23FLAGS = -O3 -Wall $(DEBUGFLAG) -std=gnu2x @EOPTS@ $(LTO) CC90 = $(BINPREF)$(CCBASE) $(M_ARCH) C90FLAGS = -O3 -Wall $(DEBUGFLAG) -std=gnu90 @EOPTS@ $(LTO) CC99 = $(BINPREF)$(CCBASE) $(M_ARCH) C99FLAGS = -O3 -Wall $(DEBUGFLAG) -std=gnu99 @EOPTS@ $(LTO) CXX = $(BINPREF)$(if $(USE_LLVM),clang++,g++) -std=gnu++17 $(M_ARCH) CXXCPP = $(CXX) -E CXXFLAGS = -O2 -Wall $(DEBUGFLAG) @EOPTS@ $(LTO) CXXPICFLAGS = CXX11 = $(BINPREF)$(if $(USE_LLVM),clang++,g++) $(M_ARCH) CXX11FLAGS = -O2 -Wall $(DEBUGFLAG) @EOPTS@ $(LTO) CXX11PICFLAGS = CXX11STD = -std=gnu++11 ## these settings are for GCC >= 10 CXX14 = $(CXX11) CXX14FLAGS = $(CXX11FLAGS) CXX14PICFLAGS = CXX14STD = -std=gnu++14 CXX17 = $(CXX11) CXX17FLAGS = $(CXX11FLAGS) CXX17PICFLAGS = CXX17STD = -std=gnu++17 CXX20 = $(CXX11) CXX20FLAGS = $(CXX11FLAGS) CXX20PICFLAGS = ## g++ 8/9 used 2a, 10 supports 20. CXX20STD = -std=gnu++20 CXX23 = $(CXX11) CXX23FLAGS = $(CXX11FLAGS) CXX23PICFLAGS = ## g++ >= 11 allow 23 CXX23STD = -std=gnu++2b DYLIB_EXT = .dll DYLIB_LD = $(DLL) DYLIB_LDFLAGS = -shared DYLIB_LINK = $(DYLIB_LD) $(DYLIB_LDFLAGS) $(LDFLAGS) ECHO = echo ECHO_C = ECHO_N = -n ECHO_T = ## unsupported on Windows F_VISIBILITY = ## FC is the compiler used for all Fortran as from R 3.6.0 ifdef USE_LLVM FC = $(BINPREF)flang $(M_ARCH) FLIBS = -lFortranRuntime -lFortranDecimal -lm else FC = $(BINPREF)gfortran $(M_ARCH) FLIBS = -lgfortran -lm -lquadmath endif FCFLAGS = -O3 $(FDEBUGFLAG) @EOPTS@ $(LTO) ## additional libs needed when linking with $(FC), e.g. on some Oracle compilers FCLIBS_XTRA = #F77 = $(BINPREF)gfortran $(M_ARCH) #F77_VISIBILITY = FFLAGS = -O3 $(FDEBUGFLAG) @EOPTS@ $(LTO) #FCPICFLAGS = FPICFLAGS = FOUNDATION_CPPFLAGS = FOUNDATION_LIBS = JAR = JAVA = JAVAC = JAVAH = ## JAVA_HOME might be used in the next three. ## They are for packages 'JavaGD' and 'rJava' # JAVA_HOME = JAVA_CPPFLAGS = -I"$(JAVA_HOME)/../include" -I"$(JAVA_HOME)/../include/win32" JAVA_LIBS = -L"$(JAVA_HOME)/bin/client" -ljvm -ljvm-w32 # JAVA_LD_LIBRARY_PATH = LAPACK_LIBS = -L"$(R_HOME)/$(IMPDIR)" -lRlapack LDFLAGS = ## we only need this is if it is external, as otherwise link to R LIBINTL = LIBM = -lm LIBR = -L"$(R_HOME)/$(IMPDIR)" -lR LIBS = -lm ## needed by R CMD config LIBnn = lib LIBTOOL = LTO = ## used in INSTALL LTO_OPT = ## needed to build applications linking to static libR # MAIN_LD = # MAIN_LDFLAGS = # MAIN_LINK = $(MAIN_LD) $(MAIN_LDFLAGS) $(LDFLAGS) # assume suitable mkdir on PATH (e.g. from Msys2) MKINSTALLDIRS = mkdir -p NM = $(BINPREF)nm ## There is no ObjC support in the recommended toolchain, ## but if a toolchain had support, this it what it would be. OBJC = $(CC) OBJCFLAGS = -O2 OBJC_LIBS = -lobjc OBJCXX = OBJDUMP = $(BINPREF)objdump R_ARCH = RANLIB = $(BINPREF)ranlib SAFE_FFLAGS = -O2 $(if $(USE_LLVM),,-msse2 -mfpmath=sse) SED = sed ## it seems some makes (but not ours) get upset if SHELL is set. # SHELL = /bin/sh SHLIB_CFLAGS = SHLIB_CXXFLAGS = SHLIB_CXXLD = $(CXX) ## ideally -shared -static-libstdc++, but not for gcc 4.2.1 SHLIB_CXXLDFLAGS = -shared #SHLIB_CXX98LD = $(CXX98) #SHLIB_CXX98LDFLAGS = -shared SHLIB_CXX11LD = $(CXX11) SHLIB_CXX11LDFLAGS = -shared SHLIB_CXX14LD = $(CXX14) SHLIB_CXX14LDFLAGS = -shared SHLIB_CXX17LD = $(CXX17) SHLIB_CXX17LDFLAGS = -shared SHLIB_CXX20LD = $(CXX20) SHLIB_CXX20LDFLAGS = -shared SHLIB_CXX23LD = $(CXX23) SHLIB_CXX23LDFLAGS = -shared SHLIB_EXT = .dll SHLIB_FCLD = $(FC) ## ideally -shared -static-libgfortran, but not for gcc 4.2.1 SHLIB_FCLDFLAGS = -shared SHLIB_FFLAGS = SHLIB_LD = $(CC) SHLIB_LDFLAGS = -shared SHLIB_LIBADD = SHLIB_LINK = $(SHLIB_LD) -Wl,--export-all-symbols $(SHLIB_LDFLAGS) $(LDFLAGS) SHLIB_OPENMP_CFLAGS = @OPENMP@ SHLIB_OPENMP_CXXFLAGS = @OPENMP@ SHLIB_OPENMP_FCFLAGS = @OPENMP@ SHLIB_OPENMP_FFLAGS = @OPENMP@ SHLIB_PTHREAD_FLAGS = @PTHREAD@ STRIP_SHARED_LIB = $(BINPREF)strip --strip-unneeded STRIP_STATIC_LIB = $(BINPREF)strip --strip-debug TCLTK_CPPFLAGS = -I "$(TCL_HOME)/include" -DWin32 TCLTK_LIBS = -L"$(TCL_HOME)/bin" -ltcl$(TCL_VERSION) -ltk$(TCL_VERSION) STATIC_LIBR = R_XTRA_CFLAGS = ## Allow next to be overriden for cross-builds. R_XTRA_CPPFLAGS ?= -I"$(R_HOME)/include" -DNDEBUG R_XTRA_CXXFLAGS = R_XTRA_FFLAGS = ifneq "$(LTO_OPT)" "" LTO = $(LTO_OPT) ifndef USE_LLVM AR = $(BINPREF)gcc-ar NM = $(BINPREF)gcc-nm RANLIB = $(BINPREF)gcc-ranlib endif SHLIB_LDFLAGS += $(CFLAGS) SHLIB_FCLDFLAGS += $(FFLAGS) SHLIB_CXXLDFLAGS += $(CXXFLAGS) SHLIB_CXX11LDFLAGS += $(CXX11FLAGS) SHLIB_CXX14LDFLAGS += $(CXX14FLAGS) SHLIB_CXX17LDFLAGS += $(CXX17FLAGS) SHLIB_CXX20LDFLAGS += $(CXX20FLAGS) endif ALL_CFLAGS = $(R_XTRA_CFLAGS) $(PKG_CFLAGS) $(CPICFLAGS) $(SHLIB_CFLAGS) $(CFLAGS) ALL_CPPFLAGS = $(R_XTRA_CPPFLAGS) $(PKG_CPPFLAGS) $(CLINK_CPPFLAGS) $(CPPFLAGS) $($*-CPPFLAGS) $(LOCAL_CPPFLAGS) ALL_CXXFLAGS = $(R_XTRA_CXXFLAGS) $(PKG_CXXFLAGS) $(CXXPICFLAGS) $(SHLIB_CXXFLAGS) $(CXXFLAGS) ALL_OBJCFLAGS = $(PKG_OBJCFLAGS) $(CPICFLAGS) $(SHLIB_CFLAGS) $(OBJCFLAGS) ALL_OBJCXXFLAGS = $(PKG_OBJCXXFLAGS) $(CXXPICFLAGS) $(SHLIB_CXXFLAGS) $(OBJCXXFLAGS) ALL_FFLAGS = $(R_XTRA_FFLAGS) $(PKG_FFLAGS) $(FPICFLAGS) $(SHLIB_FFLAGS) $(FFLAGS) ALL_LIBS = $(PKG_LIBS) $(LOCAL_LIBS) $(SHLIB_LIBADD) $(LIBR) $(LIBINTL) ## can be overridden by SHLIB P_FCFLAGS = $(PKG_FFLAGS) ALL_FCFLAGS = $(R_XTRA_FFLAGS) $(P_FCFLAGS) $(FPICFLAGS) $(SHLIB_FFLAGS) $(FCFLAGS) .SUFFIXES: .SUFFIXES: .c .cc .cpp .d .f .f90 .f95 .m .mm .M .o .a .def .dll .exe .rc .c.o: $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@ .c.d: @echo "making $@ from $<" @$(CC) -std=gnu99 -MM $(ALL_CPPFLAGS) $< > $@ .cc.o: $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $@ .cpp.o: $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $@ .cc.d: @echo "making $@ from $<" @$(CXX) -M $(ALL_CPPFLAGS) $< > $@ .cpp.d: @echo "making $@ from $<" @$(CXX) -M $(ALL_CPPFLAGS) $< > $@ .m.o: $(OBJC) $(ALL_CPPFLAGS) $(ALL_OBJCFLAGS) -c $< -o $@ .m.d: @echo "making $@ from $<" @$(OBJC) -MM $(ALL_CPPFLAGS) $< > $@ .mm.o: $(OBJCXX) $(ALL_CPPFLAGS) $(ALL_OBJCXXFLAGS) -c $< -o $@ .M.o: $(OBJCXX) $(ALL_CPPFLAGS) $(ALL_OBJCXXFLAGS) -c $< -o $@ .f.o: $(FC) $(ALL_FFLAGS) -c $< -o $@ .f95.o: $(FC) $(ALL_FCFLAGS) -c $< -o $@ .f90.o: $(FC) $(ALL_FCFLAGS) -c $< -o $@ ## Not used in R itself %.exe: $(LINKER) $(LINKFLAGS) $($*-LINKFLAGS) -o $@ $^ $($*-LIBS) $(LOCAL_LIBS) $(LIBS) %.dll: @echo EXPORTS > $*.def @$(NM) $^ | $(SED) -n $(SYMPAT) >> $*.def $(SHLIB_LD) $(SHLIB_LDFLAGS) $(DLLFLAGS) -o $@ $*.def $^ $(ALL_LIBS) @$(RM) $*.def ## It does not make much sense to have $($*-DLLTOOLFLAGS) here ## It is currently unused on CRAN lib%.dll.a: %.def $(DLLTOOL) $(DLLTOOLFLAGS) $($*-DLLTOOLFLAGS) --dllname $*.dll --input-def $*.def --output-lib $@ %.a: @$(RM) $@ $(AR) crs $@ $^ %.o: %.rc $(RESCOMP) $(RESFLAGS) -i $< -o $@