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 62# For the non-dirdeps build, HOST_CC is CC by default 63mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${INCS} ${BUILD_TOOLS_META} 64 ${HOST_CC:N${CCACHE_BIN}} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} \ 65 ${.ALLSRC:N*.h:O:u} ${LDADD} 66 67.endif 68.if ${MK_DIRDEPS_BUILD} == "yes" && ${MACHINE} != "host" 69BTOOLSPATH= ${HOST_OBJTOP}/${RELDIR} 70.else 71magic.mgc: mkmagic 72.endif 73 74FILEVER!= awk '$$1 == "\#define" && $$2 == "VERSION" { print $$3; exit }' \ 75 ${.CURDIR}/config.h 76CLEANFILES+= ${MAN} 77.for mp in ${MAN} 78${mp}: ${mp:C/[0-9]/man/} 79 sed -e 's/__FSECTION__/5/g' -e 's/__CSECTION__/1/g' \ 80 -e 's/__VERSION__/${FILEVER}/g' \ 81 -e 's,__MAGIC__,${MAGICPATH}/magic,g' ${.ALLSRC} > ${.TARGET} 82.endfor 83 84CLEANFILES+= ${INCS} 85.for inc in ${INCS} 86${inc}: ${inc}.in 87 sed -e 's,X.YY,${FILEVER:S,",,g:S,.,,g},g' ${.ALLSRC} > ${.TARGET} 88.endfor 89 90PCFILES= libmagic.pc 91 92.include <bsd.lib.mk> 93