put /local/librnd/CFLAGS_HIDLIB_STATIC_ {}
append /local/librnd/CFLAGS_HIDLIB_STATIC_ ?/local/librnd/CFLAGS_HIDLIB_STATIC
put /local/librnd/LDFLAGS_HIDLIB_STATIC_ {}
append /local/librnd/LDFLAGS_HIDLIB_STATIC_ ?/local/librnd/LDFLAGS_HIDLIB_STATIC

append /local/librnd/LDFLAGS_HIDLIB_STATIC_ [@ -lm @?/target/libs/ldl@ @]
if ?libs/script/fungw/presents
then
# system installed fungw
	append /local/librnd/CFLAGS_HIDLIB_STATIC_ libs/script/fungw/cflags
	append /local/librnd/LDFLAGS_HIDLIB_STATIC_ libs/script/fungw/ldflags
end

uniq /local/librnd/CFLAGS_HIDLIB_STATIC_
uniq /local/librnd/LDFLAGS_HIDLIB_STATIC_

gsub /local/librnd/CFLAGS_HIDLIB_STATIC_ {[.][.]/src_3rd/} {$(LIBRND_ROOT)/src_3rd/}

# Lesstif requires that -lXm is before -lXt or else there is a runtime BadWindow error
order /local/librnd/LDFLAGS_HIDLIB_STATIC_ {-lXm} {before} {-lXt}

# non-standard installation prefix requires extra -I and -L
switch /local/prefix
	case {^/usr$} end
	case {^/usr/local$} end
	default
		put /local/librnd/librnd_mak_extra_inc [@-I@/local/prefix@/include@]
		put /local/librnd/librnd_mak_extra_ldf [@-L@/local/prefix@/@/local/libarchdir@@]
	end
end

print [@

#
# Auto-generated Makefile for inclusion for librnd users.
#
# The user's Makefile needs to, in this order:
#  - include this file
#  - use the variables declared in this file for compilation and linking
#

LIBRND_PREFIX=@/local/prefix@
LIBRND_INCDIR=$(LIBRND_PREFIX)/include
LIBRND_LIBARCHDIR=@/local/libarchdir@
LIBRND_LIBDIR=$(LIBRND_PREFIX)/$(LIBRND_LIBARCHDIR)

CFLAGS_LIBRND=@?/local/librnd/CFLAGS_HIDLIB_STATIC_@ -I$(LIBRND_INCDIR) -I$(LIBRND_INCDIR)/librnd/src_3rd @?/local/librnd/librnd_mak_extra_inc@
LDFLAGS_LIBRND=@?/local/librnd/librnd_mak_extra_ldf@ @?/local/librnd/LDFLAGS_HIDLIB_STATIC_@
PUPLUG=$(LIBRND_LIBDIR)/librnd3/puplug

# These are extracts of the fungw-specific parts; only needed if the the above
# are NOT used (partial linking)
@]
if ?libs/script/fungw/presents
then
print [@
CFLAGS_LIBRND_FUNGW=@libs/script/fungw/cflags@
LDFLAGS_LIBRND_FUNGW=@libs/script/fungw/ldflags@
@]
else
print [@
CFLAGS_LIBRND_FUNGW=
LDFLAGS_LIBRND_FUNGW=
@]
end


print [@
LIBRND_EXE=@/target/sys/ext_exe@
@]
