import from HEAD:
[freeradius.git] / src / modules / rlm_sql / drivers / rules.mak
1 #######################################################################
2 #
3 # $Id$
4 #
5 #  Each module should have a few common defines at the TOP of the
6 # Makefile, and the 'include ../rules.mak'
7 #
8 # e.g.
9 #
10 ##########################
11 # TARGET = rlm_foo
12 # SRCS   = rlm_foo.c other.c
13 #
14 # include ../rules.mak
15 #
16 # CFLAGS += my_c_flags
17 ##########################
18 #
19 # and everything will be automagically built
20 #
21 #######################################################################
22
23 .PHONY: all build-module clean distclean install reconfig
24
25 all: build-module
26
27 #######################################################################
28 #
29 #  definitions for new dependencies on suffixes
30 #
31 #######################################################################
32 .SUFFIXES: .lo .o .la .a
33
34 #######################################################################
35 #
36 # define libtool objects for the libraries,
37 # along with a number of other useful definitions.
38 #
39 #######################################################################
40 LT_OBJS         = $(SRCS:.c=.lo)
41 CFLAGS          += -I../.. -I$(top_builddir)/src/include
42
43 #######################################################################
44 #
45 # Ensure that the modules get re-built if the server header files
46 # change.
47 #
48 #######################################################################
49 SERVER_HEADERS  = ../../rlm_sql.h
50 $(LT_OBJS):  $(SERVER_HEADERS)
51
52 #######################################################################
53 #
54 # define new rules
55 #
56 #######################################################################
57 %.lo: %.c
58         $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(RLM_SQL_CFLAGS) -c $<
59
60 ifneq ($(TARGET),)
61 #######################################################################
62 #
63 # Define a number of new targets
64 #
65 #######################################################################
66
67 #
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.
71 #
72 #  Yes, this is a horrible hack.
73 #
74 ifeq ($(findstring $(TARGET),$(STATIC_MODULES)),)
75 LINK_MODE=-export-dynamic
76 else
77 LINK_MODE=-static
78 endif
79
80 #
81 #  Also, if we're NOT using shared libraries, then force the
82 #  link mode to static.
83 #
84 ifneq ($(USE_SHARED_LIBS),yes)
85 LINK_MODE=-static
86 endif
87
88 #######################################################################
89 #
90 #  Generic targets so we can sweep through all modules
91 # without knowing what their names are.
92 #
93 #  These rules also allow us to copy the '.a' or '.la' up
94 # a level, to the 'src/modules' directory, for general consumption.
95 #
96 #######################################################################
97 build-module: $(TARGET).la
98         @[ -d .libs ] && cp .libs/* ../lib
99         @cp $< ../lib
100
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)
105
106 #######################################################################
107 #
108 #  It's a dummy target: don't build it
109 #
110 #######################################################################
111 else
112 build-module:
113
114 # if $(TARGET) == ""
115 endif
116
117 #######################################################################
118 #
119 #  clean and install rules
120 #
121 #######################################################################
122 clean:
123         @rm -f *.a *.o *.lo *.la *~
124         @rm -rf .libs _libs
125         @rm -f config.log config.status config.cache
126
127 distclean: clean
128         @rm -f config.h config.mak
129
130 reconfig:
131         @[ "x$(AUTOCONF)" != "x" ] && [ -f ./configure.in ] && $(AUTOCONF) -l $(RLM_DIR)../../..
132
133 #
134 #  Do any module-specific installation.
135 #
136 #  If there isn't a TARGET defined, then don't do anything.
137 #  Otherwise, install the libraries into $(libdir)
138 #
139 install:
140         [ "x$(TARGET)" = "x" ] || $(LIBTOOL) --mode=install $(INSTALL) -c $(TARGET).la $(R)$(libdir)/$(TARGET).la