1 ## Process this file with automake to generate Makefile.in
3 # Copyright (C) 2006-2023 Free Software Foundation, Inc.
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.
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.
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/>.
20 AUTOMAKE_OPTIONS = foreign
22 SUBDIRS = po testsuite
24 tooldir = $(exec_prefix)/$(target_alias)
26 ACLOCAL_AMFLAGS = -I ../bfd -I ../config
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.
34 THREADFLAGS = @PTHREAD_CFLAGS@
35 THREADLIBS = @PTHREAD_LIBS@
37 AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS) $(ZLIBINC) $(ZSTD_CFLAGS) $(THREADFLAGS)
38 AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS) $(ZLIBINC) $(ZSTD_CFLAGS) $(THREADFLAGS) $(JANSSON_CFLAGS)
39 AM_LDFLAGS = $(THREADFLAGS)
42 -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../elfcpp \
43 -DLOCALEDIR="\"$(datadir)/locale\"" \
44 -DBINDIR="\"$(bindir)\"" -DTOOLBINDIR="\"$(tooldir)/bin\"" \
45 -DTOOLLIBDIR="\"$(tooldir)/lib\"" @INCINTL@
47 LIBIBERTY = ../libiberty/libiberty.a
55 # Automake 1.10+ disables lex and yacc output file regeneration if
56 # maintainer mode is disabled. Avoid this.
62 noinst_PROGRAMS = ld-new incremental-dump
63 noinst_LIBRARIES = libgold.a
70 compressed_output.cc \
99 reduced_debug_output.cc \
114 arm-reloc-property.h \
115 aarch64-reloc-property.h \
120 compressed_output.h \
148 reduced_debug_output.h \
168 DEFFILES = arm-reloc.def aarch64-reloc.def
170 EXTRA_DIST = yyscript.c yyscript.h
172 diststuff: $(EXTRA_DIST)
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
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) \
184 libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES) $(DEFFILES)
185 libgold_a_LIBADD = $(LIBOBJS)
187 sources_var = main.cc
188 deps_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL_DEP)
189 ldadd_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) \
190 $(THREADLIBS) $(LIBDL) $(ZLIB) $(ZSTD_LIBS) $(JANSSON_LIBS)
191 ldflags_var = $(GOLD_LDFLAGS)
193 ld_new_SOURCES = $(sources_var)
194 ld_new_DEPENDENCIES = $(deps_var)
195 ld_new_LDADD = $(ldadd_var)
196 ld_new_LDFLAGS = $(ldflags_var)
198 EXTRA_ld_new_SOURCES = $(TARGETSOURCES)
200 incremental_dump_SOURCES = incremental-dump.cc
201 incremental_dump_DEPENDENCIES = $(TARGETOBJS) libgold.a $(LIBIBERTY) \
203 incremental_dump_LDADD = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) \
204 $(THREADLIBS) $(LIBDL) $(ZLIB) $(ZSTD_LIBS) $(JANSSON_LIBS)
207 dwp_DEPENDENCIES = libgold.a $(LIBIBERTY) $(LIBINTL_DEP)
208 dwp_LDADD = libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) $(THREADLIBS) \
209 $(LIBDL) $(ZLIB) $(ZSTD_LIBS) $(JANSSON_LIBS)
210 dwp_LDFLAGS = $(GOLD_LDFLAGS)
212 CONFIG_STATUS_DEPENDENCIES = $(srcdir)/../bfd/development.sh
214 # Use an explicit dependency for the bison generated header file.
215 expression.$(OBJEXT): yyscript.h
216 script-sections.$(OBJEXT): yyscript.h
217 script.$(OBJEXT): yyscript.h
219 # We have to build libgold.a before we run the tests.
222 .PHONY: install-exec-local
224 install-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); \
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); \
246 POTFILES= $(CCFILES) $(HFILES) $(TARGETSOURCES)
248 po/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
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.
259 gcctestdir1/ld gcctestdir1/collect-ld: ld-new
260 test -d gcctestdir1 || mkdir -p gcctestdir1
262 $(LN_S) $(abs_top_builddir)/ld-new $@
264 ld1_SOURCES = $(sources_var)
265 ld1_DEPENDENCIES = $(deps_var) gcctestdir1/ld gcctestdir1/collect-ld
266 ld1_LDADD = $(ldadd_var)
267 editcc1 = -e 's/\([^ ]*\)\(.*\)/\1 -Bgcctestdir1\/\2/'
268 ld1_LINK = `echo $(CXXLD) | sed $(editcc1)`\
269 $(AM_CXXFLAGS) $(CXXFLAGS) $(ld1_LDFLAGS) $(LDFLAGS) -o $@
271 gcctestdir2/ld gcctestdir2/collect-ld: ld1
272 test -d gcctestdir2 || mkdir -p gcctestdir2
274 $(LN_S) $(abs_top_builddir)/ld1 $@
276 ld2_SOURCES = $(sources_var)
277 ld2_DEPENDENCIES = $(deps_var) gcctestdir2/ld gcctestdir2/collect-ld
278 ld2_LDADD = $(ldadd_var)
279 editcc2 = -e 's/\([^ ]*\)\(.*\)/\1 -Bgcctestdir2\/\2/'
280 ld2_LINK = `echo $(CXXLD) | sed $(editcc2)`\
281 $(AM_CXXFLAGS) $(CXXFLAGS) $(ld2_LDFLAGS) $(LDFLAGS) -o $@
283 TEST_READELF = $(top_builddir)/../binutils/readelf
285 # Skip this for LTO build due to different build IDs.
288 echo "#!/bin/sh" > $@
289 if $(TEST_READELF) -SW main.$(OBJEXT) | grep "gnu.lto" > /dev/null; then \
292 echo "cmp ld1 ld2" >> $@; \
296 libgold-1-r.o: gcctestdir1/ld libgold.a
297 gcctestdir1/ld -o $@ -r --whole-archive libgold.a
299 ld1_r_SOURCES = $(sources_var)
300 ld1_r_DEPENDENCIES = libgold-1-r.o $(deps_var) gcctestdir1/ld gcctestdir1/collect-ld
301 ld1_r_LDADD = libgold-1-r.o $(ldadd_var)
302 ld1_r_LINK = `echo $(CXXLD) | sed $(editcc1)`\
303 $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
305 gcctestdir2-r/ld gcctestdir2-r/collect-ld: ld1-r
306 test -d gcctestdir2-r || mkdir -p gcctestdir2-r
308 $(LN_S) $(abs_top_builddir)/ld1-r $@
310 libgold-2-r.o: gcctestdir2-r/ld libgold.a
311 gcctestdir2-r/ld -o $@ -r --whole-archive libgold.a
313 ld2_r_SOURCES = $(sources_var)
314 ld2_r_DEPENDENCIES = libgold-2-r.o $(deps_var) gcctestdir2-r/ld gcctestdir2-r/collect-ld
315 ld2_r_LDADD = libgold-2-r.o $(ldadd_var)
316 editcc2r = -e 's/\([^ ]*\)\(.*\)/\1 -Bgcctestdir2-r\/\2/'
317 ld2_r_LINK = `echo $(CXXLD) | sed $(editcc2r)`\
318 $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
320 # Skip this for LTO build due to different build IDs.
321 bootstrap-test-r: ld2-r
323 echo "#!/bin/sh" > $@
324 if $(TEST_READELF) -SW main.$(OBJEXT) | grep "gnu.lto" > /dev/null; then \
327 echo "cmp ld1-r ld2-r" >> $@; \
331 check_PROGRAMS = ld1 ld2 ld1-r ld2-r
332 TESTS = bootstrap-test bootstrap-test-r
333 MOSTLYCLEANFILES = bootstrap-test bootstrap-test-r
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.
341 check_PROGRAMS += ld4
342 TESTS += bootstrap-test-treehash-chunksize
343 MOSTLYCLEANFILES += bootstrap-test-treehash-chunksize
345 gcctestdir3/ld gcctestdir3/collect-ld: ld-new
346 test -d gcctestdir3 || mkdir -p gcctestdir3
348 $(LN_S) $(abs_top_builddir)/ld-new $@
350 ld3_SOURCES = $(sources_var)
351 ld3_DEPENDENCIES = $(deps_var) gcctestdir3/ld gcctestdir3/collect-ld
352 ld3_LDADD = $(ldadd_var)
353 editcc3 = -e 's/\([^ ]*\)\(.*\)/\1 -Bgcctestdir3\/\2/'
354 ld3_LINK = `echo $(CXXLD) | sed $(editcc3)`\
355 $(AM_CXXFLAGS) $(CXXFLAGS) $(ld3_LDFLAGS) $(LDFLAGS) -o $@
357 gcctestdir4/ld gcctestdir4/collect-ld: ld-new
358 test -d gcctestdir4 || mkdir -p gcctestdir4
360 $(LN_S) $(abs_top_builddir)/ld-new $@
362 ld4_SOURCES = $(sources_var)
363 ld4_DEPENDENCIES = $(deps_var) gcctestdir4/ld gcctestdir4/collect-ld
364 ld4_LDADD = $(ldadd_var)
365 editcc4 = -e 's/\([^ ]*\)\(.*\)/\1 -Bgcctestdir4\/\2/'
366 ld4_LINK = `echo $(CXXLD) | sed $(editcc4)`\
367 $(AM_CXXFLAGS) $(CXXFLAGS) $(ld4_LDFLAGS) $(LDFLAGS) -o $@
369 ld1_LDFLAGS = -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12345 -Wl,--build-id-min-file-size-for-treehash=0
370 ld2_LDFLAGS = -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12345 -Wl,--build-id-min-file-size-for-treehash=0
371 ld3_LDFLAGS = -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12345 -Wl,--build-id-min-file-size-for-treehash=0
372 ld4_LDFLAGS = -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12346 -Wl,--build-id-min-file-size-for-treehash=0
376 ld1_LDFLAGS += -Wl,--thread-count=3
377 ld2_LDFLAGS += -Wl,--thread-count=3
378 ld3_LDFLAGS += -Wl,--thread-count=13
379 ld4_LDFLAGS += -Wl,--thread-count=3
380 check_PROGRAMS += ld3
381 TESTS += bootstrap-test-treehash-chunksize
382 MOSTLYCLEANFILES += bootstrap-test-treehash-chunksize
384 bootstrap-test-treehash: ld1 ld3
386 echo "#!/bin/sh" > $@
387 echo "cmp ld1 ld3" >> $@
392 bootstrap-test-treehash-chunksize: ld1 ld4
394 echo "#!/bin/sh" > $@
395 echo "cmp ld1 ld4 | grep ." >> $@