####################################################### -*- Makefile -*-
## $Id: mfd-makefile.m2m,v 1.11 2004/03/29 23:39:53 rstory Exp $
##
########################################################################
@if $m2c_mark_boundary == 1@
# START code generated by $RCSfile: mfd-makefile.m2m,v $ $Revision: 1.11 $
@end@
########################################################################
##
@strict token off@
@open ${name}_Makefile@
@ifconf ${name}_Makefile.m2m@
@   include ${name}_Makefile.m2m@
@else@
CC=gcc

@if "$mfd_netsnmp_dir" ne ""@
NETSNMPDIR=$mfd_netsnmp_dir
NETSNMPCONFIG=$(NETSNMPDIR)/net-snmp-config
@else@
NETSNMPCONFIG=net-snmp-config
@end@

@if "$mfd_netsnmp_dir" ne ""@

# Assuming we're linking against a Net-SNMP build tree (which may or
# may not be the same as the source tree) and not an installed package.

# Note: to do this we REQUIRE gnu-make.

NETSNMPBASECFLAGS := $(shell $(NETSNMPCONFIG) --base-cflags)
NETSNMPINCLUDES := $(shell $(NETSNMPCONFIG) --build-includes $(NETSNMPDIR))
# base flags after build/src include, in case it has /usr/local/include
NETSNMPCFLAGS=$(NETSNMPINCLUDES) $(NETSNMPBASECFLAGS)

NETSNMPBASELIBS := $(shell $(NETSNMPCONFIG) --base-agent-libs)
NETSNMPEXTLIBS := $(shell $(NETSNMPCONFIG) --external-agent-libs)
NETSNMPLIBDIRS := $(shell $(NETSNMPCONFIG) --build-lib-dirs $(NETSNMPDIR))
NETSNMPLIBDEPS := $(shell $(NETSNMPCONFIG) --build-lib-deps $(NETSNMPDIR))
LIB_DEPS=$(NETSNMPLIBDEPS)
LIBS=$(NETSNMPLIBDIRS) -Wl,-Bstatic $(NETSNMPBASELIBS) -Wl,-Bdynamic $(NETSNMPEXTLIBS)

@else@

# uncomment this if you have GNU make
#NETSNMPCFLAGS := $(shell $(NETSNMPCONFIG) --base-cflags)
#NETSNMPLIBS := $(shell $(NETSNMPCONFIG) --agent-libs)
NETSNMPCFLAGS=`$(NETSNMPCONFIG) --base-cflags`
NETSNMPLIBS=`$(NETSNMPCONFIG) --agent-libs`

LIBS=$(NETSNMPLIBS)

@end@

STRICT_FLAGS = -Wall -Wstrict-prototypes
CFLAGS=-I. $(NETSNMPCFLAGS) $(STRICT_FLAGS)

USER_SRCS = \
@if $m2c_create_fewer_files != 1@
	${name}_data_get.c \
	${name}_data_set.c \
@end@
	${name}_data_access.c

SRCS = $(USER_SRCS) \
	${name}.c \
	${name}_subagent.c \
	${name}_interface.c

USER_OBJS =  \
@if $m2c_create_fewer_files != 1@
	${name}_data_get.o \
	${name}_data_set.o \
@end@
	${name}_data_access.o 

OBJS =  $(USER_OBJS) \
	${name}.o \
	${name}_subagent.o \
	${name}_interface.o

TARGETS=${name}

.SUFFIXES:
.SUFFIXES: .c .o .deps


all: $(TARGETS)

user: $(USER_OBJS)

$(TARGETS): $(LIB_DEPS)

${name}: $(OBJS) ${name}_Makefile
	$(CC) -o ${name} $(OBJS) $(LIBS)

clean:
	rm -f $(OBJS) $(TARGETS)

@if "$mfd_netsnmp_dir" ne ""@

${name}.deps ${name}_subagent.deps ${name}_interface.deps: ${name}_Makefile
${name}_data_access.deps:                                  ${name}_Makefile
@if $m2c_create_fewer_files != 1@
${name}_data_get.deps:                                     ${name}_Makefile
${name}_data_set.deps:                                     ${name}_Makefile
@end@

%.deps : %.c
	@echo "Generating makefile $@ ..."
	@set -e; $(CC) -M $(COPTS) $(CFLAGS) $(CPPFLAGS) $< \
	| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
	[ -s $@ ] || $(RM) $(RMFLAGS) $@

include ${name}.deps
include ${name}_subagent.deps
include ${name}_interface.deps
include ${name}_data_access.deps
@if $m2c_create_fewer_files != 1@
include ${name}_data_get.deps
include ${name}_data_set.deps
@end@
@end@


@end@
########################################################################
@if $m2c_mark_boundary == 1@
# END code generated by $RCSfile: mfd-makefile.m2m,v $ $Revision: 1.11 $
@end@
