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 11.if !make(build-tools) 12LIBADD= z 13.endif 14MAN= libmagic.3 magic.5 15 16SRCS= apprentice.c apptype.c ascmagic.c cdf.c cdf_time.c compress.c \ 17 der.c encoding.c fsmagic.c funcs.c \ 18 is_tar.c magic.c print.c readcdf.c readelf.c softmagic.c 19INCS= magic.h 20 21MAGICPATH?= /usr/share/misc 22 23CFLAGS+= -DMAGIC='"${MAGICPATH}/magic"' -DHAVE_CONFIG_H 24CFLAGS+= -I${.CURDIR} -I${.OBJDIR} -I${CONTRDIR}/src 25 26WARNS?= 3 27 28CLEANFILES+= magic magic.mgc 29 30FILES= magic magic.mgc 31FILESDIR= ${MAGICPATH} 32 33MAGFILES= ${CONTRDIR}/magic/Header \ 34 ${CONTRDIR}/magic/Localstuff \ 35 ${CONTRDIR}/magic/Magdir/[a-z]* 36 37magic: ${MAGFILES} 38 cat ${.ALLSRC:O} > ${.TARGET} 39 40magic.mgc: mkmagic magic 41 ${BTOOLSPATH:U.}/mkmagic magic 42 43CLEANFILES+= mkmagic 44build-tools: mkmagic 45mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${INCS} ${BUILD_TOOLS_META} 46 ${CC} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} ${.ALLSRC:N*.h} \ 47 ${LDADD} 48 49FILEVER!= awk '$$1 == "\#define" && $$2 == "VERSION" { print $$3; exit }' \ 50 ${.CURDIR}/config.h 51CLEANFILES+= ${MAN} 52.for mp in ${MAN} 53${mp}: ${mp:C/[0-9]/man/} 54 sed -e 's/__FSECTION__/5/g' -e 's/__CSECTION__/1/g' \ 55 -e 's/__VERSION__/${FILEVER}/g' \ 56 -e 's,__MAGIC__,${MAGICPATH}/magic,g' ${.ALLSRC} > ${.TARGET} 57.endfor 58 59CLEANFILES+= ${INCS} 60.for inc in ${INCS} 61${inc}: ${inc}.in 62 sed -e 's,X.YY,${FILEVER:S,",,g:S,.,,g},g' ${.ALLSRC} > ${.TARGET} 63.endfor 64 65.include <bsd.lib.mk> 66