diff options
Diffstat (limited to 'documentation/libelf-by-example/Makefile')
| -rw-r--r-- | documentation/libelf-by-example/Makefile | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/documentation/libelf-by-example/Makefile b/documentation/libelf-by-example/Makefile index de663031fca8..a25492c69d68 100644 --- a/documentation/libelf-by-example/Makefile +++ b/documentation/libelf-by-example/Makefile @@ -1,7 +1,7 @@ # # Libelf by Example # -# $Id: Makefile 2441 2012-02-21 05:46:43Z jkoshy $ +# $Id: Makefile 3600 2018-04-12 06:45:40Z jkoshy $ TOP = ../.. @@ -10,19 +10,30 @@ DOC= libelf-by-example SRCS= libelf-by-example.tex prog1.txt prog2.txt prog3.txt \ prog4.txt prog5.txt prog6.txt +CLEANFILES+= ${SRCS:Mprog*:S/.txt/.c/} + .include "${TOP}/mk/elftoolchain.tex.mk" .if ${OS_HOST} == "Linux" +EXTRA_FLAGS= -I/usr/include/bsd -DLIBBSD_OVERLAY EXTRA_LIBS= -lbsd .endif check-example-syntax: .PHONY -.for f in ${SRCS:Mprog*} - @c=$$(basename ${f} .txt).c; sed -e 's/@[^@]*@//' \ - ${.CURDIR}/${f} > ${.OBJDIR}/$${c}; \ - echo -n $${c} ' '; cc -I${.CURDIR}/${TOP}/common \ - -I${.CURDIR}/${TOP}/libelf ${.OBJDIR}/$${c} \ - -L${.CURDIR}/${TOP}/libelf -lelf ${EXTRA_LIBS} && \ - rm ${.OBJDIR}/$${c} a.out +.for f in ${SRCS:Mprog*:S/.txt//} + @sed -e 's/@[^@]*@//' \ + ${.CURDIR}/${f}.txt > ${.OBJDIR}/${f}.c; \ + echo -n ${f} ' '; \ + libelf="${.OBJDIR}/${TOP}/libelf"; \ + if [ ! -d $${libelf} -a "${.CURDIR}" != "${.OBJDIR}" ]; then \ + suffix="${.OBJDIR:S,${.CURDIR}/,,}"; \ + libelf="${.CURDIR}/${TOP}/libelf/$${suffix}"; \ + fi; \ + cc -I${.CURDIR}/${TOP}/common \ + -I${.CURDIR}/${TOP}/libelf \ + ${EXTRA_FLAGS} \ + ${.OBJDIR}/${f}.c \ + -L"$${libelf}" -lelf ${EXTRA_LIBS} && \ + rm ${.OBJDIR}/a.out .endfor @echo |
