xref: /freebsd/lib/libmagic/Makefile (revision 1e413cf93298b5b97441a21d9a50fdcd0ee9945e)
1# $FreeBSD$
2# Copyright (c) David E. O'Brien, 2000-2004
3
4CONTRDIR=	${.CURDIR}/../../contrib/file
5.PATH: ${CONTRDIR}
6
7LIB=	magic
8SHLIB_MAJOR=	3
9DPADD=	${LIBZ}
10LDADD=	-lz
11MAN=	libmagic.3 magic.5
12
13SRCS=	apprentice.c apptype.c ascmagic.c compress.c fsmagic.c funcs.c \
14	is_tar.c magic.c print.c readelf.c softmagic.c
15INCS=	magic.h
16
17MAGICPATH?=	/usr/share/misc
18
19CFLAGS+= -DMAGIC='"${MAGICPATH}/magic"' -DHAVE_CONFIG_H
20CFLAGS+= -I${.CURDIR} -I${CONTRDIR}
21
22CLEANFILES+=	magic magic.mgc magic.mime.mgc
23
24FILES=		magic magic.mgc ${CONTRDIR}/magic.mime magic.mime.mgc
25FILESDIR=	${MAGICPATH}
26
27MAGFILES=	${CONTRDIR}/Header\
28		${CONTRDIR}/Localstuff\
29		${CONTRDIR}/Magdir/[a-z]*
30
31magic: ${MAGFILES}
32	cat ${.ALLSRC} > ${.TARGET}
33
34magic.mgc: mkmagic magic
35	./mkmagic magic
36
37magic.mime.mgc: mkmagic magic.mime
38	./mkmagic ${CONTRDIR}/magic.mime
39
40CLEANFILES+=	mkmagic
41build-tools: mkmagic
42mkmagic: apprentice.c funcs.c magic.c print.c
43	${CC} -DHAVE_CONFIG_H -DCOMPILE_ONLY \
44	    -I${.CURDIR} -I${CONTRDIR} -o ${.TARGET} ${.ALLSRC}
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