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 include ../../../../../Make.inc
27 #######################################################################
29 # definitions for new dependencies on suffixes
31 #######################################################################
32 .SUFFIXES: .lo .o .la .a
34 #######################################################################
36 # define static and dynamic objects for the libraries,
37 # along with a number of other useful definitions.
39 #######################################################################
40 STATIC_OBJS = $(SRCS:.c=.o)
41 DYNAMIC_OBJS = $(SRCS:.c=.lo)
42 CFLAGS += -I../.. -I../../../../include
44 #######################################################################
46 # Ensure that the modules get re-built if the server header files
49 #######################################################################
50 SERVER_HEADERS = ../../rlm_sql.h
51 $(STATIC_OBJS): $(SERVER_HEADERS)
52 $(DYNAMIC_OBJS): $(SERVER_HEADERS)
54 #######################################################################
58 #######################################################################
60 $(CC) $(CFLAGS) $(RLM_SQL_CFLAGS) -c $< -o $@
63 $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(RLM_SQL_CFLAGS) -c $<
66 #######################################################################
68 # Define a number of new targets
70 #######################################################################
71 $(TARGET).a: $(STATIC_OBJS)
72 $(LIBTOOL) --mode=link $(LD) -module -static $(CFLAGS) $(RLM_SQL_CFLAGS) $^ -o $@
75 # If the module is in the list of static modules, then the "dynamic"
76 # library is built statically, so that the '.la' file contains the
77 # libraries that the module depends on.
79 # Yes, this is a horrible hack.
81 ifeq ($(findstring $(TARGET),$(STATIC_MODULES)),)
82 LINK_MODE=-export-dynamic
88 # Also, if we're NOT using shared libraries, then force the
89 # link mode to static.
91 ifneq ($(USE_SHARED_LIBS),yes)
95 $(TARGET).la: $(DYNAMIC_OBJS)
96 $(LIBTOOL) --mode=link $(CC) -module $(LINK_MODE) $(CFLAGS) \
97 $(RLM_SQL_CFLAGS) -o $@ -rpath $(libdir) $^ $(RLM_SQL_LIBS)
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 #######################################################################
111 dynamic: $(TARGET).la
114 #######################################################################
116 # It's a dummy target: don't build it
118 #######################################################################
127 #######################################################################
129 # clean and install rules
131 #######################################################################
133 @rm -f *.a *.o *.lo *.la *~
137 @rm -f config.h config.mak
140 # Do any module-specific installation.
142 # If there isn't a TARGET defined, then don't do anything.
143 # Otherwise, install the libraries into $(libdir)
146 [ "x$(TARGET)" = "x" ] || $(LIBTOOL) --mode=install $(INSTALL) -c $(TARGET).la $(R)$(libdir)/$(TARGET).la