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_csv.c \ 19 is_tar.c magic.c print.c readcdf.c readelf.c seccomp.c softmagic.c 20INCS= magic.h 21 22MAGICPATH?= /usr/share/misc 23 24CFLAGS+= -DMAGIC='"${MAGICPATH}/magic"' -DHAVE_CONFIG_H 25CFLAGS+= -I${.CURDIR} -I${.OBJDIR} -I${CONTRDIR}/src 26 27WARNS?= 3 28 29CLEANFILES+= magic magic.mgc 30 31FILES= magic magic.mgc 32FILESDIR= ${MAGICPATH} 33 34MAGFILES= ${CONTRDIR}/magic/Header \ 35 ${CONTRDIR}/magic/Localstuff \ 36 ${CONTRDIR}/magic/Magdir/[a-z]* 37 38magic: ${MAGFILES} 39 cat ${.ALLSRC:O} > ${.TARGET} 40 41magic.mgc: magic 42 ${BTOOLSPATH:U.}/mkmagic magic 43 44.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no" 45CLEANFILES+= mkmagic 46DEPENDOBJS+= mkmagic 47build-tools: mkmagic 48mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${INCS} ${BUILD_TOOLS_META} 49 ${CC:N${CCACHE_BIN}} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} \ 50 ${.ALLSRC:N*.h:O:u} ${LDADD} 51 52.endif 53.if ${MK_DIRDEPS_BUILD} == "yes" 54BTOOLSPATH= ${HOST_OBJTOP}/${RELDIR} 55.else 56magic.mgc: mkmagic 57.endif 58 59FILEVER!= awk '$$1 == "\#define" && $$2 == "VERSION" { print $$3; exit }' \ 60 ${.CURDIR}/config.h 61CLEANFILES+= ${MAN} 62.for mp in ${MAN} 63${mp}: ${mp:C/[0-9]/man/} 64 sed -e 's/__FSECTION__/5/g' -e 's/__CSECTION__/1/g' \ 65 -e 's/__VERSION__/${FILEVER}/g' \ 66 -e 's,__MAGIC__,${MAGICPATH}/magic,g' ${.ALLSRC} > ${.TARGET} 67.endfor 68 69CLEANFILES+= ${INCS} 70.for inc in ${INCS} 71${inc}: ${inc}.in 72 sed -e 's,X.YY,${FILEVER:S,",,g:S,.,,g},g' ${.ALLSRC} > ${.TARGET} 73.endfor 74 75.include <bsd.lib.mk> 76