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