# CC = icc
# CFLAGS = -axP -ip -O3 -rcd -xP -I. -I../include
CC = cc
CFLAGS = -O3 -I. -I../include
# -xK: P3
# -xW: P4
# -xN: P4, more effort than -xW
# -xB: Pentium M
# -xP: P4 w SSE3
# on EM64T, default is -xW
# -ip: Enables more interprocedural optimizations for single file compilation.
# -axP: generate both generic & EM64T-specific code


INCDIR = /home2/atsushi/src/g5x/include/
LIBDIR = /home2/atsushi/src/g5x/lib
LIBOBJS = xhibutil.o memmap.o
PLIBOBJS = xhibutilp.o memmap.o
TARGET = libxhib.a libxhibp.a xhibtest

all:	$(TARGET)

libxhib.a:	$(LIBOBJS)
	ar rvu $@ $?
	ranlib $@

libxhibp.a:	$(PLIBOBJS)
	ar rvu $@ $?
	ranlib $@

xhibutilp.o:	xhibutil.c
	$(CC) $(CFLAGS) -c -o $@ -pthread -DTHREAD_SAFE_XHIBLIB xhibutil.c

xhibtest:	$(LIBOBJS) xhibtest.o
	$(CC) -o $@ xhibtest.o $(LIBOBJS) -lm

install:
		cp libxhib.a $(LIBDIR)/libxhib.a
		cp libxhibp.a $(LIBDIR)/libxhibp.a
		cp xhibutil.h $(INCDIR)/xhibutil.h

clean:
	rm -f *.o core *~ $(TARGET)

bak:
	-tar cvf xhib.tar ./*.[hc] ./*.pl ./*.csh ./*.awk ./*.template
	-gzip xhib.tar
