.SUFFICES: .o .c

CC = gcc
CFLAGS = -msupersparc -Wa,-xarch=v8plus -O3

# CC = cc
# CFLAGS = -xarch=v8plus -g

# My version of gdb isn't MP-capable, so I debug using dbx and code
# produced by cc.

CFILES = atomic_ops.c \
	clh_plain.c       \
	clh_plain_numa.c  \
	clh_try.c		  \
	mcs_plain.c		  \
	mcs_try.c		  \
	tas.c			  \
	time_test.c

OFILES = atomic_ops.o \
	clh_plain.o       \
	clh_plain_numa.o  \
	clh_try.o		  \
	mcs_plain.o       \
	mcs_try.o		  \
	tas.o			  \
	time_test.o

HFILES = atomic_ops.h  \
	atomic_op_bodies.h \
	main.h			   \
	tas.h mcs.h clh.h  \
	inline.h

.c.o:
	$(CC) -c $(CFLAGS) $*.c

time_test: $(OFILES) atomic_ops.o
	$(CC) -o time_test $(CFLAGS) \
		$(OFILES) -lpthread

time_test.s: time_test.c
	$(CC) -S -fverbose-asm $(CFLAGS) time_test.c

atomic_ops.o: atomic_ops.c
	gcc -c -g -msupersparc -Wa,-xarch=v8plus atomic_ops.c

test: test.c atomic_ops.o
	gcc -o test -g -msupersparc -Wa,-xarch=v8plus test.c atomic_ops.o

sources:
	@echo $(CFILES) $(HFILES)

clean:
	rm *.o time_test

tags:
	etags $(CFILES) $(HFILES) > TAGS

depend:
	echo '# DO NOT EDIT THIS FILE -- it is automatically generated' \
		> makefile.dep
	echo '' >> makefile.dep
	gcc -M $(CFILES) >> makefile.dep

include makefile.dep
