
srcdir = @srcdir@
top_builddir =  @top_builddir@
abs_top_builddir = @abs_top_builddir@
top_srcdir = @top_srcdir@
abs_top_srcdir = @abs_top_srcdir@
subdir = io
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@

LEMON_AVAILABLE = @LEMON_AVAILABLE@

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

LIBRARIES = libio

libio_TARGETS = utils_engineering \
		utils_parse_checksum_xml \
		utils_write_message \
		utils_read_message \
		gauge_write_binary \
		gauge_read_binary \
		gauge_read \
		gauge_write \
		utils_write_xlf \
		utils_write_xlf_xml \
		utils_write_ildg_format \
		utils_write_header \
		utils_write_checksum \
		utils_write_inverter_info \
		utils_kill_with_error \
		utils_construct_reader \
		utils_destruct_reader \
		utils_construct_writer \
		utils_destruct_writer \
		utils_close_writer_record \
		utils_close_reader_record \
		utils_write_first_message \
		utils_parse_propagator_type \
		utils_parse_ildgformat_xml \
		params_construct_ildgFormat \
		params_construct_propagatorFormat \
		params_construct_sourceFormat \
		params_construct_xlfInfo \
		params_construct_InverterInfo \
		spinor_write \
		spinor_read \
		spinor_write_binary \
		spinor_read_binary \
		spinor_write_info \
		spinor_write_source_format \
		spinor_write_propagator_format \
		spinor_write_propagator_type \
		utils DML_crc32 dml \
		eospinor_write \
		eospinor_read \
		io_cm \
		deri_write_stdout spinor_write_stdout sw_write_stdout

libio_OBJECTS = $(addsuffix .o, ${libio_TARGETS})

# default rule

all: Makefile dep libio.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,${libio_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 libio
libio.a: ${libio_OBJECTS} Makefile
	@rm -f libio.a
	@${AR} cru libio.a $(libio_OBJECTS)
	@$(RANLIB) libio.a
	@cp libio.a ${top_builddir}/lib/libio.a

# rule to generate .d files

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

# rule to make dependencies

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

# rules to clean

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

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

distclean: clean
	rm -f Makefile


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