1 #######################################################################
5 # Each module should have a few common defines at the TOP of the
6 # Makefile, and the 'include ../rules.mak'
10 ##########################
12 # SRCS = rlm_foo.c other.c
14 # include ../rules.mak
16 # RLM_CFLAGS = my_cflags
17 # RLM_LDLAGS = my_ldflags
18 ##########################
20 # and everything will be automagically built
22 #######################################################################
24 include $(RLM_DIR)../../../Make.inc
28 #######################################################################
30 # definitions for new dependencies on suffixes
32 #######################################################################
33 .SUFFIXES: .lo .o .la .a
35 #######################################################################
37 # define static and dynamic objects for the libraries,
38 # along with a number of other useful definitions.
40 #######################################################################
41 STATIC_OBJS += $(SRCS:.c=.o)
42 STATIC_OBJS += $(SRCS:.cpp=.o)
43 DYNAMIC_OBJS += $(SRCS:.c=.lo)
44 DYNAMIC_OBJS += $(SRCS:.cpp=.lo)
45 CFLAGS += -I$(top_builddir)/src
47 #######################################################################
49 # Ensure that the modules get re-built if the server header files
52 #######################################################################
53 SERVER_HEADERS = $(RLM_DIR)../../include/radiusd.h $(RLM_DIR)../../include/radius.h $(RLM_DIR)../../include/modules.h
54 $(STATIC_OBJS): $(SERVER_HEADERS)
55 $(DYNAMIC_OBJS): $(SERVER_HEADERS)
57 #######################################################################
61 #######################################################################
63 $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(RLM_CFLAGS) -c $< -o $@
66 $(LIBTOOL) --mode=compile $(CXX) $(CFLAGS) $(RLM_CFLAGS) -c $< -o $@
69 $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(RLM_CFLAGS) -c $<
72 $(LIBTOOL) --mode=compile $(CXX) $(CFLAGS) $(RLM_CFLAGS) -c $<
75 #######################################################################
77 # Define a number of new targets
79 #######################################################################
82 # If the module is in the list of static modules, then the "dynamic"
83 # library is built statically, so that the '.la' file contains the
84 # libraries that the module depends on.
86 # Yes, this is a horrible hack.
88 ifeq ($(findstring $(TARGET),$(STATIC_MODULES)),)
89 LINK_MODE +=-export-dynamic
95 # Also, if we're NOT using shared libraries, then force the
96 # link mode to static.
98 ifneq ($(USE_SHARED_LIBS),yes)
102 $(TARGET).la: $(DYNAMIC_OBJS)
103 $(LIBTOOL) --mode=link $(CC) -release $(RADIUSD_VERSION) \
104 -module $(LINK_MODE) $(LDFLAGS) $(RLM_LDFLAGS) \
105 -o $@ -rpath $(libdir) $^ $(RLM_DIR)../../lib/libradius.la \
108 #######################################################################
110 # Generic targets so we can sweep through all modules
111 # without knowing what their names are.
113 # These rules also allow us to copy the '.a' or '.la' up
114 # a level, to the 'src/modules' directory, for general consumption.
116 #######################################################################
117 #static: $(TARGET).a $(RLM_UTILS)
118 # @[ "x$(RLM_SUBDIRS)" = "x" ] || $(MAKE) $(MFLAGS) WHAT_TO_MAKE=static common
119 # @cp $< $(top_builddir)/src/modules/lib
122 dynamic: $(TARGET).la $(RLM_UTILS)
123 @[ "x$(RLM_SUBDIRS)" = "x" ] || $(MAKE) $(MFLAGS) WHAT_TO_MAKE=dynamic common
124 @[ -d .libs ] && cp .libs/* $(top_builddir)/src/modules/lib
125 @cp $< $(top_builddir)/src/modules/lib
127 #######################################################################
129 # It's a dummy target: don't build it
131 #######################################################################
140 #######################################################################
142 # clean and install rules
144 #######################################################################
146 @rm -f *.a *.o *.lo *.la *~
148 @rm -f config.cache config.log config.status $(RLM_UTILS)
149 @[ "x$(RLM_SUBDIRS)" = "x" ] || $(MAKE) $(MFLAGS) WHAT_TO_MAKE=clean common
152 @rm -f config.h config.mak
153 @test -f Makefile.in && rm -f Makefile
156 @[ "x$(AUTOCONF)" != "x" ] && [ -f ./configure.in ] && $(AUTOCONF) -I $(RLM_DIR)../../..
157 @[ "x$(AUTOHEADER)" != "x" ] && [ -f ./configure.in ] && \
158 if grep AC_CONFIG_HEADERS configure.in >/dev/null; then\
163 # Do any module-specific installation.
165 # If there isn't a TARGET defined, then don't do anything.
166 # Otherwise, install the libraries into $(libdir)
169 @[ "x$(RLM_INSTALL)" = "x" ] || $(MAKE) $(MFLAGS) $(RLM_INSTALL)
170 if [ "x$(TARGET)" != "x" ]; then \
171 $(LIBTOOL) --mode=install $(INSTALL) -c \
172 $(TARGET).la $(R)$(libdir)/$(TARGET).la || exit $?;\
173 rm -f $(R)$(libdir)/$(TARGET)-$(RADIUSD_VERSION).la || exit %?; \
174 ln -s $(TARGET).la $(R)$(libdir)/$(TARGET)-$(RADIUSD_VERSION).la || exit $?;\