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 $(INCLTDL)
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 \
56 $(top_builddir)/src/include/libradius.h
58 $(LT_OBJS): $(SERVER_HEADERS)
60 #######################################################################
64 #######################################################################
68 @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) $(RLM_CFLAGS) -c $<
72 @$(LIBTOOL) --quiet --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 #######################################################################
104 # Generic targets so we can sweep through all modules
105 # without knowing what their names are.
107 # These rules also allow us to copy the '.a' or '.la' up
108 # a level, to the 'src/modules' directory, for general consumption.
110 #######################################################################
113 # We can't use $(PWD), because that's apparently where the "make"
114 # started. Any child builds (make -C foo) don't change PWD.
118 build-module: $(TARGET).la $(RLM_UTILS)
119 @[ -d $(top_builddir)/src/modules/lib/.libs ] || mkdir $(top_builddir)/src/modules/lib/.libs
120 @for x in .libs/* $^; do \
121 rm -rf $(top_builddir)/src/modules/lib/$$x; \
122 ln -s $(WHERE)/$$x $(top_builddir)/src/modules/lib/$$x; \
125 $(TARGET).la: $(RLM_SUBDIRS) $(LT_OBJS)
127 @$(LIBTOOL) --quiet --mode=link $(CC) -release $(RADIUSD_VERSION) \
128 -module $(LINK_MODE) $(LDFLAGS) $(RLM_LDFLAGS) -o $@ \
129 -rpath $(libdir) $^ $(LIBRADIUS) $(RLM_LIBS) $(LIBS)
131 #######################################################################
133 # It's a dummy target: don't build it
135 #######################################################################
142 #######################################################################
144 # clean and install rules
146 #######################################################################
148 @rm -f *.a *.o *.lo *.la *~
150 @rm -f config.cache config.log config.status $(RLM_UTILS)
151 @[ "x$(RLM_SUBDIRS)" = "x" ] || $(MAKE) $(MFLAGS) WHAT_TO_MAKE=clean common
154 @rm -f config.h config.mak
155 @test -f Makefile.in && rm -f Makefile
158 @if [ -f configure.in ]; then \
159 [ "x$(AUTOCONF)" != "x" ] && $(AUTOCONF) -I $(top_builddir); \
161 @[ "x$(AUTOHEADER)" != "x" ] && [ -f ./configure.in ] && \
162 if grep AC_CONFIG_HEADERS configure.in >/dev/null; then\
167 # Do any module-specific installation.
169 # If there isn't a TARGET defined, then don't do anything.
170 # Otherwise, install the libraries into $(libdir)
173 @[ "x$(RLM_INSTALL)" = "x" ] || $(MAKE) $(MFLAGS) $(RLM_INSTALL)
174 if [ "x$(TARGET)" != "x" ]; then \
175 $(LIBTOOL) --mode=install $(INSTALL) -c \
176 $(TARGET).la $(R)$(libdir)/$(TARGET).la || exit $$?; \
177 rm -f $(R)$(libdir)/$(TARGET)-$(RADIUSD_VERSION).la; \
178 ln -s $(TARGET).la $(R)$(libdir)/$(TARGET)-$(RADIUSD_VERSION).la || exit $$?; \
180 ifneq ($(RLM_UTILS),)
181 $(INSTALL) -d -m 755 $(R)$(bindir)
182 for x in $(RLM_UTILS); do \
183 $(LIBTOOL) --mode=install $(INSTALL) -m 755 $(INSTALLSTRIP) $$x$(EXEEXT) $(R)$(bindir); \