
srcdir = @srcdir@
top_builddir =  @top_builddir@
abs_top_builddir = @abs_top_builddir@
top_srcdir = @top_srcdir@
abs_top_srcdir = @abs_top_srcdir@
subdir = buffers
builddir = @builddir@

CFLAGS = @CFLAGS@
DEPFLAGS = @DEPFLAGS@
LDFLAGS = @LDFLAGS@
DEFS = @DEFS@
OPTARGS = @OPTARGS@

AR = @AR@
RANLIB = @RANLIB@
CC = @CC@
CCDEP = @CCDEP@
CCLD = $(CC)
LINK = $(CCLD) $(CFLAGS) $(LDFLAGS) ${OPTARGS} -o $@
LEX = @LEX@
AUTOCONF = @AUTOCONF@
DEFS = @DEFS@

INCLUDES = @INCLUDES@
LDADD =
COMPILE = ${CC} ${DEFS} ${INCLUDES} ${CFLAGS} ${OPTARGS}

LIBRARIES = libbuffers

libbuffers_TARGETS = 	gauge \
			gauge_allocate_gauge_buffers \
			gauge_finalize_gauge_buffers \
			gauge_free_unused_gauge_buffers \
			gauge_get_gauge_field \
			gauge_get_gauge_field_array \
			gauge_initialize_gauge_buffers \
			gauge_return_gauge_field \
			gauge_return_gauge_field_array \
			utils_generic_exchange

libbuffers_OBJECTS = $(addsuffix .o, ${libbuffers_TARGETS})

# default rule

all: Makefile dep libbuffers.a

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

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


#include dep rules


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

include ${top_srcdir}/Makefile.global

# rule to compile objects

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


# rule to make libbuffers
libbuffers.a: ${libbuffers_OBJECTS} Makefile
	@rm -f libbuffers.a
	@${AR} cru libbuffers.a $(libbuffers_OBJECTS)
	@$(RANLIB) libbuffers.a
	@cp libbuffers.a ${top_builddir}/lib/libbuffers.a

# rule to generate .d files

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

# rule to make dependencies

dep: ${addsuffix .d, ${libbuffers_TARGETS}}

# rules to clean

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

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

distclean: clean
	rm -f Makefile


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