OBJLIST = calibr.o rdtsc.o proc_hz.o
LIBHEAD = libdiag.h
LIBTITLE = diag
LIBRARY = lib$(LIBTITLE).a
COPT = -Wall

# PROGLIST = ptid own

PROGLIST = ptid own p2-1 p2-2 s6 sigthr

#all: lib prog p2-1 p2-2 s6 sigthr
all: lib prog

prog:  $(PROGLIST)

ptid:  ptid.c
	$(CC) $(COPT) -lpthread $< -o $@

own:  own.c
	$(CC) $(COPT) -lpthread $< -o $@

p2-1:  p2-1.c $(LIBHEAD)
	$(CC) $(COPT) $< -lpthread -Bstatic -L./ -l$(LIBTITLE) -o $@

p2-2:  p2-2.c $(LIBHEAD)
	$(CC) $(COPT) $< -lpthread -Bstatic -L./ -l$(LIBTITLE) -o $@

s6:    s6.cc
	$(CXX) $(COPT) $< -lpthread -o $@

sigthr:	sigthr.c
	$(CC) $(COPT) -lpthread $< -o $@

#lib:   proc_hz.c calibr.c rdtsc.c
lib:    proc_hz.o calibr.o rdtsc.o
	ar -t $(LIBRARY)

proc_hz.o:  proc_hz.c $(LIBHEAD)
	$(CC) $(COPT) proc_hz.c -c -o $@
	ar -r $(LIBRARY) $@
	rm $@

calibr.o:  calibr.c $(LIBHEAD)
	$(CC) $(COPT) calibr.c -c -o $@
	ar -r $(LIBRARY) $@
	rm $@

rdtsc.o:  rdtsc.c $(LIBHEAD)
	$(CC) $(COPT) rdtsc.c -c -o $@
	ar -r $(LIBRARY) $@
	rm $@

clean:
	@rm -f *.o .*.cmd .*.flags *.mod.c *.order $(PROGLIST)
	@rm -f .*.*.cmd *.symvers *~ *.*~ TODO.* $(LIBRARY)
	@rm -fR .tmp*
	@rm -rf .tmp_versions

