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