# This is common code for a Makefile.am and creates $(LIB_REF) to be used
# afterwards in noinst_LTLIBRARIES and EXTRA_slurmrestd_DEPENDENCIES
#
# usage
#
# REF = usage.txt
# include $(top_srcdir)/make_ref.include
# noinst_LTLIBRARIES [+]= $(LIB_REF)
# EXTRA_$PROGRAMNAME_DEPENDENCIES [+]= $(LIB_REF)
# $PROGRAMNAME_LDADD += $(LIB_REF)
#
# What the above lines do is include this file in a Makefile.am
# It will insert usage.txt as a variable that the calling program can access
# with the calls in src/common/ref.h.
#
# If I where doing this for the slurmrestd I would put 'slurmrestd' in for
# $PROGRAMNAME i.e. EXTRA_slurmrestd_DEPENDENCIES, slurmrestd_LDADD.


CLEANFILES = *.bino

BIN_REF = $(REF:.txt=.bino)

%.bino: %.txt
	$(AM_V_GEN)curr_dir=$(shell pwd); cd $(abs_srcdir); $(LD) -r $(LD_EMULATION) -o "$(abs_builddir)/$*.bino" -z noexecstack --format=binary "$(notdir $<)"; cd $$curr_dir
	$(AM_V_at)@OBJCOPY@ --rename-section .data=.rodata,alloc,load,readonly,data,contents "$*.bino"

lib_ref.lo: $(BIN_REF)
	$(AM_V_at)echo "# $@ - a libtool object file" >"$@"
	$(AM_V_at)echo "# Generated by libtool" >>"$@"
	$(AM_V_at)echo "# (Not really... but we need libtool to believe it was.)" >>"$@"
	$(AM_V_at)echo "#" >>"$@"
	$(AM_V_at)echo "# Please DO NOT delete this file!" >>"$@"
	$(AM_V_at)echo "# It is necessary for linking the library." >>"$@"
	$(AM_V_at)echo >>"$@"
	$(AM_V_at)echo "# Name of the PIC object." >>"$@"
	$(AM_V_at)echo "pic_object='$(BIN_REF)'" >>"$@"
	$(AM_V_at)echo >>"$@"
	$(AM_V_at)echo "# Name of the non-PIC object" >>"$@"
	$(AM_V_at)echo "non_pic_object=''" >>"$@"
	$(AM_V_at)echo >>"$@"

LIB_REF = lib_ref.la

# a blank lib_ref_la_SOURCES is needed for 'make cscope' to work correctly.
lib_ref_la_SOURCES =
lib_ref_la_LIBADD = lib_ref.lo
