blob: ccb6f96cf01064a5c9f899a3c725e0045e47f9c1 [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001## Process this file with automake to create Makefile.in
2##
3## Copyright (C) 1996-2002, 2003, 2004, 2005 Red Hat, Inc.
4##
5## This program is Open Source software; you can redistribute it and/or
6## modify it under the terms of the Open Software License version 1.0 as
7## published by the Open Source Initiative.
8##
9## You should have received a copy of the Open Software License along
10## with this program; if not, you may obtain a copy of the Open Software
11## License version 1.0 from http://www.opensource.org/licenses/osl.php or
12## by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
13## 3001 King Ranch Road, Ukiah, CA 95482.
14##
15DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) \
16 -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
17if MUDFLAP
18AM_CFLAGS = -Wall -Wshadow -Wunused -Wextra -std=gnu99 -fmudflap \
19 $(native_ld_cflags) $(if $($(*F)_no_Wunused),,-Wunused) \
20 $(if $($(*F)_no_Wformat),,-Wformat=2)
21else
22AM_CFLAGS = -Wall -Wshadow -std=gnu99 $(native_ld_cflags) \
23 $(if $($(*F)_no_Werror),,-Werror) \
24 $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
25 $(if $($(*F)_no_Wformat),,-Wformat=2)
26endif
27if MUDFLAP
28libmudflap = -lmudflap
29endif
30INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl -I$(srcdir)/../lib -I$(srcdir)/../libdw -I..
31
32YACC = @YACC@ -d
33AM_YFLAGS = -pld
34AM_LFLAGS = -Pld -olex.yy.c
35## Uncomment to enable debugging of linker script parser
36##YYDEBUG = -DYYDEBUG=1
37
38native_ld = @native_ld@
39base_cpu = @base_cpu@
40
41bin_PROGRAMS = readelf nm size strip ld elflint findtextrel addr2line \
42 elfcmp
43
44
45ld_dsos = libld_elf_i386_pic.a
46if NATIVE_LD
47noinst_LIBRARIES = libld_elf.a
48native_ld_cflags = -DBASE_ELF_NAME=elf_$(base_cpu)
49else
50noinst_LIBRARIES = libld_elf.a $(ld_dsos)
51noinst_PROGRAMS = $(ld_dsos:_pic.a=.so)
52endif
53
54textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
55
56
57ld_SOURCES = ld.c ldgeneric.c ldlex.l ldscript.y symbolhash.c sectionhash.c \
58 versionhash.c
59
60noinst_HEADERS = ld.h symbolhash.h sectionhash.h versionhash.h \
61 ldscript.h xelf.h unaligned.h
62
63EXTRA_DIST = elf32-i386.script libld_elf_i386.map $(ld_modules)
64ld_modules = i386_ld.c
65
66if MUDFLAP
67libdw = ../libdw/libdw.a
68libelf = ../libelf/libelf.a
69else
70libdw = ../libdw/libdw.so
71libelf = ../libelf/libelf.so
72endif
73libebl = ../libebl/libebl.a
74libeu = ../lib/libeu.a
75
76nm_no_Wformat = yes
77size_no_Wformat = yes
78# XXX While the file is not finished, don't warn about this
79ldgeneric_no_Wunused = yes
80
81readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
82nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
83size_LDADD = $(libelf) $(libeu) $(libmudflap)
84strip_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
85ld_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
86if NATIVE_LD
87ld_LDADD += libld_elf.a
88endif
89ld_LDFLAGS = -rdynamic
90elflint_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
91findtextrel_LDADD = $(libdw) $(libelf) $(libmudflap)
92addr2line_LDADD = $(libdw) $(libelf) $(libmudflap)
93elfcmp_LDADD = $(libebl) $(libelf) $(libmudflap) -ldl
94
95ldlex.o: ldscript.c
96ldlex_no_Werror = yes
97ldscript.h: ldscript.c
98
99# Machine-specific linker code.
100libld_elf_a_SOURCES = $(base_cpu)_ld.c
101
102libld_elf_i386_pic_a_SOURCES =
103am_libld_elf_i386_pic_a_OBJECTS = i386_ld.os
104
105libld_elf_i386_so_SOURCES =
106libld_elf_i386.so: libld_elf_i386_pic.a libld_elf_i386.map
107 $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
108 $(libelf) $(libeu) \
109 -Wl,--version-script,$(srcdir)/libld_elf_i386.map
110 $(textrel_check)
111
112
113%.os: %.c %.o
114 if $(filter-out -fmudflap,$(COMPILE)) -c -o $@ -fpic -DPIC -DSHARED \
115 -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
116 `test -f '$<' || echo '$(srcdir)/'`$<; \
117 then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
118 rm -f "$(DEPDIR)/$*.Tpo"; \
119 else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
120 fi
121
122# Special rule to make it possible to define libld_elf_a_SOURCES as we do.
123# Otherwise make would complain.
124.deps/none_ld.Po: none_ld.os
125 -:
126
127
128installcheck-binPROGRAMS: $(bin_PROGRAMS)
129 bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \
130 case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
131 *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
132 esac; \
133 f=`echo "$$p" | \
134 sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
135 for opt in --help --version; do \
136 if LD_LIBRARY_PATH=$(DESTDIR)$(libdir) \
137 $(DESTDIR)$(bindir)/$$f $$opt > c$${pid}_.out 2> c$${pid}_.err \
138 && test -n "`cat c$${pid}_.out`" \
139 && test -z "`cat c$${pid}_.err`"; then :; \
140 else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
141 done; \
142 done; rm -f c$${pid}_.???; exit $$bad
143
144CLEANFILES = none_ld.os $(ld_modules:.c=.os)