xref: /freebsd/lib/libmagic/Makefile (revision d9f0ce31900a48d1a2bfc1c8c86f79d1e831451a)
1# $FreeBSD$
2# Copyright (c) David E. O'Brien, 2000-2004, 2006, 2009
3
4PACKAGE=lib${LIB}
5CONTRDIR=	${.CURDIR}/../../contrib/file
6.PATH: ${CONTRDIR}/src
7.PATH: ${CONTRDIR}/doc
8
9LIB=	magic
10SHLIB_MAJOR=	4
11LIBADD=	z
12MAN=	libmagic.3 magic.5
13
14SRCS=	apprentice.c apptype.c ascmagic.c cdf.c cdf_time.c compress.c \
15	encoding.c fsmagic.c funcs.c \
16	is_tar.c magic.c print.c readcdf.c readelf.c softmagic.c
17INCS=	magic.h
18
19MAGICPATH?=	/usr/share/misc
20
21CFLAGS+= -DMAGIC='"${MAGICPATH}/magic"' -DHAVE_CONFIG_H
22CFLAGS+= -I${.CURDIR} -I${CONTRDIR}/src
23
24WARNS?=		3
25
26CLEANFILES+=	magic magic.mgc
27
28FILES=		magic magic.mgc
29FILESDIR=	${MAGICPATH}
30
31MAGFILES=	${CONTRDIR}/magic/Header \
32		${CONTRDIR}/magic/Localstuff \
33		${CONTRDIR}/magic/Magdir/[a-z]*
34
35magic: ${MAGFILES}
36	cat ${.ALLSRC:O} > ${.TARGET}
37
38magic.mgc: mkmagic magic
39	./mkmagic magic
40
41CLEANFILES+=	mkmagic
42build-tools: mkmagic
43mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${BUILD_TOOLS_META}
44	${CC} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} \
45	    ${LDADD}
46
47FILEVER!= awk '$$1 == "\#define" && $$2 == "VERSION" { print $$3; exit }' \
48			${.CURDIR}/config.h
49CLEANFILES+=	${MAN}
50.for mp in ${MAN}
51${mp}: ${mp:C/[0-9]/man/}
52	sed -e 's/__FSECTION__/5/g' -e 's/__CSECTION__/1/g' \
53		-e 's/__VERSION__/${FILEVER}/g' \
54		-e 's,__MAGIC__,${MAGICPATH}/magic,g' ${.ALLSRC} > ${.TARGET}
55.endfor
56
57.include <bsd.lib.mk>
58