1## Process this file with automake to generate Makefile.in
2#
3#  Copyright (C) 2006-2014 Free Software Foundation, Inc.
4#
5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; see the file COPYING3.  If not see
17# <http://www.gnu.org/licenses/>.
18#
19
20AUTOMAKE_OPTIONS = foreign
21
22SUBDIRS = po testsuite
23
24tooldir = $(exec_prefix)/$(target_alias)
25
26ACLOCAL_AMFLAGS = -I ../bfd -I ../config
27
28AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS)
29AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS)
30
31AM_CPPFLAGS = \
32	-I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../elfcpp \
33	-DLOCALEDIR="\"$(datadir)/locale\"" \
34	-DBINDIR="\"$(bindir)\"" -DTOOLBINDIR="\"$(tooldir)/bin\"" \
35	-DTOOLLIBDIR="\"$(tooldir)/lib\"" @INCINTL@
36
37LIBIBERTY = ../libiberty/libiberty.a
38
39if PLUGINS
40LIBDL = @DLOPEN_LIBS@
41endif
42
43if THREADS
44THREADSLIB = -lpthread
45endif
46
47AM_YFLAGS = -d
48
49# Automake 1.10+ disables lex and yacc output file regeneration if
50# maintainer mode is disabled.  Avoid this.
51am__skiplex =
52am__skipyacc =
53
54bin_PROGRAMS = dwp
55
56noinst_PROGRAMS = ld-new incremental-dump
57noinst_LIBRARIES = libgold.a
58
59CCFILES = \
60	archive.cc \
61	attributes.cc \
62	binary.cc \
63	common.cc \
64	compressed_output.cc \
65	copy-relocs.cc \
66	cref.cc \
67	defstd.cc \
68	descriptors.cc \
69	dirsearch.cc \
70	dynobj.cc \
71	dwarf_reader.cc \
72	ehframe.cc \
73	errors.cc \
74	expression.cc \
75	fileread.cc \
76        gc.cc \
77        gdb-index.cc \
78	gold.cc \
79	gold-threads.cc \
80	icf.cc \
81	incremental.cc \
82	int_encoding.cc \
83	layout.cc \
84	mapfile.cc \
85	merge.cc \
86	nacl.cc \
87	object.cc \
88	options.cc \
89	output.cc \
90	parameters.cc \
91	plugin.cc \
92	readsyms.cc \
93	reduced_debug_output.cc \
94	reloc.cc \
95	resolve.cc \
96	script-sections.cc \
97	script.cc \
98	stringpool.cc \
99	symtab.cc \
100	target.cc \
101	target-select.cc \
102	timer.cc \
103	version.cc \
104	workqueue.cc \
105	workqueue-threads.cc
106
107HFILES = \
108	arm-reloc-property.h \
109	aarch64-reloc-property.h \
110	archive.h \
111	attributes.h \
112	binary.h \
113	common.h \
114	compressed_output.h \
115	copy-relocs.h \
116	cref.h \
117	defstd.h \
118	dirsearch.h \
119	descriptors.h \
120	dynobj.h \
121	dwarf_reader.h \
122	ehframe.h \
123	errors.h \
124	fileread.h \
125	freebsd.h \
126        gc.h \
127        gdb-index.h \
128	gold.h \
129	gold-threads.h \
130	icf.h \
131	int_encoding.h \
132	layout.h \
133	mapfile.h \
134	merge.h \
135	nacl.h \
136	object.h \
137	options.h \
138	output.h \
139	parameters.h \
140	plugin.h \
141	readsyms.h \
142	reduced_debug_output.h \
143	reloc.h \
144	reloc-types.h \
145	script-c.h \
146	script-sections.h \
147	script.h \
148	stringpool.h \
149	symtab.h \
150	target.h \
151	target-reloc.h \
152	target-select.h \
153	timer.h \
154	tls.h \
155	token.h \
156	workqueue.h \
157	workqueue-internal.h
158
159YFILES = \
160	yyscript.y
161
162DEFFILES = arm-reloc.def aarch64-reloc.def
163
164EXTRA_DIST = yyscript.c yyscript.h
165
166TARGETSOURCES = \
167	i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc \
168	mips.cc aarch64.cc aarch64-reloc-property.cc
169
170ALL_TARGETOBJS = \
171	i386.$(OBJEXT) x86_64.$(OBJEXT) sparc.$(OBJEXT) powerpc.$(OBJEXT) \
172	arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT) \
173	mips.$(OBJEXT) aarch64.$(OBJEXT) aarch64-reloc-property.$(OBJEXT)
174
175libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES) $(DEFFILES)
176libgold_a_LIBADD = $(LIBOBJS)
177
178sources_var = main.cc
179deps_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL_DEP)
180ldadd_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) \
181	 $(THREADSLIB) $(LIBDL)
182ldflags_var = $(GOLD_LDFLAGS)
183
184ld_new_SOURCES = $(sources_var)
185ld_new_DEPENDENCIES = $(deps_var)
186ld_new_LDADD = $(ldadd_var)
187ld_new_LDFLAGS = $(ldflags_var)
188
189EXTRA_ld_new_SOURCES = $(TARGETSOURCES)
190
191incremental_dump_SOURCES = incremental-dump.cc
192incremental_dump_DEPENDENCIES = $(TARGETOBJS) libgold.a $(LIBIBERTY) \
193	$(LIBINTL_DEP)
194incremental_dump_LDADD = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) \
195	 $(THREADSLIB) $(LIBDL)
196
197dwp_SOURCES = dwp.cc
198dwp_DEPENDENCIES = libgold.a $(LIBIBERTY) $(LIBINTL_DEP)
199dwp_LDADD = libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) $(THREADSLIB) \
200	$(LIBDL)
201dwp_LDFLAGS = $(GOLD_LDFLAGS)
202
203CONFIG_STATUS_DEPENDENCIES = $(srcdir)/../bfd/development.sh
204
205# Use an explicit dependency for the bison generated header file.
206expression.$(OBJEXT): yyscript.h
207script-sections.$(OBJEXT): yyscript.h
208script.$(OBJEXT): yyscript.h
209
210# We have to build libgold.a before we run the tests.
211check: libgold.a
212
213.PHONY: install-exec-local
214
215install-exec-local: ld-new$(EXEEXT)
216	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(tooldir)/bin
217	n=`echo $(installed_linker) | sed '$(transform)'`; \
218	$(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) \
219	  ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${n}$(EXEEXT); \
220	if test "$(bindir)" != "$(tooldir)/bin"; then \
221	  rm -f $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT); \
222	  ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT) >/dev/null 2>/dev/null \
223	  || $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT); \
224	fi; \
225	if test "x$(install_as_default)" = "xyes"; then \
226	  ld=`echo ld | sed '$(transform)'`; \
227	  rm -f $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \
228	  ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT) >/dev/null 2>/dev/null \
229	  || $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \
230	  if test "$(bindir)" != "$(tooldir)/bin"; then \
231	    rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
232	    ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
233	    || $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
234	  fi; \
235	fi
236
237# We want install to imply install-info as per GNU standards, despite
238# the cygnus option.
239install-data-local: install-info
240
241POTFILES= $(CCFILES) $(HFILES) $(TARGETSOURCES)
242
243po/POTFILES.in: @MAINT@ Makefile
244	for f in $(POTFILES); do echo $$f; done | LC_ALL=C sort > tmp \
245	  && mv tmp $(srcdir)/po/POTFILES.in
246
247# Bootstrap test support.  We use ld-new to build ld1, then use ld1 to
248# build ld2.  ld1 and ld2 should be identical.  ld-new need not be
249# identical to ld1, since it was linked with the host linker.
250
251if GCC
252if TEST_AS_NATIVE_LINKER
253
254gcctestdir1/ld: ld-new
255	test -d gcctestdir1 || mkdir -p gcctestdir1
256	rm -f gcctestdir1/ld
257	(cd gcctestdir1 && $(LN_S) ../ld-new ld)
258
259ld1_SOURCES = $(sources_var)
260ld1_DEPENDENCIES = $(deps_var) gcctestdir1/ld
261ld1_LDADD = $(ldadd_var)
262ld1_LDFLAGS = -Bgcctestdir1/
263
264gcctestdir2/ld: ld1
265	test -d gcctestdir2 || mkdir -p gcctestdir2
266	rm -f gcctestdir2/ld
267	(cd gcctestdir2 && $(LN_S) ../ld1 ld)
268
269ld2_SOURCES = $(sources_var)
270ld2_DEPENDENCIES = $(deps_var) gcctestdir2/ld
271ld2_LDADD = $(ldadd_var)
272ld2_LDFLAGS = -Bgcctestdir2/
273
274bootstrap-test: ld2
275	rm -f $@
276	echo "#!/bin/sh" > $@
277	echo "cmp ld1 ld2" >> $@
278	chmod +x $@
279
280libgold-1-r.o: gcctestdir1/ld libgold.a
281	gcctestdir1/ld -o $@ -r --whole-archive libgold.a
282
283ld1_r_SOURCES = $(sources_var)
284ld1_r_DEPENDENCIES = libgold-1-r.o $(deps_var) gcctestdir1/ld
285ld1_r_LDADD = libgold-1-r.o $(ldadd_var)
286ld1_r_LDFLAGS = -Bgcctestdir1/
287
288gcctestdir2-r/ld: ld1-r
289	test -d gcctestdir2-r || mkdir -p gcctestdir2-r
290	rm -f gcctestdir2-r/ld
291	(cd gcctestdir2-r && $(LN_S) ../ld1-r ld)
292
293libgold-2-r.o: gcctestdir2-r/ld libgold.a
294	gcctestdir2-r/ld -o $@ -r --whole-archive libgold.a
295
296ld2_r_SOURCES = $(sources_var)
297ld2_r_DEPENDENCIES = libgold-2-r.o $(deps_var) gcctestdir2-r/ld
298ld2_r_LDADD = libgold-2-r.o $(ldadd_var)
299ld2_r_LDFLAGS = -Bgcctestdir2-r/
300
301bootstrap-test-r: ld2-r
302	rm -f $@
303	echo "#!/bin/sh" > $@
304	echo "cmp ld1-r ld2-r" >> $@
305	chmod +x $@
306
307check_PROGRAMS = ld1 ld2 ld1-r ld2-r
308TESTS = bootstrap-test bootstrap-test-r
309
310# Verify that changing the number of threads doesn't change the
311# treehash computation, by building ld1 and ld3 the same way except
312# for the number of threads.  However, the build ID should change if
313# we change the chunk size for --build-id=tree, so ld4 should be
314# different.  We run the latter test even if multithreading is unavailable,
315# because the treehash can still operate in that mode.
316check_PROGRAMS += ld4
317TESTS += bootstrap-test-treehash-chunksize
318
319gcctestdir3/ld: ld-new
320	test -d gcctestdir3 || mkdir -p gcctestdir3
321	rm -f gcctestdir3/ld
322	(cd gcctestdir3 && $(LN_S) ../ld-new ld)
323
324ld3_SOURCES = $(sources_var)
325ld3_DEPENDENCIES = $(deps_var) gcctestdir3/ld
326ld3_LDADD = $(ldadd_var)
327ld3_LDFLAGS = -Bgcctestdir3/
328
329gcctestdir4/ld: ld-new
330	test -d gcctestdir4 || mkdir -p gcctestdir4
331	rm -f gcctestdir4/ld
332	(cd gcctestdir4 && $(LN_S) ../ld-new ld)
333
334ld4_SOURCES = $(sources_var)
335ld4_DEPENDENCIES = $(deps_var) gcctestdir4/ld
336ld4_LDADD = $(ldadd_var)
337ld4_LDFLAGS = -Bgcctestdir4/
338
339ld1_LDFLAGS += -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12345 -Wl,--build-id-min-file-size-for-treehash=0
340ld2_LDFLAGS += -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12345 -Wl,--build-id-min-file-size-for-treehash=0
341ld3_LDFLAGS += -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12345 -Wl,--build-id-min-file-size-for-treehash=0
342ld4_LDFLAGS += -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12346 -Wl,--build-id-min-file-size-for-treehash=0
343
344if THREADS
345
346ld1_LDFLAGS += -Wl,--thread-count=3
347ld2_LDFLAGS += -Wl,--thread-count=3
348ld3_LDFLAGS += -Wl,--thread-count=13
349ld4_LDFLAGS += -Wl,--thread-count=3
350check_PROGRAMS += ld3
351TESTS += bootstrap-test-treehash-chunksize
352
353bootstrap-test-treehash: ld1 ld3
354	rm -f $@
355	echo "#!/bin/sh" > $@
356	echo "cmp ld1 ld3" >> $@
357	chmod +x $@
358
359endif
360
361bootstrap-test-treehash-chunksize: ld1 ld4
362	rm -f $@
363	echo "#!/bin/sh" > $@
364	echo "cmp ld1 ld4 | grep ." >> $@
365	chmod +x $@
366
367endif
368endif
369