#!/usr/bin/make -f

CC=gcc 
CFLAGS=-O
LIBS=-lm
#OPTFLAGS=-march=k6
OPTFLAGS=-march=native
RM=/bin/rm -f
LS=/bin/ls
MV=/bin/mv
TIME=/usr/bin/time --portability

all:  	opt normal display

normal: cpu-hog.c
	$(CC) -o cpu-hog $(CFLAGS) $(LIBS) cpu-hog.c
	$(CC) $(CFLAGS) cpu-hog.c -S
	$(MV) cpu-hog.s cpu-hog.normal.s

opt:	cpu-hog.c
	$(CC) -o cpu-hog-opt $(CFLAGS) $(LIBS) cpu-hog.c $(OPTFLAGS)
	$(CC) $(CFLAGS) cpu-hog.c -S $(OPTFLAGS)
	$(MV) cpu-hog.s cpu-hog.opt.s

display: 
	$(LS) -l cpu-hog cpu-hog-opt

run: 	clean all
	$(TIME) ./cpu-hog 
	$(TIME) ./cpu-hog-opt

.PHONY:
clean:	
	$(RM) cpu-hog cpu-hog-opt *~ *.bak

