xref: /freebsd/lib/libelf/Makefile (revision dd41de95a84d979615a2ef11df6850622bf6184e)
1# $FreeBSD$
2
3SHLIBDIR?= /lib
4
5.include <bsd.own.mk>
6
7ELFTCDIR=${SRCTOP}/contrib/elftoolchain
8SRCDIR=	${ELFTCDIR}/libelf
9
10.PATH:	${SRCDIR}
11
12PACKAGE=	runtime
13LIB=	elf
14
15SRCS=	elf.c							\
16	elf_begin.c						\
17	elf_cntl.c						\
18	elf_end.c elf_errmsg.c elf_errno.c			\
19	elf_data.c						\
20	elf_fill.c						\
21	elf_flag.c						\
22	elf_getarhdr.c						\
23	elf_getarsym.c						\
24	elf_getbase.c						\
25	elf_getident.c						\
26	elf_hash.c						\
27	elf_kind.c						\
28	elf_memory.c						\
29	elf_next.c						\
30	elf_open.c						\
31	elf_rand.c						\
32	elf_rawfile.c						\
33	elf_phnum.c						\
34	elf_shnum.c						\
35	elf_shstrndx.c						\
36	elf_scn.c						\
37	elf_strptr.c						\
38	elf_update.c						\
39	elf_version.c						\
40	gelf_cap.c						\
41	gelf_chdr.c						\
42	gelf_checksum.c						\
43	gelf_dyn.c						\
44	gelf_ehdr.c						\
45	gelf_getclass.c						\
46	gelf_fsize.c						\
47	gelf_mips64el.c						\
48	gelf_move.c						\
49	gelf_phdr.c						\
50	gelf_rel.c						\
51	gelf_rela.c						\
52	gelf_shdr.c						\
53	gelf_sym.c						\
54	gelf_syminfo.c						\
55	gelf_symshndx.c						\
56	gelf_xlate.c						\
57	libelf_align.c						\
58	libelf_allocate.c					\
59	libelf_ar.c						\
60	libelf_ar_util.c					\
61	libelf_chdr.c						\
62	libelf_checksum.c					\
63	libelf_data.c						\
64	libelf_ehdr.c						\
65	libelf_elfmachine.c					\
66	libelf_extended.c					\
67	libelf_memory.c						\
68	libelf_open.c						\
69	libelf_phdr.c						\
70	libelf_shdr.c						\
71	libelf_xlate.c						\
72	${GENSRCS}
73
74INCS=		libelf.h gelf.h
75
76# This same hack is in lib/libdwarf/Makefile and usr.bin/readelf/Makefile
77# We need to link against the correct version of these files. One
78# solution is to include ../../sys in the include path. This causes
79# problems when a header file in sys depends on a file in another
80# part of the tree, e.g. a machine dependent header.
81#
82SRCS+=	sys/elf32.h sys/elf64.h sys/elf_common.h
83
84# Allow bootstrapping elftoolchain on Linux:
85.if defined(BOOTSTRAPPING) && ${.MAKE.OS} == "Linux"
86native-elf-format.h:
87	${ELFTCDIR}/common/native-elf-format > ${.TARGET} || rm ${.TARGET}
88SRCS+=	native-elf-format.h
89.endif
90
91GENSRCS=	libelf_fsize.c libelf_msize.c libelf_convert.c
92CLEANFILES=	${GENSRCS}
93CLEANDIRS=	sys
94CFLAGS+=	-I. -I${SRCDIR} -I${ELFTCDIR}/common
95
96sys/elf32.h sys/elf64.h sys/elf_common.h: ${SRCTOP}/sys/${.TARGET} .NOMETA
97	mkdir -p ${.OBJDIR}/sys
98	ln -sf ${.ALLSRC} ${.TARGET}
99
100SHLIB_MAJOR=	2
101
102MAN=	elf.3							\
103	elf_begin.3						\
104	elf_cntl.3						\
105	elf_end.3						\
106	elf_errmsg.3						\
107	elf_fill.3						\
108	elf_flagdata.3						\
109	elf_getarhdr.3						\
110	elf_getarsym.3						\
111	elf_getbase.3						\
112	elf_getdata.3						\
113	elf_getident.3						\
114	elf_getscn.3						\
115	elf_getphdrnum.3					\
116	elf_getphnum.3						\
117	elf_getshdrnum.3					\
118	elf_getshnum.3						\
119	elf_getshdrstrndx.3					\
120	elf_getshstrndx.3					\
121	elf_hash.3						\
122	elf_kind.3						\
123	elf_memory.3						\
124	elf_next.3						\
125	elf_open.3						\
126	elf_rawfile.3						\
127	elf_rand.3						\
128	elf_strptr.3						\
129	elf_update.3						\
130	elf_version.3						\
131	gelf.3							\
132	gelf_checksum.3						\
133	gelf_fsize.3						\
134	gelf_getcap.3						\
135	gelf_getclass.3						\
136	gelf_getdyn.3						\
137	gelf_getehdr.3						\
138	gelf_getmove.3						\
139	gelf_getphdr.3						\
140	gelf_getrel.3						\
141	gelf_getrela.3						\
142	gelf_getshdr.3						\
143	gelf_getsym.3						\
144	gelf_getsyminfo.3					\
145	gelf_getsymshndx.3					\
146	gelf_newehdr.3						\
147	gelf_newphdr.3						\
148	gelf_update_ehdr.3					\
149	gelf_xlatetof.3
150
151MLINKS+= \
152	elf_errmsg.3 elf_errno.3		\
153	elf_flagdata.3 elf_flagarhdr.3		\
154	elf_flagdata.3 elf_flagehdr.3		\
155	elf_flagdata.3 elf_flagelf.3		\
156	elf_flagdata.3 elf_flagphdr.3		\
157	elf_flagdata.3 elf_flagscn.3		\
158	elf_flagdata.3 elf_flagshdr.3		\
159	elf_getdata.3 elf_newdata.3		\
160	elf_getdata.3 elf_rawdata.3		\
161	elf_getscn.3 elf_ndxscn.3		\
162	elf_getscn.3 elf_newscn.3		\
163	elf_getscn.3 elf_nextscn.3		\
164	elf_getshstrndx.3 elf_setshstrndx.3	\
165	elf_open.3 elf_openmemory.3             \
166	gelf_getcap.3 gelf_update_cap.3		\
167	gelf_getdyn.3 gelf_update_dyn.3		\
168	gelf_getmove.3 gelf_update_move.3	\
169	gelf_getrel.3 gelf_update_rel.3		\
170	gelf_getrela.3 gelf_update_rela.3	\
171	gelf_getsym.3 gelf_update_sym.3		\
172	gelf_getsyminfo.3 gelf_update_syminfo.3	\
173	gelf_getsymshndx.3 gelf_update_symshndx.3 \
174	gelf_update_ehdr.3 gelf_update_phdr.3	\
175	gelf_update_ehdr.3 gelf_update_shdr.3	\
176	gelf_xlatetof.3 gelf_xlatetom.3
177
178.for E in 32 64
179MLINKS+= \
180	gelf_checksum.3	elf${E}_checksum.3 	\
181	gelf_fsize.3	elf${E}_fsize.3 	\
182	gelf_getehdr.3	elf${E}_getehdr.3	\
183	gelf_getphdr.3	elf${E}_getphdr.3	\
184	gelf_getshdr.3	elf${E}_getshdr.3	\
185	gelf_newehdr.3	elf${E}_newehdr.3	\
186	gelf_newphdr.3	elf${E}_newphdr.3	\
187	gelf_xlatetof.3	elf${E}_xlatetof.3	\
188	gelf_xlatetof.3	elf${E}_xlatetom.3
189.endfor
190
191VERSION_MAP=           ${SRCDIR}/Version.map
192
193libelf_convert.c:	elf_types.m4 libelf_convert.m4
194libelf_fsize.c:		elf_types.m4 libelf_fsize.m4
195libelf_msize.c:		elf_types.m4 libelf_msize.m4
196
197.include <bsd.lib.mk>
198
199# Keep the .SUFFIXES line after the include of bsd.lib.mk
200.SUFFIXES:	.m4 .c
201.m4.c:
202	m4 -D SRCDIR=${SRCDIR} ${M4FLAGS} ${.IMPSRC} > ${.TARGET}
203
204