CFLAGS += -DDEBUG
#---------------
TARGET_MACHINE_ARCH=mips
DESTDIR=~/bin
#---------------
PROG=	gprof
SRCS=	gprof.c arcs.c dfn.c lookup.c machine.c hertz.c printgprof.c \
	printlist.c elf.c
OBJS	+= ${SRCS:.c=.o}
#---------------
CFLAGS+= -I.
CFLAGS += -g -static
LDFLAGS += -static -g

CFLAGS += -Wall
CFLAGS += -Werror
CFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Winline -Waggregate-return
#-----------------------------------------------------------------------------
# all:	beforedepend ${PROG} beforedepend
all:	${PROG}
#---------------
${PROG}: ${OBJS}
#---------------
machine.h machine.c: beforedepend
beforedepend::
	ln -sf ${TARGET_MACHINE_ARCH}.h machine.h
	ln -sf ${TARGET_MACHINE_ARCH}.c machine.c
#---------------
install: ${PROG}
	${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \
	    ${.CURDIR}/gprof.flat ${.CURDIR}/gprof.callg \
	    ${DESTDIR}
	${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 gprof \
	    ${DESTDIR}/${TARGET_MACHINE_ARCH}-gprof
#---------------
clean:
	rm -f *.o ${PROG} machine.h machine.c
#-----------------------------------------------------------------------------
gprof.h: machine.h
arcs.c: gprof.h
dfn.c: gprof.h
elf.c: gprof.h
gprof.c: gprof.h
i386.c: gprof.h
lookup.c: gprof.h
mips.c: gprof.h
printgprof.c: gprof.h
printlist.c: gprof.h
#-----------------------------------------------------------------------------
test:	${PROG} ../../init/ledflash ~/gmon.out
	./${PROG} ../../init/ledflash ~/gmon.out
#	./${PROG} -b ../../init/ledflash ~/gmon.out >A
#-----------------------------------------------------------------------------
