summaryrefslogtreecommitdiff
path: root/local/mib2c-conf.d/mfd-makefile.m2m
blob: c41d5bbb55be0ef403c1bd72b4af3af4d8a4c14f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
####################################################### -*- Makefile -*-
## $Id$
##
########################################################################
##
@strict token off@
@ifconf ${name}_Makefile@
@   print ${name}_Makefile exists, skipping@
@else@
@   if "x$m2c_create_fewer_files" eq "x"@
@      eval $m2c_create_fewer_files = 0@
@   end@
@   open ${name}_Makefile@
@   ifconf ${name}_Makefile.m2m@
@      include ${name}_Makefile.m2m@
@   else@
########################################################################
@      if $m2c_mark_boundary == 1@
# START code generated by $RCSfile$ $Revision$
@      end@
########################################################################

CC=gcc
TABLE_PREFIX=${name}

@      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@
	$(TABLE_PREFIX)_data_get.c \
	$(TABLE_PREFIX)_data_set.c \
@      end@
	$(TABLE_PREFIX)_data_access.c

SRCS = $(USER_SRCS) \
	$(TABLE_PREFIX).c \
	$(TABLE_PREFIX)_subagent.c \
	$(TABLE_PREFIX)_interface.c

USER_OBJS =  \
@      if $m2c_create_fewer_files != 1@
	$(TABLE_PREFIX)_data_get.o \
	$(TABLE_PREFIX)_data_set.o \
@      end@
	$(TABLE_PREFIX)_data_access.o 

OBJS =  $(USER_OBJS) \
	$(TABLE_PREFIX).o \
	$(TABLE_PREFIX)_subagent.o \
	$(TABLE_PREFIX)_interface.o

TARGETS=$(TABLE_PREFIX)

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


all: $(TARGETS)

user: $(USER_OBJS)

$(TARGETS): $(LIB_DEPS)

$(TABLE_PREFIX): $(OBJS) $(TABLE_PREFIX)_Makefile
	$(CC) -o $(TABLE_PREFIX) $(OBJS) $(LIBS)

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

@if "$mfd_netsnmp_dir" ne ""@

$(TABLE_PREFIX).deps $(TABLE_PREFIX)_subagent.deps $(TABLE_PREFIX)_interface.deps: $(TABLE_PREFIX)_Makefile
$(TABLE_PREFIX)_data_access.deps:                                  $(TABLE_PREFIX)_Makefile
@if $m2c_create_fewer_files != 1@
$(TABLE_PREFIX)_data_get.deps:                                     $(TABLE_PREFIX)_Makefile
$(TABLE_PREFIX)_data_set.deps:                                     $(TABLE_PREFIX)_Makefile
@end@

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

include $(TABLE_PREFIX).deps
include $(TABLE_PREFIX)_subagent.deps
include $(TABLE_PREFIX)_interface.deps
include $(TABLE_PREFIX)_data_access.deps
@      if $m2c_create_fewer_files != 1@
include $(TABLE_PREFIX)_data_get.deps
include $(TABLE_PREFIX)_data_set.deps
@      end@
@end@
########################################################################
@      if $m2c_mark_boundary == 1@
# END code generated by $RCSfile$ $Revision$
@      end@
@   end@ # not including ${name}_Makefile.m2m
@   close ${name}_Makefile@
@end@ # no existing makefile