AUTOMAKE_OPTIONS = foreign
CLEANFILES = core.* *.bino

REF = default_crontab.txt usage.txt

SRCS = \
	opt.c \
	parse.c \
	scrontab.c \
	scrontab.h

AM_CPPFLAGS = -I$(top_srcdir)
BIN_REF = $(REF:.txt=.bino)

bin_PROGRAMS = scrontab

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

libscrontab_ref.lo: $(BIN_REF)
	$(AM_V_at)echo "# $@ - a libtool object file" >"$@"
	$(AM_V_at)echo "# Generated by $(shell @LIBTOOL@ --version | head -n 1)" >>"$@"
	$(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 >>"$@"

noinst_LTLIBRARIES = libscrontab_ref.la
libscrontab_ref_la_SOURCES =
scrontab_SOURCES = $(SRCS)
convenience_libs = $(LIB_SLURM) $(DL_LIBS)
scrontab_DEPENDENCIES = $(LIB_SLURM_BUILD) libscrontab_ref.la
scrontab_LDFLAGS = -export-dynamic $(CMD_LDFLAGS)

libscrontab_ref_la_LIBADD = libscrontab_ref.lo
scrontab_LDADD = \
	$(convenience_libs) \
	libscrontab_ref.la

force:
$(convenience_libs) : force
	@cd `dirname $@` && $(MAKE) `basename $@`
