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 buffer.c cdf.c cdf_time.c \ 17 compress.c der.c encoding.c fsmagic.c funcs.c \ 18 is_tar.c magic.c print.c readcdf.c readelf.c seccomp.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 44DEPENDOBJS+= mkmagic 45build-tools: mkmagic 46mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${INCS} ${BUILD_TOOLS_META} 47 ${CC:N${CCACHE_BIN}} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} \ 48 ${.ALLSRC:N*.h:O:u} ${LDADD} 49 50FILEVER!= awk '$$1 == "\#define" && $$2 == "VERSION" { print $$3; exit }' \ 51 ${.CURDIR}/config.h 52CLEANFILES+= ${MAN} 53.for mp in ${MAN} 54${mp}: ${mp:C/[0-9]/man/} 55 sed -e 's/__FSECTION__/5/g' -e 's/__CSECTION__/1/g' \ 56 -e 's/__VERSION__/${FILEVER}/g' \ 57 -e 's,__MAGIC__,${MAGICPATH}/magic,g' ${.ALLSRC} > ${.TARGET} 58.endfor 59 60CLEANFILES+= ${INCS} 61.for inc in ${INCS} 62${inc}: ${inc}.in 63 sed -e 's,X.YY,${FILEVER:S,",,g:S,.,,g},g' ${.ALLSRC} > ${.TARGET} 64.endfor 65 66.include <bsd.lib.mk> 67