1## Process this file with automake to generate Makefile.in
2#
3#  Copyright (C) 2006-2022 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
28# This is where we get zlib from.  zlibdir is -L../zlib and zlibinc is
29# -I../zlib, unless we were configured with --with-system-zlib, in which
30# case both are empty.
31ZLIB = @zlibdir@ -lz
32ZLIBINC = @zlibinc@
33
34THREADFLAGS = @PTHREAD_CFLAGS@
35THREADLIBS = @PTHREAD_LIBS@
36
37AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS) $(ZLIBINC) $(THREADFLAGS)
38AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS) $(ZLIBINC) $(THREADFLAGS)
39AM_LDFLAGS = $(THREADFLAGS)
40
41AM_CPPFLAGS = \
42	-I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../elfcpp \
43	-DLOCALEDIR="\"$(datadir)/locale\"" \
44	-DBINDIR="\"$(bindir)\"" -DTOOLBINDIR="\"$(tooldir)/bin\"" \
45	-DTOOLLIBDIR="\"$(tooldir)/lib\"" @INCINTL@
46
47LIBIBERTY = ../libiberty/libiberty.a
48
49if PLUGINS
50LIBDL = @DLOPEN_LIBS@
51endif
52
53AM_YFLAGS = -d
54
55# Automake 1.10+ disables lex and yacc output file regeneration if
56# maintainer mode is disabled.  Avoid this.
57am__skiplex =
58am__skipyacc =
59
60bin_PROGRAMS = dwp
61
62noinst_PROGRAMS = ld-new incremental-dump
63noinst_LIBRARIES = libgold.a
64
65CCFILES = \
66	archive.cc \
67	attributes.cc \
68	binary.cc \
69	common.cc \
70	compressed_output.cc \
71	copy-relocs.cc \
72	cref.cc \
73	defstd.cc \
74	descriptors.cc \
75	dirsearch.cc \
76	dynobj.cc \
77	dwarf_reader.cc \
78	ehframe.cc \
79	errors.cc \
80	expression.cc \
81	fileread.cc \
82        gc.cc \
83        gdb-index.cc \
84	gold.cc \
85	gold-threads.cc \
86	icf.cc \
87	incremental.cc \
88	int_encoding.cc \
89	layout.cc \
90	mapfile.cc \
91	merge.cc \
92	nacl.cc \
93	object.cc \
94	options.cc \
95	output.cc \
96	parameters.cc \
97	plugin.cc \
98	readsyms.cc \
99	reduced_debug_output.cc \
100	reloc.cc \
101	resolve.cc \
102	script-sections.cc \
103	script.cc \
104	stringpool.cc \
105	symtab.cc \
106	target.cc \
107	target-select.cc \
108	timer.cc \
109	version.cc \
110	workqueue.cc \
111	workqueue-threads.cc
112
113HFILES = \
114	arm-reloc-property.h \
115	aarch64-reloc-property.h \
116	archive.h \
117	attributes.h \
118	binary.h \
119	common.h \
120	compressed_output.h \
121	copy-relocs.h \
122	cref.h \
123	defstd.h \
124	dirsearch.h \
125	descriptors.h \
126	dynobj.h \
127	dwarf_reader.h \
128	ehframe.h \
129	errors.h \
130	fileread.h \
131	freebsd.h \
132        gc.h \
133        gdb-index.h \
134	gold.h \
135	gold-threads.h \
136	icf.h \
137	int_encoding.h \
138	layout.h \
139	mapfile.h \
140	merge.h \
141	nacl.h \
142	object.h \
143	options.h \
144	output.h \
145	parameters.h \
146	plugin.h \
147	readsyms.h \
148	reduced_debug_output.h \
149	reloc.h \
150	reloc-types.h \
151	script-c.h \
152	script-sections.h \
153	script.h \
154	stringpool.h \
155	symtab.h \
156	target.h \
157	target-reloc.h \
158	target-select.h \
159	timer.h \
160	tls.h \
161	token.h \
162	workqueue.h \
163	workqueue-internal.h
164
165YFILES = \
166	yyscript.y
167
168DEFFILES = arm-reloc.def aarch64-reloc.def
169
170EXTRA_DIST = yyscript.c yyscript.h
171
172diststuff: $(EXTRA_DIST)
173
174TARGETSOURCES = \
175	i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc \
176	mips.cc aarch64.cc aarch64-reloc-property.cc s390.cc
177
178ALL_TARGETOBJS = \
179	i386.$(OBJEXT) x86_64.$(OBJEXT) sparc.$(OBJEXT) powerpc.$(OBJEXT) \
180	arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT) \
181	mips.$(OBJEXT) aarch64.$(OBJEXT) aarch64-reloc-property.$(OBJEXT) \
182	s390.$(OBJEXT)
183
184libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES) $(DEFFILES)
185libgold_a_LIBADD = $(LIBOBJS)
186
187sources_var = main.cc
188deps_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL_DEP)
189ldadd_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) \
190	 $(THREADLIBS) $(LIBDL) $(ZLIB)
191ldflags_var = $(GOLD_LDFLAGS)
192
193ld_new_SOURCES = $(sources_var)
194ld_new_DEPENDENCIES = $(deps_var)
195ld_new_LDADD = $(ldadd_var)
196ld_new_LDFLAGS = $(ldflags_var)
197
198EXTRA_ld_new_SOURCES = $(TARGETSOURCES)
199
200incremental_dump_SOURCES = incremental-dump.cc
201incremental_dump_DEPENDENCIES = $(TARGETOBJS) libgold.a $(LIBIBERTY) \
202	$(LIBINTL_DEP)
203incremental_dump_LDADD = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) \
204	 $(THREADLIBS) $(LIBDL) $(ZLIB)
205
206dwp_SOURCES = dwp.cc
207dwp_DEPENDENCIES = libgold.a $(LIBIBERTY) $(LIBINTL_DEP)
208dwp_LDADD = libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) $(THREADLIBS) \
209	$(LIBDL) $(ZLIB)
210dwp_LDFLAGS = $(GOLD_LDFLAGS)
211
212CONFIG_STATUS_DEPENDENCIES = $(srcdir)/../bfd/development.sh
213
214# Use an explicit dependency for the bison generated header file.
215expression.$(OBJEXT): yyscript.h
216script-sections.$(OBJEXT): yyscript.h
217script.$(OBJEXT): yyscript.h
218
219# We have to build libgold.a before we run the tests.
220check: libgold.a
221
222.PHONY: install-exec-local
223
224install-exec-local: ld-new$(EXEEXT)
225	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(tooldir)/bin
226	n=`echo $(installed_linker) | sed '$(transform)'`; \
227	$(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) \
228	  ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${n}$(EXEEXT); \
229	if test "$(bindir)" != "$(tooldir)/bin"; then \
230	  rm -f $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT); \
231	  ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT) >/dev/null 2>/dev/null \
232	  || $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT); \
233	fi; \
234	if test "x$(install_as_default)" = "xyes"; then \
235	  ld=`echo ld | sed '$(transform)'`; \
236	  rm -f $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \
237	  ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT) >/dev/null 2>/dev/null \
238	  || $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \
239	  if test "$(bindir)" != "$(tooldir)/bin"; then \
240	    rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
241	    ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
242	    || $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
243	  fi; \
244	fi
245
246POTFILES= $(CCFILES) $(HFILES) $(TARGETSOURCES)
247
248po/POTFILES.in: @MAINT@ Makefile
249	for f in $(POTFILES); do echo $$f; done | LC_ALL=C sort > tmp \
250	  && mv tmp $(srcdir)/po/POTFILES.in
251
252# Bootstrap test support.  We use ld-new to build ld1, then use ld1 to
253# build ld2.  ld1 and ld2 should be identical.  ld-new need not be
254# identical to ld1, since it was linked with the host linker.
255
256if GCC
257if NATIVE_LINKER
258
259gcctestdir1/ld gcctestdir1/collect-ld: ld-new
260	test -d gcctestdir1 || mkdir -p gcctestdir1
261	rm -f $@
262	$(LN_S) $(abs_top_builddir)/ld-new $@
263
264ld1_SOURCES = $(sources_var)
265ld1_DEPENDENCIES = $(deps_var) gcctestdir1/ld gcctestdir1/collect-ld
266ld1_LDADD = $(ldadd_var)
267editcc1 = -e 's/\([^ ]*\)\(.*\)/\1 -Bgcctestdir1\/\2/'
268ld1_LINK = `echo $(CXXLD) | sed $(editcc1)`\
269	$(AM_CXXFLAGS) $(CXXFLAGS) $(ld1_LDFLAGS) $(LDFLAGS) -o $@
270
271gcctestdir2/ld gcctestdir2/collect-ld: ld1
272	test -d gcctestdir2 || mkdir -p gcctestdir2
273	rm -f $@
274	$(LN_S) $(abs_top_builddir)/ld1 $@
275
276ld2_SOURCES = $(sources_var)
277ld2_DEPENDENCIES = $(deps_var) gcctestdir2/ld gcctestdir2/collect-ld
278ld2_LDADD = $(ldadd_var)
279editcc2 = -e 's/\([^ ]*\)\(.*\)/\1 -Bgcctestdir2\/\2/'
280ld2_LINK = `echo $(CXXLD) | sed $(editcc2)`\
281	$(AM_CXXFLAGS) $(CXXFLAGS) $(ld2_LDFLAGS) $(LDFLAGS) -o $@
282
283TEST_READELF = $(top_builddir)/../binutils/readelf
284
285# Skip this for LTO build due to different build IDs.
286bootstrap-test: ld2
287	rm -f $@
288	echo "#!/bin/sh" > $@
289	if $(TEST_READELF) -SW main.$(OBJEXT) | grep "gnu.lto" > /dev/null; then \
290	  echo true >> $@; \
291	else \
292	  echo "cmp ld1 ld2" >> $@; \
293	fi
294	chmod +x $@
295
296libgold-1-r.o: gcctestdir1/ld libgold.a
297	gcctestdir1/ld -o $@ -r --whole-archive libgold.a
298
299ld1_r_SOURCES = $(sources_var)
300ld1_r_DEPENDENCIES = libgold-1-r.o $(deps_var) gcctestdir1/ld gcctestdir1/collect-ld
301ld1_r_LDADD = libgold-1-r.o $(ldadd_var)
302ld1_r_LINK = `echo $(CXXLD) | sed $(editcc1)`\
303	$(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
304
305gcctestdir2-r/ld gcctestdir2-r/collect-ld: ld1-r
306	test -d gcctestdir2-r || mkdir -p gcctestdir2-r
307	rm -f $@
308	$(LN_S) $(abs_top_builddir)/ld1-r $@
309
310libgold-2-r.o: gcctestdir2-r/ld libgold.a
311	gcctestdir2-r/ld -o $@ -r --whole-archive libgold.a
312
313ld2_r_SOURCES = $(sources_var)
314ld2_r_DEPENDENCIES = libgold-2-r.o $(deps_var) gcctestdir2-r/ld gcctestdir2-r/collect-ld
315ld2_r_LDADD = libgold-2-r.o $(ldadd_var)
316editcc2r = -e 's/\([^ ]*\)\(.*\)/\1 -Bgcctestdir2-r\/\2/'
317ld2_r_LINK = `echo $(CXXLD) | sed $(editcc2r)`\
318	$(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
319
320# Skip this for LTO build due to different build IDs.
321bootstrap-test-r: ld2-r
322	rm -f $@
323	echo "#!/bin/sh" > $@
324	if $(TEST_READELF) -SW main.$(OBJEXT) | grep "gnu.lto" > /dev/null; then \
325	  echo true >> $@; \
326	else \
327	  echo "cmp ld1-r ld2-r" >> $@; \
328	fi
329	chmod +x $@
330
331check_PROGRAMS = ld1 ld2 ld1-r ld2-r
332TESTS = bootstrap-test bootstrap-test-r
333MOSTLYCLEANFILES = bootstrap-test bootstrap-test-r
334
335# Verify that changing the number of threads doesn't change the
336# treehash computation, by building ld1 and ld3 the same way except
337# for the number of threads.  However, the build ID should change if
338# we change the chunk size for --build-id=tree, so ld4 should be
339# different.  We run the latter test even if multithreading is unavailable,
340# because the treehash can still operate in that mode.
341check_PROGRAMS += ld4
342TESTS += bootstrap-test-treehash-chunksize
343MOSTLYCLEANFILES += bootstrap-test-treehash-chunksize
344
345gcctestdir3/ld gcctestdir3/collect-ld: ld-new
346	test -d gcctestdir3 || mkdir -p gcctestdir3
347	rm -f $@
348	$(LN_S) $(abs_top_builddir)/ld-new $@
349
350ld3_SOURCES = $(sources_var)
351ld3_DEPENDENCIES = $(deps_var) gcctestdir3/ld gcctestdir3/collect-ld
352ld3_LDADD = $(ldadd_var)
353editcc3 = -e 's/\([^ ]*\)\(.*\)/\1 -Bgcctestdir3\/\2/'
354ld3_LINK = `echo $(CXXLD) | sed $(editcc3)`\
355	$(AM_CXXFLAGS) $(CXXFLAGS) $(ld3_LDFLAGS) $(LDFLAGS) -o $@
356
357gcctestdir4/ld gcctestdir4/collect-ld: ld-new
358	test -d gcctestdir4 || mkdir -p gcctestdir4
359	rm -f $@
360	$(LN_S) $(abs_top_builddir)/ld-new $@
361
362ld4_SOURCES = $(sources_var)
363ld4_DEPENDENCIES = $(deps_var) gcctestdir4/ld gcctestdir4/collect-ld
364ld4_LDADD = $(ldadd_var)
365editcc4 = -e 's/\([^ ]*\)\(.*\)/\1 -Bgcctestdir4\/\2/'
366ld4_LINK = `echo $(CXXLD) | sed $(editcc4)`\
367	$(AM_CXXFLAGS) $(CXXFLAGS) $(ld4_LDFLAGS) $(LDFLAGS) -o $@
368
369ld1_LDFLAGS = -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12345 -Wl,--build-id-min-file-size-for-treehash=0
370ld2_LDFLAGS = -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12345 -Wl,--build-id-min-file-size-for-treehash=0
371ld3_LDFLAGS = -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12345 -Wl,--build-id-min-file-size-for-treehash=0
372ld4_LDFLAGS = -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12346 -Wl,--build-id-min-file-size-for-treehash=0
373
374if THREADS
375
376ld1_LDFLAGS += -Wl,--thread-count=3
377ld2_LDFLAGS += -Wl,--thread-count=3
378ld3_LDFLAGS += -Wl,--thread-count=13
379ld4_LDFLAGS += -Wl,--thread-count=3
380check_PROGRAMS += ld3
381TESTS += bootstrap-test-treehash-chunksize
382MOSTLYCLEANFILES += bootstrap-test-treehash-chunksize
383
384bootstrap-test-treehash: ld1 ld3
385	rm -f $@
386	echo "#!/bin/sh" > $@
387	echo "cmp ld1 ld3" >> $@
388	chmod +x $@
389
390endif
391
392bootstrap-test-treehash-chunksize: ld1 ld4
393	rm -f $@
394	echo "#!/bin/sh" > $@
395	echo "cmp ld1 ld4 | grep ." >> $@
396	chmod +x $@
397
398endif
399endif
400