xref: /freebsd/lib/libmagic/Makefile (revision ca987d4641cdcd7f27e153db17c5bf064934faf5)
1# $FreeBSD$
2# Copyright (c) David E. O'Brien, 2000-2004, 2006, 2009
3
4PACKAGE=lib${LIB}
5CONTRDIR=	${SRCTOP}/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	der.c 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${.OBJDIR} -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	${BTOOLSPATH:U.}/mkmagic magic
40
41CLEANFILES+=	mkmagic
42build-tools: mkmagic
43mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${INCS} ${BUILD_TOOLS_META}
44	${CC} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} ${.ALLSRC:N*.h} \
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
57CLEANFILES+=	${INCS}
58.for inc in ${INCS}
59${inc}: ${inc}.in
60	sed -e 's,X.YY,${FILEVER:S,",,g:S,.,,g},g' ${.ALLSRC} > ${.TARGET}
61.endfor
62
63.include <bsd.lib.mk>
64