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
26 .PHONY: all build-module clean distclean install reconfig
30 #######################################################################
32 # definitions for new dependencies on suffixes
34 #######################################################################
35 .SUFFIXES: .lo .o .la .a
37 #######################################################################
39 # define libtool objects for the libraries,
40 # along with a number of other useful definitions.
42 #######################################################################
43 LT_OBJS += $(SRCS:.c=.lo)
44 LT_OBJS += $(SRCS:.cpp=.lo)
45 CFLAGS += -I$(top_builddir)/src/include
47 #######################################################################
49 # Ensure that the modules get re-built if the server header files
52 #######################################################################
53 SERVER_HEADERS = $(top_builddir)/src/include/radius.h \
54 $(top_builddir)/src/include/radiusd.h \
55 $(top_builddir)/src/include/modules.h
57 $(LT_OBJS): $(SERVER_HEADERS)
59 #######################################################################
63 #######################################################################
65 $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(RLM_CFLAGS) -c $<
68 $(LIBTOOL) --mode=compile $(CXX) $(CFLAGS) $(RLM_CFLAGS) -c $<
71 #######################################################################
73 # Define a number of new targets
75 #######################################################################
78 # If the module is in the list of static modules, then the "dynamic"
79 # library is built statically, so that the '.la' file contains the
80 # libraries that the module depends on.
82 # Yes, this is a horrible hack.
84 ifeq ($(findstring $(TARGET),$(STATIC_MODULES)),)
85 LINK_MODE = -export-dynamic
91 # Also, if we're NOT using shared libraries, then force the
92 # link mode to static.
94 ifneq ($(USE_SHARED_LIBS),yes)
98 #######################################################################
100 # Generic targets so we can sweep through all modules
101 # without knowing what their names are.
103 # These rules also allow us to copy the '.a' or '.la' up
104 # a level, to the 'src/modules' directory, for general consumption.
106 #######################################################################
108 build-module: $(TARGET).la $(RLM_UTILS)
109 @[ "x$(RLM_SUBDIRS)" = "x" ] || $(MAKE) $(MFLAGS) WHAT_TO_MAKE=all common
110 @[ -d .libs ] && cp .libs/* $(top_builddir)/src/modules/lib
111 @cp $< $(top_builddir)/src/modules/lib
113 $(TARGET).la: $(LT_OBJS)
114 $(LIBTOOL) --mode=link $(CC) -release $(RADIUSD_VERSION) \
115 -module $(LINK_MODE) $(LDFLAGS) $(RLM_LDFLAGS) -o $@ \
116 -rpath $(libdir) $^ $(top_builddir)/src/lib/libradius.la \
119 #######################################################################
121 # It's a dummy target: don't build it
123 #######################################################################
130 #######################################################################
132 # clean and install rules
134 #######################################################################
136 @rm -f *.a *.o *.lo *.la *~
138 @rm -f config.cache config.log config.status $(RLM_UTILS)
139 @[ "x$(RLM_SUBDIRS)" = "x" ] || $(MAKE) $(MFLAGS) WHAT_TO_MAKE=clean common
142 @rm -f config.h config.mak
143 @test -f Makefile.in && rm -f Makefile
146 @if [ -f configure.in ]; then \
147 [ "x$(AUTOCONF)" != "x" ] && $(AUTOCONF) -I $(top_builddir); \
149 @if [ -f config.h.in ]; then \
150 [ "x$(AUTOHEADER)" != "x" ] && $(AUTOHEADER); \
155 # Do any module-specific installation.
157 # If there isn't a TARGET defined, then don't do anything.
158 # Otherwise, install the libraries into $(libdir)
161 @[ "x$(RLM_INSTALL)" = "x" ] || $(MAKE) $(MFLAGS) $(RLM_INSTALL)
162 if [ "x$(TARGET)" != "x" ]; then \
163 $(LIBTOOL) --mode=install $(INSTALL) -c \
164 $(TARGET).la $(R)$(libdir)/$(TARGET).la || exit $$?; \
165 rm -f $(R)$(libdir)/$(TARGET)-$(RADIUSD_VERSION).la; \
166 ln -s $(TARGET).la $(R)$(libdir)/$(TARGET)-$(RADIUSD_VERSION).la || exit $$?; \