1#
2# ${R_HOME}/src/main/Makefile
3
4VPATH = @srcdir@
5srcdir = @srcdir@
6top_srcdir = @top_srcdir@
7
8top_builddir = ../..
9subdir = src/main
10# next is needed for shared BLAS
11R_HOME=$(top_builddir)
12
13include $(top_builddir)/Makeconf
14
15SOURCES_C = \
16	CommandLineArgs.c \
17	Rdynload.c Renviron.c RNG.c \
18	agrep.c altclasses.c altrep.c apply.c arithmetic.c array.c attrib.c \
19	bind.c builtin.c \
20	character.c coerce.c colors.c complex.c connections.c context.c cum.c \
21	dcf.c datetime.c debug.c deparse.c devices.c \
22	dotcode.c dounzip.c dstruct.c duplicate.c \
23	edit.c engine.c envir.c errors.c eval.c \
24	format.c \
25	gevents.c gram.c gram-ex.c graphics.c grep.c \
26	identical.c inlined.c inspect.c internet.c iosupport.c \
27	lapack.c list.c localecharset.c logic.c \
28	main.c mapply.c match.c memory.c \
29	names.c \
30	objects.c options.c \
31	paste.c patterns.c platform.c plot.c plot3d.c plotmath.c \
32	print.c printarray.c printvector.c printutils.c qsort.c \
33	radixsort.c random.c raw.c registration.c relop.c rlocale.c \
34	saveload.c scan.c seq.c serialize.c sort.c source.c split.c \
35	sprintf.c startup.c subassign.c subscript.c subset.c summary.c sysutils.c \
36	times.c \
37	unique.c util.c \
38	version.c \
39	g_alab_her.c g_cntrlify.c g_fontdb.c g_her_glyph.c
40
41SOURCES_F =  xxxpr.f
42
43## If the substitutes are needed, the corresponding objects are put by
44## configure in @LIBOBJS@ @ALLOCA@
45EXTRA_SOURCES_C = \
46	Rmain.c alloca.c mkdtemp.c strdup.c strncasecmp.c
47
48DEPENDS = $(SOURCES_C:.c=.d) $(EXTRA_SOURCES_C:.c=.d)
49SOURCES = $(SOURCES_C) $(SOURCES_F)
50OBJECTS = $(SOURCES_C:.c=.o) $(SOURCES_F:.f=.o) @LIBOBJS@ @ALLOCA@
51HEADERS = \
52	RBufferUtils.h Rcomplex.h Rstrptime.h \
53	arithmetic.h \
54	basedecl.h \
55	contour-common.h \
56	datetime.h \
57	duplicate.h \
58	gzio.h \
59	machar.c \
60	qsort-body.c \
61	rlocale_data.h rlocale_tolower.h rlocale_toupper.h rlocale_widths.h \
62	split-incl.c \
63	unzip.h \
64	valid_utf8.h \
65	xspline.c \
66	g_cntrlify.h g_control.h g_extern.h g_her_metr.h g_jis.h
67
68
69distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
70DISTFILES = Makefile.in Makefile.win \
71	$(HEADERS) \
72	$(SOURCES_C) \
73	$(EXTRA_SOURCES_C) \
74	$(SOURCES_F) \
75	gram.y
76
77TRE_CPPFLAGS = @BUILD_TRE_TRUE@ -I$(top_srcdir)/src/extra
78XDR_CPPFLAGS = @BUILD_XDR_TRUE@ -I$(top_srcdir)/src/extra/xdr
79@BUILD_XDR_FALSE@XDR_CPPFLAGS = @TIRPC_CPPFLAGS@
80
81## platform.c needs $(CURL_CPPFLAGS).
82ALL_CPPFLAGS = $(TRE_CPPFLAGS) $(XDR_CPPFLAGS) $(R_XTRA_CPPFLAGS) \
83  $(CURL_CPPFLAGS) $(CPPFLAGS) -I$(top_srcdir)/src/nmath $(DEFS)
84@WANT_R_SHLIB_TRUE@ALL_CFLAGS = $(ALL_CFLAGS_LO)
85@WANT_R_SHLIB_TRUE@ALL_FFLAGS = $(ALL_FFLAGS_LO)
86
87
88## use an explicit library: there might be an unsatisfactory -lintl around
89R_TRE = @BUILD_TRE_TRUE@ ../extra/tre/libtre.a
90R_XDR = @BUILD_XDR_TRUE@ ../extra/xdr/libxdr.a
91R_LIBINTL = @BUILD_LIBINTL_TRUE@ ../extra/intl/libintl.a
92R_TZONE = @BUILD_TZONE_TRUE@ ../extra/tzone/libtz.a
93
94MAIN_LIBS = ../unix/libunix.a ../appl/libappl.a ../nmath/libnmath.a
95MAIN_OBJS = `ls ../unix/*.o ../appl/*.o ../nmath/*.o`
96EXTRA_STATIC_LIBS = $(R_TRE) $(R_XDR) $(R_LIBINTL) $(R_TZONE)
97STATIC_LIBS = $(MAIN_LIBS) $(EXTRA_STATIC_LIBS)
98
99EXTRA_LIBS = $(BLAS_LIBS) $(FLIBS) @R_XTRA_LIBS@ @LIBINTL@ $(READLINE_LIBS) $(LIBS)
100
101R_binary = R.bin
102R_bin_OBJECTS = Rmain.o @WANT_R_SHLIB_FALSE@$(OBJECTS)
103@WANT_R_SHLIB_FALSE@R_bin_LDADD = $(MAIN_OBJS) $(EXTRA_STATIC_LIBS) $(EXTRA_LIBS)
104## Linked against -lRblas because -lR is and otherwise ld complains.
105@WANT_R_SHLIB_TRUE@R_bin_LDADD = -lR @BLAS_SHLIB_TRUE@-lRblas
106## This should depend on MAIN_OBJS not MAIN_LIBS, but we can't use that.
107## There is also a dependence on libRblas when that is internal and static.
108@WANT_R_SHLIB_FALSE@R_bin_DEPENDENCIES = $(MAIN_LIBS) $(EXTRA_STATIC_LIBS)@USE_EXPORTFILES_TRUE@ $(top_builddir)/etc/R.exp
109
110libR_la = libR$(R_DYLIB_EXT)
111libR_la_OBJECTS = $(OBJECTS)
112libR_la_LIBADD =  $(MAIN_OBJS) $(EXTRA_STATIC_LIBS) $(EXTRA_LIBS) @WANT_R_SHLIB_TRUE@ @USE_EXPORTFILES_TRUE@ -Wl,-bE:$(top_builddir)/etc/R.exp
113libR_la_DEPENDENCIES = $(STATIC_LIBS) $(R_TZONE) @WANT_R_SHLIB_TRUE@ @USE_EXPORTFILES_TRUE@ $(top_builddir)/etc/R.exp
114
115## The next is needed for macOS only at present
116LIBR_LDFLAGS = @LIBR_LDFLAGS@
117
118
119all: R
120
121Makefile: $(srcdir)/Makefile.in \
122  $(top_builddir)/config.status \
123  ../include/config.h \
124  ../include/Rversion.h \
125  $(SOURCES_C) $(EXTRA_SOURCES_C)
126	@cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
127
128Makedeps: Makefile $(DEPENDS)
129	@cat $(DEPENDS) >> Makefile
130	@touch $@
131
132## This target has been changed to ensure that R.bin and libR get
133## installed in the build tree if necessary, even if the corresponding
134## objects are not re-made.
135## Note that dependencies in the test Makefiles used to depend on these objects,
136## so copy-if-change is used.
137R: Makedeps
138@WANT_R_SHLIB_TRUE@	@$(MAKE) install-lib-local
139@WANT_R_STATIC_TRUE@	@$(MAKE) install-static-local
140	@$(MAKE) install-bin-local
141
142
143## is this portable?  Documented as GNU extension.
144../include/config.h ../include/Rversion.h:
145	(cd $(@D); $(MAKE) $(@F))
146
147$(R_binary): $(R_bin_OBJECTS) $(R_bin_DEPENDENCIES)
148	$(MAIN_LINK) -o $@ $(R_bin_OBJECTS) $(R_bin_LDADD)
149
150libR.a: $(OBJECTS) $(STATIC_LIBS)
151	-@mkdir libs
152	@(cd libs; for l in $(STATIC_LIBS); do $(AR) -x ../$$l; done)
153	@rm -Rf $@
154	$(AR) -cr $@ $(OBJECTS) libs/*o
155	$(RANLIB) $@
156	@rm -Rf libs
157
158install-bin-local: $(R_binary)
159	@$(MAKE) rhome="$(abs_top_builddir)" install-bin
160
161install-static-local: libR.a
162	@$(MAKE) rhome="$(abs_top_builddir)" install-static
163
164$(top_builddir)/etc/R.exp: $(OBJECTS) $(MAIN_LIBS)
165	@$(SHELL) $(top_srcdir)/tools/ldAIX4 -o $@ $(OBJECTS) $(MAIN_LIBS)
166
167## is this portable?  Documented as GNU extension.
168$(MAIN_LIBS):
169	(cd $(@D); $(MAKE) $(@F))
170
171../extra/bzip2/libbz2.a ../extra/pcre/libpcre.a ../extra/pcre/libtre.a\
172  ../extra/xdr/libxdr.a ../extra/zlib/libz.a ../extra/xz/liblzma.a \
173  ../extra/intl/libintl.a:
174	(cd $(@D); $(MAKE))
175
176
177libR: $(libR_la)
178
179$(libR_la): $(libR_la_OBJECTS) $(libR_la_DEPENDENCIES)
180	$(DYLIB_LINK) $(LIBR_LDFLAGS) -o $@ $(libR_la_OBJECTS) $(libR_la_LIBADD)
181
182install-lib-local: $(libR_la)
183	@$(MAKE) rhome="$(abs_top_builddir)" install-lib
184
185
186# suppress #line directives
187YFLAGS=-l
188
189$(srcdir)/gram.c: @MAINTAINER_MODE_TRUE@ $(srcdir)/gram.y
190	@$(ECHO) "re-making gram.c"
191	$(YACC) $(YFLAGS) $(srcdir)/gram.y
192	$(SHELL) $(top_srcdir)/tools/move-if-change y.tab.c $(srcdir)/gram.c
193
194install: installdirs
195	@$(MAKE) install-bin
196	@if test -f $(libR_la); then $(MAKE) install-lib; fi
197@WANT_R_STATIC_TRUE@	@$(MAKE) install-static
198## may not need $(rhome)/lib if not static/shared libR, external blas and lapack.
199installdirs:
200	@$(MKINSTALLDIRS) "$(DESTDIR)$(Rexecbindir2)"
201install-bin: installdirs
202	@$(SHELL) $(top_srcdir)/tools/copy-if-change $(R_binary) "$(DESTDIR)$(Rexecbindir2)/R"
203install-lib: installdirs
204	@$(MKINSTALLDIRS) "$(DESTDIR)$(Rexeclibdir)"
205	@$(SHELL) $(top_srcdir)/tools/copy-if-change $(libR_la) "$(DESTDIR)$(Rexeclibdir)/$(libR_la)"
206install-static: installdirs
207	@$(MKINSTALLDIRS) "$(DESTDIR)$(Rexeclibdir)"
208	@$(SHELL) $(top_srcdir)/tools/copy-if-change libR.a "$(DESTDIR)$(Rexeclibdir)/libR.a"
209install-strip: installdirs
210	@${INSTALL_PROGRAM} -s $(R_binary) "$(DESTDIR)$(Rexecbindir2)/R"
211	@if test -f $(libR_la); then $(MAKE) install-lib; fi
212	@if test -n "$(STRIP_SHARED_LIB)"; then \
213	  if test -f $(libR_la); then $(STRIP_SHARED_LIB) "$(DESTDIR)$(Rexeclibdir)/$(libR_la)"; fi; \
214	fi
215@WANT_R_STATIC_TRUE@	@$(MAKE) install-strip-static
216install-strip-static: installdirs
217	@$(MAKE) install-static
218	@if test -n "$(STRIP_STATIC_LIB)"; then \
219	  if test -f libR.a; then $(STRIP_STATIC_LIB) "$(DESTDIR)$(Rexeclibdir)/libR.a"; fi; \
220	fi
221uninstall:
222	@rm -f "$(DESTDIR)$(Rexecbindir)/exec/$(R_ARCH)/R" "$(DESTDIR)$(Rexecbindir)/R.bin"
223	@rm -f "$(DESTDIR)$(Rexeclibdir)/libR$(R_DYLIB_EXT)"
224	@rm -f "$(DESTDIR)$(Rexeclibdir)/libR.a"
225
226mostlyclean: clean
227clean:
228	@-rm -f $(top_builddir)/etc/R.exp
229	@-rm -Rf .libs _libs
230	@-rm -f *core Makedeps *.d *.o *.lo *.la *$(R_DYLIB_EXT) \
231	  $(R_binary) libR.a
232distclean: clean
233	@-rm -f Makefile
234maintainer-clean: distclean
235	@$(ECHO) "This command is intended for maintainers to use; it"
236	@$(ECHO) "deletes files that may need special rules to rebuild"
237	@-rm -f $(srcdir)/gram.c $(srcdir)/gramLatex.c $(srcdir)/gramRd.c
238
239tags: TAGS
240TAGS: $(SOURCES) $(EXTRA_SOURCES_C) $(HEADERS)
241	etags $(SOURCES) $(EXTRA_SOURCES_C) $(HEADERS)
242
243## Unused targets
244info dvi check:
245
246distdir: $(DISTFILES)
247	@for f in $(DISTFILES); do \
248	  test -f $(distdir)/$${f} \
249	    || ln $(srcdir)/$${f} $(distdir)/$${f} 2>/dev/null \
250	    || cp -p $(srcdir)/$${f} $(distdir)/$${f}; \
251	done
252
253## Automagically generated dependencies:
254
255