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 # CFLAGS += my_c_flags
17 ##########################
19 # and everything will be automagically built
21 #######################################################################
23 .PHONY: all build-module clean distclean install reconfig
27 #######################################################################
29 # definitions for new dependencies on suffixes
31 #######################################################################
32 .SUFFIXES: .lo .o .la .a
34 #######################################################################
36 # define libtool objects for the libraries,
37 # along with a number of other useful definitions.
39 #######################################################################
40 LT_OBJS = $(SRCS:.c=.lo)
41 CFLAGS += -I../.. -I$(top_builddir)/src/include
43 #######################################################################
45 # Ensure that the modules get re-built if the server header files
48 #######################################################################
49 SERVER_HEADERS = ../../rlm_sql.h
50 $(LT_OBJS): $(SERVER_HEADERS)
52 #######################################################################
56 #######################################################################
58 $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(RLM_SQL_CFLAGS) -c $<
61 #######################################################################
63 # Define a number of new targets
65 #######################################################################
68 # If the module is in the list of static modules, then the "dynamic"
69 # library is built statically, so that the '.la' file contains the
70 # libraries that the module depends on.
72 # Yes, this is a horrible hack.
74 ifeq ($(findstring $(TARGET),$(STATIC_MODULES)),)
75 LINK_MODE=-export-dynamic
81 # Also, if we're NOT using shared libraries, then force the
82 # link mode to static.
84 ifneq ($(USE_SHARED_LIBS),yes)
88 #######################################################################
90 # Generic targets so we can sweep through all modules
91 # without knowing what their names are.
93 # These rules also allow us to copy the '.a' or '.la' up
94 # a level, to the 'src/modules' directory, for general consumption.
96 #######################################################################
97 build-module: $(TARGET).la
98 @[ -d .libs ] && cp .libs/* ../lib
101 $(TARGET).la: $(LT_OBJS)
102 $(LIBTOOL) --mode=link $(CC) -release $(RADIUSD_VERSION) \
103 -module $(LINK_MODE) $(LDFLAGS) $(RLM_SQL_LDFLAGS) -o $@ \
104 -rpath $(libdir) $^ $(RLM_SQL_LIBS)
106 #######################################################################
108 # It's a dummy target: don't build it
110 #######################################################################
117 #######################################################################
119 # clean and install rules
121 #######################################################################
123 @rm -f *.a *.o *.lo *.la *~
125 @rm -f config.log config.status config.cache
128 @rm -f config.h config.mak
131 @[ "x$(AUTOCONF)" != "x" ] && [ -f ./configure.in ] && $(AUTOCONF) -l $(RLM_DIR)../../..
134 # Do any module-specific installation.
136 # If there isn't a TARGET defined, then don't do anything.
137 # Otherwise, install the libraries into $(libdir)
140 [ "x$(TARGET)" = "x" ] || $(LIBTOOL) --mode=install $(INSTALL) -c $(TARGET).la $(R)$(libdir)/$(TARGET).la