ifndef prefix
    export prefix=$(shell cd ../..;pwd)
endif

TARGET_STATIC  = libpslib.a
include ../Makefile.Globals
CFLAGS := $(CFLAGS_RELOC) -I. -I../sysUtils -I../collections -I..

SRC_OBJS = psStats.o  \
           psFunctions.o \
           psMinimize.o \
           psMatrix.o

all: $(TARGET_STATIC)

%.o:	%.c
	@echo "    Compiling $<. "
	$(CC) $(CFLAGS)  -c $< -o $@

libpslib.a:	$(SRC_OBJS)
# The ar option -r is to add/replace object and -s is to create
# a symbol table in the archive
	$(AR) rcs ../$@ $(SRC_OBJS)

# Define PHONY target "install" which will install necessary files
install: $(TARGET_STATIC) 
	install *.h $(includedir)

# Define PHONY target "distclean" which will cleanup the distribution
distclean:	clean
	$(RM) ../$(TARGET_STATIC)

# Define PHONY target "clean" which will cleanup the development area
clean:
	@echo "    Deleting intermediate files for 'sysUtils'"
	$(RM) $(SRC_OBJS) *.lint $(SRC_OBJS:.o=.d*)

%.lint: %.c
	splint +posixlib -exportlocal -realcompare $(INCLUDE_GLOBAL) $? > $@; cat $@

%.d: %.c
	$(CC) -M $(CFLAGS) $< > $@.tmp
	sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' $@.tmp > $@
	$(RM) -f $@.tmp

include $(SRC_OBJS:.o=.d)
