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 #######################################################################
25 #######################################################################
27 # definitions for new dependencies on suffixes
29 #######################################################################
30 .SUFFIXES: .lo .o .la .a
32 #######################################################################
34 # define static and dynamic objects for the libraries,
35 # along with a number of other useful definitions.
37 #######################################################################
38 STATIC_OBJS = $(SRCS:.c=.o)
39 DYNAMIC_OBJS = $(SRCS:.c=.lo)
40 CFLAGS += -I../.. -I../../../../include
42 #######################################################################
44 # Ensure that the modules get re-built if the server header files
47 #######################################################################
48 SERVER_HEADERS = ../../rlm_sql.h
49 $(STATIC_OBJS): $(SERVER_HEADERS)
50 $(DYNAMIC_OBJS): $(SERVER_HEADERS)
52 #######################################################################
56 #######################################################################
58 $(CC) $(CFLAGS) $(RLM_SQL_CFLAGS) -c $< -o $@
61 $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(RLM_SQL_CFLAGS) -c $<
64 #######################################################################
66 # Define a number of new targets
68 #######################################################################
69 $(TARGET).a: $(STATIC_OBJS)
70 $(LIBTOOL) --mode=link $(LD) -module -static $(CFLAGS) $(RLM_SQL_CFLAGS) $^ -o $@
73 # If the module is in the list of static modules, then the "dynamic"
74 # library is built statically, so that the '.la' file contains the
75 # libraries that the module depends on.
77 # Yes, this is a horrible hack.
79 ifeq ($(findstring $(TARGET),$(STATIC_MODULES)),)
80 LINK_MODE=-export-dynamic
86 # Also, if we're NOT using shared libraries, then force the
87 # link mode to static.
89 ifneq ($(USE_SHARED_LIBS),yes)
93 $(TARGET).la: $(DYNAMIC_OBJS)
94 $(LIBTOOL) --mode=link $(CC) -release $(RADIUSD_VERSION) \
95 -module $(LINK_MODE) $(CFLAGS) \
96 $(RLM_SQL_CFLAGS) -o $@ -rpath $(libdir) $^ $(RLM_SQL_LIBS)
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 #######################################################################
110 dynamic: $(TARGET).la
113 #######################################################################
115 # It's a dummy target: don't build it
117 #######################################################################
126 #######################################################################
128 # clean and install rules
130 #######################################################################
132 @rm -f *.a *.o *.lo *.la *~
134 @rm -f config.log config.status config.cache
137 @rm -f config.h config.mak
140 @[ "x$(AUTOCONF)" != "x" ] && [ -f ./configure.in ] && $(AUTOCONF) -l $(RLM_DIR)../../..
143 # Do any module-specific installation.
145 # If there isn't a TARGET defined, then don't do anything.
146 # Otherwise, install the libraries into $(libdir)
149 [ "x$(TARGET)" = "x" ] || $(LIBTOOL) --mode=install $(INSTALL) -c $(TARGET).la $(R)$(libdir)/$(TARGET).la