]> git.stg.codes - stg.git/blob - projects/rlm_stg/Makefile
Fix projects and plugins building system to support new libs
[stg.git] / projects / rlm_stg / Makefile
1 ###############################################################################
2 # $Id: Makefile,v 1.5 2009/03/03 15:49:34 faust Exp $
3 ###############################################################################
4
5 include ../../Makefile.conf
6
7 LIB_NAME = rlm_stg
8
9 PROG = $(LIB_NAME).so
10
11 SRCS = ./rlm_stg.cpp \
12        ./stg_client.cpp
13
14 STGLIBS = common \
15           crypto
16
17 STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
18 STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
19
20 LIBS += $(LIB_THREAD) $(addprefix -lstg,$(STGLIBS))
21
22 ifeq ($(OS),linux)
23 LIBS += -ldl
24 else
25 LIBS += -lintl \
26         -lc
27 endif
28
29 SEARCH_DIRS = -I ../../include
30
31 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
32
33 CXXFLAGS += -fPIC $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
34 CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
35 LDFLAGS += -shared -Wl,-rpath,$(PREFIX)/usr/lib/stg -Wl,-E $(STGLIBS_LIBS)
36
37 .PHONY: all clean distclean libs install uninstall install-bin uninstall-bin
38 all: libs $(PROG) ../../Makefile.conf
39
40 libs:
41         $(MAKE) -C $(DIR_LIBSRC)
42
43 $(PROG): $(OBJS)
44         $(CXX) $^ $(LDFLAGS) -o $(PROG) $(LIBS)
45
46 clean:
47         rm -f deps $(PROG) *.o tags *.*~ .OS
48         rm -f .OS
49         rm -f core*
50         $(MAKE) -C $(DIR_LIBSRC) clean
51
52 distclean: clean
53         rm -f ../../Makefile.conf
54
55 install: install-bin
56
57 install-bin:
58         install -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/lib/$(PROG)
59         $(MAKE) -C $(DIR_LIBSRC) install
60
61 uninstall: uninstall-bin
62
63 uninstall-bin:
64         rm -f $(PREFIX)/usr/lib/$(PROG)
65
66 ifneq ($(MAKECMDGOALS),distclean)
67 ifneq ($(MAKECMDGOALS),clean)
68 ifneq ($(MAKECMDGOALS),uninstall)
69 -include deps
70 endif
71 endif
72 endif
73
74 deps:   $(SRCS) ../../Makefile.conf
75         $(MAKE) -C $(DIR_LIBSRC)
76         @>deps ;\
77         for file in $(SRCS); do\
78           echo "`$(CC) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
79           echo -e '\t$$(CC) -c $$< $(CXXFLAGS)' >> deps ;\
80         done
81
82