xref: /freebsd/lib/libelf/Makefile (revision e9ac41698b2f322d55ccf9da50a3596edb2c1800)
1e5e23eccSBryan DrewerySHLIBDIR?= /lib
2e5e23eccSBryan Drewery
3edbef29bSKai Wang.include <bsd.own.mk>
4edbef29bSKai Wang
52821bdccSEd MasteELFTCDIR=${SRCTOP}/contrib/elftoolchain
62821bdccSEd MasteSRCDIR=	${ELFTCDIR}/libelf
7edbef29bSKai Wang
8edbef29bSKai Wang.PATH:	${SRCDIR}
93eb1a62eSJoseph Koshy
10a7b5a3d4SEmmanuel VadotPACKAGE=	runtime
113eb1a62eSJoseph KoshyLIB=	elf
123eb1a62eSJoseph Koshy
13edbef29bSKai WangSRCS=	elf.c							\
14edbef29bSKai Wang	elf_begin.c						\
153eb1a62eSJoseph Koshy	elf_cntl.c						\
163eb1a62eSJoseph Koshy	elf_end.c elf_errmsg.c elf_errno.c			\
173eb1a62eSJoseph Koshy	elf_data.c						\
183eb1a62eSJoseph Koshy	elf_fill.c						\
193eb1a62eSJoseph Koshy	elf_flag.c						\
203eb1a62eSJoseph Koshy	elf_getarhdr.c						\
213eb1a62eSJoseph Koshy	elf_getarsym.c						\
223eb1a62eSJoseph Koshy	elf_getbase.c						\
233eb1a62eSJoseph Koshy	elf_getident.c						\
243eb1a62eSJoseph Koshy	elf_hash.c						\
253eb1a62eSJoseph Koshy	elf_kind.c						\
263eb1a62eSJoseph Koshy	elf_memory.c						\
273eb1a62eSJoseph Koshy	elf_next.c						\
28edbef29bSKai Wang	elf_open.c						\
293eb1a62eSJoseph Koshy	elf_rand.c						\
303eb1a62eSJoseph Koshy	elf_rawfile.c						\
31f6c0f35eSJoseph Koshy	elf_phnum.c						\
323eb1a62eSJoseph Koshy	elf_shnum.c						\
333eb1a62eSJoseph Koshy	elf_shstrndx.c						\
343eb1a62eSJoseph Koshy	elf_scn.c						\
353eb1a62eSJoseph Koshy	elf_strptr.c						\
363eb1a62eSJoseph Koshy	elf_update.c						\
373eb1a62eSJoseph Koshy	elf_version.c						\
382dacb27eSJoseph Koshy	gelf_cap.c						\
39573456a9SEd Maste	gelf_chdr.c						\
403eb1a62eSJoseph Koshy	gelf_checksum.c						\
413eb1a62eSJoseph Koshy	gelf_dyn.c						\
423eb1a62eSJoseph Koshy	gelf_ehdr.c						\
432dacb27eSJoseph Koshy	gelf_getclass.c						\
442dacb27eSJoseph Koshy	gelf_fsize.c						\
459f45c6c1SJohn Baldwin	gelf_mips64el.c						\
462dacb27eSJoseph Koshy	gelf_move.c						\
473eb1a62eSJoseph Koshy	gelf_phdr.c						\
483eb1a62eSJoseph Koshy	gelf_rel.c						\
493eb1a62eSJoseph Koshy	gelf_rela.c						\
503eb1a62eSJoseph Koshy	gelf_shdr.c						\
513eb1a62eSJoseph Koshy	gelf_sym.c						\
522dacb27eSJoseph Koshy	gelf_syminfo.c						\
533eb1a62eSJoseph Koshy	gelf_symshndx.c						\
543eb1a62eSJoseph Koshy	gelf_xlate.c						\
553eb1a62eSJoseph Koshy	libelf_align.c						\
563eb1a62eSJoseph Koshy	libelf_allocate.c					\
573eb1a62eSJoseph Koshy	libelf_ar.c						\
58d961c5b4SKai Wang	libelf_ar_util.c					\
59573456a9SEd Maste	libelf_chdr.c						\
603eb1a62eSJoseph Koshy	libelf_checksum.c					\
613eb1a62eSJoseph Koshy	libelf_data.c						\
623eb1a62eSJoseph Koshy	libelf_ehdr.c						\
63ae500c1fSEd Maste	libelf_elfmachine.c					\
64f6c0f35eSJoseph Koshy	libelf_extended.c					\
65edbef29bSKai Wang	libelf_memory.c						\
66edbef29bSKai Wang	libelf_open.c						\
673eb1a62eSJoseph Koshy	libelf_phdr.c						\
683eb1a62eSJoseph Koshy	libelf_shdr.c						\
699167cd63SJoseph Koshy	libelf_xlate.c						\
709167cd63SJoseph Koshy	${GENSRCS}
713eb1a62eSJoseph Koshy
72edbef29bSKai WangINCS=		libelf.h gelf.h
73ec280fdbSAndrew Turner
744aa63711SBryan Drewery# This same hack is in lib/libdwarf/Makefile and usr.bin/readelf/Makefile
756eabfa96SKai Wang# We need to link against the correct version of these files. One
766eabfa96SKai Wang# solution is to include ../../sys in the include path. This causes
776eabfa96SKai Wang# problems when a header file in sys depends on a file in another
786eabfa96SKai Wang# part of the tree, e.g. a machine dependent header.
796eabfa96SKai Wang#
806eabfa96SKai WangSRCS+=	sys/elf32.h sys/elf64.h sys/elf_common.h
816eabfa96SKai Wang
82b46517aaSAlex Richardson# Allow bootstrapping elftoolchain on Linux:
83b46517aaSAlex Richardson.if defined(BOOTSTRAPPING) && ${.MAKE.OS} == "Linux"
84b46517aaSAlex Richardsonnative-elf-format.h:
85b46517aaSAlex Richardson	${ELFTCDIR}/common/native-elf-format > ${.TARGET} || rm ${.TARGET}
86b46517aaSAlex RichardsonSRCS+=	native-elf-format.h
87b46517aaSAlex Richardson.endif
88b46517aaSAlex Richardson
8973eee246SRuslan ErmilovGENSRCS=	libelf_fsize.c libelf_msize.c libelf_convert.c
9073eee246SRuslan ErmilovCLEANFILES=	${GENSRCS}
916eabfa96SKai WangCLEANDIRS=	sys
922821bdccSEd MasteCFLAGS+=	-I. -I${SRCDIR} -I${ELFTCDIR}/common
933eb1a62eSJoseph Koshy
94b18d12baSEnji Coopersys/elf32.h sys/elf64.h sys/elf_common.h: ${SRCTOP}/sys/${.TARGET} .NOMETA
956eabfa96SKai Wang	mkdir -p ${.OBJDIR}/sys
96b791fbe6SBryan Drewery	ln -sf ${.ALLSRC} ${.TARGET}
976eabfa96SKai Wang
9888d795a0SKai WangSHLIB_MAJOR=	2
993eb1a62eSJoseph Koshy
1003eb1a62eSJoseph KoshyMAN=	elf.3							\
1013eb1a62eSJoseph Koshy	elf_begin.3						\
1023eb1a62eSJoseph Koshy	elf_cntl.3						\
10386f5401bSKai Wang	elf_end.3						\
10486f5401bSKai Wang	elf_errmsg.3						\
1053eb1a62eSJoseph Koshy	elf_fill.3						\
1063eb1a62eSJoseph Koshy	elf_flagdata.3						\
1073eb1a62eSJoseph Koshy	elf_getarhdr.3						\
1083eb1a62eSJoseph Koshy	elf_getarsym.3						\
1093eb1a62eSJoseph Koshy	elf_getbase.3						\
1103eb1a62eSJoseph Koshy	elf_getdata.3						\
1113eb1a62eSJoseph Koshy	elf_getident.3						\
1123eb1a62eSJoseph Koshy	elf_getscn.3						\
11386f5401bSKai Wang	elf_getphdrnum.3					\
114f6c0f35eSJoseph Koshy	elf_getphnum.3						\
11586f5401bSKai Wang	elf_getshdrnum.3					\
1163eb1a62eSJoseph Koshy	elf_getshnum.3						\
11786f5401bSKai Wang	elf_getshdrstrndx.3					\
1183eb1a62eSJoseph Koshy	elf_getshstrndx.3					\
1193eb1a62eSJoseph Koshy	elf_hash.3						\
1203eb1a62eSJoseph Koshy	elf_kind.3						\
1213eb1a62eSJoseph Koshy	elf_memory.3						\
1223eb1a62eSJoseph Koshy	elf_next.3						\
123edbef29bSKai Wang	elf_open.3						\
1243eb1a62eSJoseph Koshy	elf_rawfile.3						\
1253eb1a62eSJoseph Koshy	elf_rand.3						\
1263eb1a62eSJoseph Koshy	elf_strptr.3						\
1273eb1a62eSJoseph Koshy	elf_update.3						\
1283eb1a62eSJoseph Koshy	elf_version.3						\
1293eb1a62eSJoseph Koshy	gelf.3							\
1303eb1a62eSJoseph Koshy	gelf_checksum.3						\
1313eb1a62eSJoseph Koshy	gelf_fsize.3						\
1323eb1a62eSJoseph Koshy	gelf_getcap.3						\
133*9ff084f0SMark Johnston	gelf_getchdr.3						\
1343eb1a62eSJoseph Koshy	gelf_getclass.3						\
1353eb1a62eSJoseph Koshy	gelf_getdyn.3						\
1363eb1a62eSJoseph Koshy	gelf_getehdr.3						\
1373eb1a62eSJoseph Koshy	gelf_getmove.3						\
1383eb1a62eSJoseph Koshy	gelf_getphdr.3						\
1393eb1a62eSJoseph Koshy	gelf_getrel.3						\
1403eb1a62eSJoseph Koshy	gelf_getrela.3						\
1413eb1a62eSJoseph Koshy	gelf_getshdr.3						\
1423eb1a62eSJoseph Koshy	gelf_getsym.3						\
1433eb1a62eSJoseph Koshy	gelf_getsyminfo.3					\
1443eb1a62eSJoseph Koshy	gelf_getsymshndx.3					\
1453eb1a62eSJoseph Koshy	gelf_newehdr.3						\
1463eb1a62eSJoseph Koshy	gelf_newphdr.3						\
1473eb1a62eSJoseph Koshy	gelf_update_ehdr.3					\
1483eb1a62eSJoseph Koshy	gelf_xlatetof.3
1493eb1a62eSJoseph Koshy
1503eb1a62eSJoseph KoshyMLINKS+= \
1513eb1a62eSJoseph Koshy	elf_errmsg.3 elf_errno.3		\
152edbef29bSKai Wang	elf_flagdata.3 elf_flagarhdr.3		\
1533eb1a62eSJoseph Koshy	elf_flagdata.3 elf_flagehdr.3		\
1543eb1a62eSJoseph Koshy	elf_flagdata.3 elf_flagelf.3		\
1553eb1a62eSJoseph Koshy	elf_flagdata.3 elf_flagphdr.3		\
1563eb1a62eSJoseph Koshy	elf_flagdata.3 elf_flagscn.3		\
1573eb1a62eSJoseph Koshy	elf_flagdata.3 elf_flagshdr.3		\
1583eb1a62eSJoseph Koshy	elf_getdata.3 elf_newdata.3		\
1593eb1a62eSJoseph Koshy	elf_getdata.3 elf_rawdata.3		\
1603eb1a62eSJoseph Koshy	elf_getscn.3 elf_ndxscn.3		\
1613eb1a62eSJoseph Koshy	elf_getscn.3 elf_newscn.3		\
1623eb1a62eSJoseph Koshy	elf_getscn.3 elf_nextscn.3		\
1633eb1a62eSJoseph Koshy	elf_getshstrndx.3 elf_setshstrndx.3	\
164edbef29bSKai Wang	elf_open.3 elf_openmemory.3             \
1653eb1a62eSJoseph Koshy	gelf_getcap.3 gelf_update_cap.3		\
1663eb1a62eSJoseph Koshy	gelf_getdyn.3 gelf_update_dyn.3		\
1673eb1a62eSJoseph Koshy	gelf_getmove.3 gelf_update_move.3	\
1683eb1a62eSJoseph Koshy	gelf_getrel.3 gelf_update_rel.3		\
1693eb1a62eSJoseph Koshy	gelf_getrela.3 gelf_update_rela.3	\
1703eb1a62eSJoseph Koshy	gelf_getsym.3 gelf_update_sym.3		\
1713eb1a62eSJoseph Koshy	gelf_getsyminfo.3 gelf_update_syminfo.3	\
1723eb1a62eSJoseph Koshy	gelf_getsymshndx.3 gelf_update_symshndx.3 \
1733eb1a62eSJoseph Koshy	gelf_update_ehdr.3 gelf_update_phdr.3	\
1743eb1a62eSJoseph Koshy	gelf_update_ehdr.3 gelf_update_shdr.3	\
1753eb1a62eSJoseph Koshy	gelf_xlatetof.3 gelf_xlatetom.3
1763eb1a62eSJoseph Koshy
1773eb1a62eSJoseph Koshy.for E in 32 64
1783eb1a62eSJoseph KoshyMLINKS+= \
1793eb1a62eSJoseph Koshy	gelf_checksum.3	elf${E}_checksum.3 	\
1803eb1a62eSJoseph Koshy	gelf_fsize.3	elf${E}_fsize.3 	\
181*9ff084f0SMark Johnston	gelf_getchdr.3	elf${E}_getchdr.3	\
1823eb1a62eSJoseph Koshy	gelf_getehdr.3	elf${E}_getehdr.3	\
1833eb1a62eSJoseph Koshy	gelf_getphdr.3	elf${E}_getphdr.3	\
1843eb1a62eSJoseph Koshy	gelf_getshdr.3	elf${E}_getshdr.3	\
1853eb1a62eSJoseph Koshy	gelf_newehdr.3	elf${E}_newehdr.3	\
1863eb1a62eSJoseph Koshy	gelf_newphdr.3	elf${E}_newphdr.3	\
1873eb1a62eSJoseph Koshy	gelf_xlatetof.3	elf${E}_xlatetof.3	\
1883eb1a62eSJoseph Koshy	gelf_xlatetof.3	elf${E}_xlatetom.3
1893eb1a62eSJoseph Koshy.endfor
1903eb1a62eSJoseph Koshy
191edbef29bSKai WangVERSION_MAP=           ${SRCDIR}/Version.map
1923eb1a62eSJoseph Koshy
1933eb1a62eSJoseph Koshylibelf_convert.c:	elf_types.m4 libelf_convert.m4
1943eb1a62eSJoseph Koshylibelf_fsize.c:		elf_types.m4 libelf_fsize.m4
1953eb1a62eSJoseph Koshylibelf_msize.c:		elf_types.m4 libelf_msize.m4
1963eb1a62eSJoseph Koshy
1973eb1a62eSJoseph Koshy.include <bsd.lib.mk>
1983eb1a62eSJoseph Koshy
1999167cd63SJoseph Koshy# Keep the .SUFFIXES line after the include of bsd.lib.mk
2003eb1a62eSJoseph Koshy.SUFFIXES:	.m4 .c
2013eb1a62eSJoseph Koshy.m4.c:
202edbef29bSKai Wang	m4 -D SRCDIR=${SRCDIR} ${M4FLAGS} ${.IMPSRC} > ${.TARGET}
203edbef29bSKai Wang
204