
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 = operator
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 = liboperator
liboperator_TARGETS = clover_accumulate_deriv clover_deriv clovertm_operators clover_leaf \
  tm_operators_nd tm_operators_nd_32 clover_term clover_invert clover_det \
	clovertm_operators_32

liboperator_STARGETS = Hopping_Matrix_nocom tm_times_Hopping_Matrix Hopping_Matrix Hopping_Matrix_32 Hopping_Matrix_32_nocom \
	tm_operators tm_operators_32 tm_sub_Hopping_Matrix D_psi D_psi_32 Dov_psi Dov_proj

liboperator_OBJECTS = $(addsuffix .o, ${liboperator_TARGETS})
liboperator_SOBJECTS = $(addsuffix .o, ${liboperator_STARGETS})

# default rule

all: Makefile dep liboperator.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,${liboperator_TARGETS})

include ${top_srcdir}/Makefile.global

# rule to compile objects
${liboperator_OBJECTS}: %.o: ${srcdir}/%.c %.d Makefile ${abs_top_builddir}/config.h
	$(COMPILE) ${OPTARGS} -c $<

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

# rule to make liboperator
liboperator.a: ${liboperator_OBJECTS} ${liboperator_SOBJECTS} Makefile
	@rm -f liboperator.a
	@${AR} cru liboperator.a ${liboperator_OBJECTS} ${liboperator_SOBJECTS}
	@$(RANLIB) liboperator.a
	@cp liboperator.a ../lib/liboperator.a

# rule to generate .d files
$(addsuffix .d, $(liboperator_TARGETS) ${liboperator_STARGETS}): %.d: ${srcdir}/%.c Makefile
	@${CCDEP} ${DEFS} ${DEPFLAGS} ${INCLUDES} $< > $@

# rule to make dependencies
dep: ${addsuffix .d, ${liboperator_TARGETS} ${liboperator_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/liboperator.a

distclean: clean
	rm -f Makefile

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