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 #######################################################################
66 $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(RLM_CFLAGS) -c $<
69 $(LIBTOOL) --mode=compile $(CXX) $(CFLAGS) $(RLM_CFLAGS) -c $<
72 #######################################################################
74 # Define a number of new targets
76 #######################################################################
79 # If the module is in the list of static modules, then the "dynamic"
80 # library is built statically, so that the '.la' file contains the
81 # libraries that the module depends on.
83 # Yes, this is a horrible hack.
85 ifeq ($(findstring $(TARGET),$(STATIC_MODULES)),)
86 LINK_MODE = -export-dynamic
92 # Also, if we're NOT using shared libraries, then force the
93 # link mode to static.
95 ifneq ($(USE_SHARED_LIBS),yes)
99 #######################################################################
101 # Generic targets so we can sweep through all modules
102 # without knowing what their names are.
104 # These rules also allow us to copy the '.a' or '.la' up
105 # a level, to the 'src/modules' directory, for general consumption.
107 #######################################################################
110 # We can't use $(PWD), because that's apparently where the "make"
111 # started. Any child builds (make -C foo) don't change PWD.
115 build-module: $(TARGET).la $(RLM_UTILS)
116 @[ "x$(RLM_SUBDIRS)" = "x" ] || $(MAKE) $(MFLAGS) WHAT_TO_MAKE=all common
117 @[ -d $(top_builddir)/src/modules/lib/.libs ] || mkdir $(top_builddir)/src/modules/lib/.libs
118 for x in .libs/* $^; do \
119 rm -rf $(top_builddir)/src/modules/lib/$$x; \
120 ln -s $(WHERE)/$$x $(top_builddir)/src/modules/lib/$$x; \
123 $(TARGET).la: $(LT_OBJS)
124 $(LIBTOOL) --mode=link $(CC) -release $(RADIUSD_VERSION) \
125 -module $(LINK_MODE) $(LDFLAGS) $(RLM_LDFLAGS) -o $@ \
126 -rpath $(libdir) $^ $(LIBRADIUS) $(RLM_LIBS) $(LIBS)
128 #######################################################################
130 # It's a dummy target: don't build it
132 #######################################################################
139 #######################################################################
141 # clean and install rules
143 #######################################################################
145 @rm -f *.a *.o *.lo *.la *~
147 @rm -f config.cache config.log config.status $(RLM_UTILS)
148 @[ "x$(RLM_SUBDIRS)" = "x" ] || $(MAKE) $(MFLAGS) WHAT_TO_MAKE=clean common
151 @rm -f config.h config.mak
152 @test -f Makefile.in && rm -f Makefile
155 @if [ -f configure.in ]; then \
156 [ "x$(AUTOCONF)" != "x" ] && $(AUTOCONF) -I $(top_builddir); \
158 @[ "x$(AUTOHEADER)" != "x" ] && [ -f ./configure.in ] && \
159 if grep AC_CONFIG_HEADERS configure.in >/dev/null; then\
164 # Do any module-specific installation.
166 # If there isn't a TARGET defined, then don't do anything.
167 # Otherwise, install the libraries into $(libdir)
170 @[ "x$(RLM_INSTALL)" = "x" ] || $(MAKE) $(MFLAGS) $(RLM_INSTALL)
171 if [ "x$(TARGET)" != "x" ]; then \
172 $(LIBTOOL) --mode=install $(INSTALL) -c \
173 $(TARGET).la $(R)$(libdir)/$(TARGET).la || exit $$?; \
174 rm -f $(R)$(libdir)/$(TARGET)-$(RADIUSD_VERSION).la; \
175 ln -s $(TARGET).la $(R)$(libdir)/$(TARGET)-$(RADIUSD_VERSION).la || exit $$?; \
180 @[ "$(SCAN_BUILD)" == "" ] || ($(MAKE) SCAN=yes LIBTOOL= 2>&1) | grep 'scan-view' || true