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 is_json.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: magic 41 ${BTOOLSPATH:U.}/mkmagic magic 42 43.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no" 44CLEANFILES+= mkmagic 45DEPENDOBJS+= mkmagic 46build-tools: mkmagic 47mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${INCS} ${BUILD_TOOLS_META} 48 ${CC:N${CCACHE_BIN}} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} \ 49 ${.ALLSRC:N*.h:O:u} ${LDADD} 50 51.endif 52.if ${MK_DIRDEPS_BUILD} == "yes" 53BTOOLSPATH= ${HOST_OBJTOP}/${RELDIR} 54.else 55magic.mgc: mkmagic 56.endif 57 58FILEVER!= awk '$$1 == "\#define" && $$2 == "VERSION" { print $$3; exit }' \ 59 ${.CURDIR}/config.h 60CLEANFILES+= ${MAN} 61.for mp in ${MAN} 62${mp}: ${mp:C/[0-9]/man/} 63 sed -e 's/__FSECTION__/5/g' -e 's/__CSECTION__/1/g' \ 64 -e 's/__VERSION__/${FILEVER}/g' \ 65 -e 's,__MAGIC__,${MAGICPATH}/magic,g' ${.ALLSRC} > ${.TARGET} 66.endfor 67 68CLEANFILES+= ${INCS} 69.for inc in ${INCS} 70${inc}: ${inc}.in 71 sed -e 's,X.YY,${FILEVER:S,",,g:S,.,,g},g' ${.ALLSRC} > ${.TARGET} 72.endfor 73 74.include <bsd.lib.mk> 75