blob: 84efdd3a1985e10d26d7a58f5aa010e59ad3251b [file]
# 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)
# Remove partially updated targets on error so a later make does not treat
# them as up to date.
.DELETE_ON_ERROR:
# Embed a .txt blob as a linkable object via objcopy (rather than
# ld --format=binary, which lld and mold do not support).
# -I binary treat input as a raw byte stream
# -O TARGET BFD output format, detected at configure time (OBJCOPY_TARGET)
# -B ARCH set e_machine for objcopy < 2.34; omitted on newer toolchains
# (OBJCOPY_BINARCH, also detected at configure time)
#
# The second objcopy call moves the blob from .data to read-only .rodata
# and injects an empty .note.GNU-stack so the linker does not mark the
# stack executable.
%.bino: %.txt
$(AM_V_GEN)curr_dir=$(shell pwd) && cd $(abs_srcdir) && @OBJCOPY@ -I binary -O @OBJCOPY_TARGET@ @OBJCOPY_BINARCH@ "$(notdir $<)" "$(abs_builddir)/$*.bino" && cd $$curr_dir
$(AM_V_at)@OBJCOPY@ --rename-section .data=.rodata,alloc,load,readonly,data,contents --add-section .note.GNU-stack=/dev/null "$*.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