#!/usr/bin/make -f
# file: hpav/Makefile

# ====================================================================
# environment definitions;
# --------------------------------------------------------------------

include ../make.def

# ====================================================================
# symbols;
# --------------------------------------------------------------------

CFLAGS=-Wall -DMAKEFILE -D__GETOPT_H__ -D_GETOPT_DEFINED_
LFLAGS=
VPATH=../tools:../ether:../mme:../int6k:../nvm
TRASH=*.o *.obj *.exe t t.* *~ *.[0-9][0-9][0-9]
FILES=Makefile *.mak *.sh *.txt *.c *.h *.xml *.css
TOOLS=amptest   
PAGES=amptest.7

# ====================================================================
# targets;
# --------------------------------------------------------------------

.PHONY: all compile compact install scripts manuals uninstall library clean fresh

# ====================================================================
# targets;
# --------------------------------------------------------------------

all compile: ${TOOLS}
compact: compile
	if [ ! -z ${STRIP} ]; then ${STRIP} ${TOOLS}; fi
	if [ -x /usr/local/bin/upx ]; then upx --best ${TOOLS}; fi
library:
	su root -c "install -m 0755 -o ${OWNER} -g ${GROUP} -d ${BIN}"
scripts:
manuals:
	su root -c "install -m 0444 -o ${OWNER} -g ${GROUP} ${PAGES} ${MAN}"
install: compile library
	su root -c "install -m 4555 -o ${OWNER} -g ${GROUP} -s ${TOOLS} ${BIN}"
uninstall:
	su root -c "cd ${BIN}; rm -f ${TOOLS}"
	su root -c "cd ${MAN}; rm -f ${PAGES}"
clean:
	rm -f ${TRASH} ${TOOLS}
fresh: clean compile
%.o: %.c
	${CC} ${CFLAGS} -c ${<} 
%: %.o
	${CC} ${LFLAGS} -o ${@} ${^} 

# ====================================================================
# programs; 
# --------------------------------------------------------------------

amptest: amptest.o getoptv.o putoptv.o version.o error.o channel.o openchannel.o closechannel.o sendpacket.o readpacket.o UnwantedPacket.o FirmwarePacket.o ARPCPrint.o SendMME.o EthernetHeader.o IntellonHeader.o uintspec.o Failure.o Confirm.o todigit.o hexdump.o MMECode.o filepart.o nvmfile.o Request.o WriteMEM.o hexdecode.o checksum_32.o fdchecksum_32.o WaitForStop.o WaitForStart.o

# ====================================================================
# includes; 
# --------------------------------------------------------------------

include ../tools/tools.mak
include ../int6k/int6k.mak
include ../crypt/crypt.mak
include ../mme/mme.mak
include ../nvm/nvm.mak

