
srcdir = .
top_builddir =  ..
abs_top_builddir = /home/jacob/Job/Prace/kernel_D_soft/kernel_D_update2
top_srcdir = ..
abs_top_srcdir = /home/jacob/Job/Prace/kernel_D_soft/kernel_D_update2
subdir = linalg
builddir = .

CFLAGS = -std=c99 -fopenmp  -pedantic -Wall
DEPFLAGS = -MM
LDFLAGS =  -L${HOME}/lib -L${top_builddir}/lib 
DEFS = -DHAVE_CONFIG_H
OPTARGS = -O
SOPTARGS = -O

AR = ar
RANLIB = ranlib
CC = mpicc
CCDEP = gcc
CCLD = ${CC}
LINK = ${CCLD} ${CFLAGS} ${LDFLAGS} ${OPTARGS} -o $@
LEX = flex
AUTOCONF = autoconf
DEFS = -DHAVE_CONFIG_H

INCLUDES =  -I$(HOME)/include/ -I. -I${abs_top_builddir}/  -I${abs_top_srcdir}/ -I/include/ -I/include/
LDADD =
#COMPILE = ${CC} ${DEFS} ${INCLUDES} ${CFLAGS}
COMPILE = ${CC} $(DEFS) ${INCLUDES} ${CFLAGS}

LIBRARIES = liblinalg
liblinalg_TARGETS = assign_add_mul_r_add_mul \
	assign_mul_bra_add_mul_ket_add_r \
	scalar_prod_r scalar_prod_i \
	square_and_prod_r assign_mul_bra_add_mul_r mul_r mul_r_32 \
	diff_and_square_norm assign \
	scalar_prod mul_diff_r mul_diff_mul assign_add_mul assign_mul_add add \
	assign_diff_mul mul_add_mul mul assign_add_mul_add_mul \
	assign_mul_bra_add_mul_ket_add assign_mul_add_mul_add_mul_add_mul_r \
	mul_diff_mul_r assign_add_mul_add_mul_r \
        comp_decomp \
	convert_eo_to_lexic assign_mul_add_mul_r assign_mul_add_mul_r_32 \
	mul_add_mul_r assign_mul_add_mul_add_mul_r mattimesvec \
	scalar_prod_su3spinor \
	assign_mul_add_r_and_square \
	addto_32 scalar_prod_r_32 assign_mul_add_r_32 assign_add_mul_r_32 \
	square_norm_32 assign_to_32 diff_32

liblinalg_STARGETS = diff assign_add_mul_r assign_mul_add_r square_norm

liblinalg_OBJECTS = $(addsuffix .o, ${liblinalg_TARGETS})
liblinalg_SOBJECTS = $(addsuffix .o, ${liblinalg_STARGETS})

# default rule

all: Makefile dep liblinalg.a

# rules for debugging
debug all-debug: CFLAGS := $(CFLAGS) -g
debug all-debug: all

# rules for profiling information
profile all-profile: CFLAGS := $(filter-out -fomit-frame-pointer,${CFLAGS}) 
profile all-profile: all


#include dep rules

-include $(addsuffix .d,${liblinalg_TARGETS})

include ${top_srcdir}/Makefile.global

# rule to compile objects

${liblinalg_OBJECTS}: %.o: ${srcdir}/%.c %.d Makefile ${abs_top_builddir}/config.h
	$(COMPILE) ${OPTARGS} -c $<

${liblinalg_SOBJECTS}: %.o: ${srcdir}/%.c %.d Makefile ${abs_top_builddir}/config.h
	$(COMPILE) ${SOPTARGS} -c $<

# rule to make liblinalg

liblinalg.a: ${liblinalg_OBJECTS} ${liblinalg_SOBJECTS} Makefile
	@rm -f liblinalg.a
	@${AR} cru liblinalg.a ${liblinalg_OBJECTS} ${liblinalg_SOBJECTS}
	@$(RANLIB) liblinalg.a
	@cp liblinalg.a ../lib/liblinalg.a

# rule to generate .d files

$(addsuffix .d, $(liblinalg_TARGETS) ${liblinalg_STARGETS}): %.d: ${srcdir}/%.c Makefile
	@${CCDEP} ${DEFS} ${DEPFLAGS} ${INCLUDES} $< > $@

# rule to make dependencies

dep: ${addsuffix .d, ${liblinalg_TARGETS} ${liblinalg_STARGETS}}

# rules to clean

compile-clean: Makefile
	rm -f ${$(addsuffix _OBJECTS, ${LIBRARIES})} ${$(addsuffix _SOBJECTS, ${LIBRARIES})} *.d

clean: compile-clean 
	rm -f $(addsuffix .a, ${LIBRARIES})
	rm -f ../lib/liblinalg.a

distclean: clean
	rm -f Makefile

.PHONY: all dep clean compile-clean distclean profile all-profile debug all-debug
