# vim:noexpandtab:autoindent:tabstop=8:shiftwidth=8:filetype=make:

# this is a "helper" include file. set the following variables, then include
# this file and it will set up all the necessary rules to make static and
# dynamic executables
#
#  binname: the final name of the output executable. (just basename, no dir)
#  binlink: which libsmbios libs to link in. "-lsmbios" is default
#  binextlink: which external libs to link in. 
#  binobjs: any extra .o files to link in. "executable name".o is already added
#           getopts.o is also added as almost all bins should make use of it.
#
# you can add additional things to the _LDFLAGS, etc vars after the include 
# line, if needed.

ifndef binclass
binclass := BASE
endif

$(binclass)_BINS    += $(d)/output/$(binname)
$(binname)_LDFLAGS  :=  $(foreach i,$(binlink),-l$(i)) -lsmbios $(foreach i,$(binextlink),-l$(i))
$(binname)_LIBS     :=  $(d)/$(binname).o $(d)/getopts.o $(foreach i,$(binobjs),$(i).o)
$(binname)_DEPS     :=  $(foreach i,$(binlink),$(call gen_dynlibfilenames,$(i))) $($(binname)_LIBS)
$(binname)_CXXFLAGS := 
$(d)/output/$(binname):  $($(binname)_DEPS) $(call gen_dynlibfilenames,smbios)
	$(call build_dyn_bin)

ifndef bin_skip_static
$(binclass)_BINS_STATIC += $(d)/output/$(binname)S
$(binname)S_LDFLAGS  :=  $(foreach i,$(binlink),-l$(i)) -lsmbios $(foreach i,$(binextlink),-l$(i))
$(binname)S_LIBS     :=  $(d)/$(binname).o $(d)/getopts.o $(foreach i,$(binobjs),$(i).o)
$(binname)S_DEPS     :=  $(foreach i,$(binlink),$(call gen_staticlibfilenames,$(i))) $($(binname)S_LIBS)
$(binname)S_CXXFLAGS := 
$(d)/output/$(binname)S:  $($(binname)S_DEPS) $(call gen_staticlibfilenames,smbios)
	$(call build_static_bin)
endif


-include $(d)/$(binname).d

# clear variables for next user
binclass :=
binname :=
binobjs :=
binlink :=
binextlink :=
bin_skip_static :=



