1# Copyright (c) David E. O'Brien, 2000-2004, 2006, 2009 2 3PACKAGE=lib${LIB} 4CONTRDIR= ${SRCTOP}/contrib/file 5.PATH: ${CONTRDIR} 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_simh.c \ 20 is_tar.c magic.c print.c readcdf.c readelf.c seccomp.c softmagic.c 21INCS= magic.h 22 23MAGICPATH?= /usr/share/misc 24 25CFLAGS+= -DMAGIC='"${MAGICPATH}/magic"' -DHAVE_CONFIG_H 26CFLAGS+= -I${.CURDIR} -I${.OBJDIR} -I${CONTRDIR}/src 27 28WARNS?= 3 29 30CLEANFILES+= magic magic.mgc 31 32FILES= magic magic.mgc 33FILESDIR= ${MAGICPATH} 34 35MAGFILES= ${CONTRDIR}/magic/Header \ 36 ${CONTRDIR}/magic/Localstuff \ 37 ${CONTRDIR}/magic/Magdir/[a-z]* 38 39 40PACKAGE_VERSION!= sed -n '/define.*PACKAGE_VERSION/{s,[^0-9.],,gp;q;}' ${.CURDIR}/config.h 41 42libmagic.pc: libmagic.pc.in 43 sed -e 's,@prefix@,/usr,g ; \ 44 s,@exec_prefix@,$${prefix},g ; \ 45 s,@libdir@,${LIBDIR},g ; \ 46 s,@sharedlibdir@,${SHLIBDIR},g ; \ 47 s,@includedir@,${INCLUDEDIR},g ; \ 48 s,@VERSION@,${PACKAGE_VERSION},g ; \ 49 s,@LIBS@,,g ;' \ 50 ${.ALLSRC} > ${.TARGET} 51 52magic: ${MAGFILES} 53 cat ${.ALLSRC:O} > ${.TARGET} 54 55magic.mgc: magic 56 ${BTOOLSPATH:U.}/mkmagic magic 57 58.if ${MACHINE} == "host" || ${MK_DIRDEPS_BUILD} == "no" 59CLEANFILES+= mkmagic 60DEPENDOBJS+= mkmagic 61build-tools: mkmagic 62mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${INCS} ${BUILD_TOOLS_META} 63 ${CC:N${CCACHE_BIN}} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} \ 64 ${.ALLSRC:N*.h:O:u} ${LDADD} 65 66.endif 67.if ${MK_DIRDEPS_BUILD} == "yes" 68BTOOLSPATH= ${HOST_OBJTOP}/${RELDIR} 69.else 70magic.mgc: mkmagic 71.endif 72 73FILEVER!= awk '$$1 == "\#define" && $$2 == "VERSION" { print $$3; exit }' \ 74 ${.CURDIR}/config.h 75CLEANFILES+= ${MAN} 76.for mp in ${MAN} 77${mp}: ${mp:C/[0-9]/man/} 78 sed -e 's/__FSECTION__/5/g' -e 's/__CSECTION__/1/g' \ 79 -e 's/__VERSION__/${FILEVER}/g' \ 80 -e 's,__MAGIC__,${MAGICPATH}/magic,g' ${.ALLSRC} > ${.TARGET} 81.endfor 82 83CLEANFILES+= ${INCS} 84.for inc in ${INCS} 85${inc}: ${inc}.in 86 sed -e 's,X.YY,${FILEVER:S,",,g:S,.,,g},g' ${.ALLSRC} > ${.TARGET} 87.endfor 88 89PCFILES= libmagic.pc 90 91.include <bsd.lib.mk> 92