]> git.stg.codes - stg.git/blob - projects/rlm_stg/Makefile
Merge branch 'stg-2.409' into stg-2.409-radius
[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.c \
12        ./iface.cpp \
13        ./stg_client.cpp
14
15 STGLIBS = crypto \
16           common \
17           sgcp
18
19 STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
20 STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
21
22 LIBS += $(addprefix -lstg,$(STGLIBS)) $(LIB_THREAD) $(LIBICONV)
23
24 ifeq ($(OS),linux)
25 LIBS += -ldl
26 else
27 LIBS += -lintl \
28         -lc
29 endif
30
31 SEARCH_DIRS = -I ../../include
32
33 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
34
35 CFLAGS += -fPIC $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
36 CXXFLAGS += -fPIC $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
37 CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
38 LDFLAGS += -shared -Wl,-rpath,$(PREFIX)/usr/lib/stg -Wl,-E $(STGLIBS_LIBS)
39
40 .PHONY: all clean distclean libs install uninstall install-bin uninstall-bin
41 all: libs $(PROG) ../../Makefile.conf
42
43 libs:
44         $(MAKE) -C $(DIR_LIBSRC)
45
46 $(PROG): $(OBJS)
47         $(CXX) $^ $(LDFLAGS) -o $(PROG) $(LIBS)
48
49 clean:
50         rm -f deps $(PROG) *.o tags *.*~ .OS
51         rm -f .OS
52         rm -f core*
53         $(MAKE) -C $(DIR_LIBSRC) clean
54
55 distclean: clean
56         rm -f ../../Makefile.conf
57
58 install: install-bin
59
60 install-bin:
61 ifeq ($(DEBUG), yes)
62 ifeq ($(OS), linux)
63         mkdir -m $(DIR_MODE) -p $(PREFIX)/usr/lib/freeradius
64         install -m $(BIN_MODE) -o $(OWNER) $(PROG) $(PREFIX)/usr/lib/freeradius/$(PROG)
65 else
66         mkdir -m $(DIR_MODE) -p $(PREFIX)/usr/lib
67         install -m $(BIN_MODE) -o $(OWNER) $(PROG) $(PREFIX)/usr/lib/$(PROG)
68 endif
69 else
70         mkdir -m $(DIR_MODE) -p $(PREFIX)/usr/lib/freeradius
71         install -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/lib/freeradius/$(PROG)
72 ifeq ($(OS), linux)
73         mkdir -m $(DIR_MODE) -p $(PREFIX)/usr/lib/freeradius
74         install -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/lib/freeradius/$(PROG)
75 else
76         mkdir -m $(DIR_MODE) -p $(PREFIX)/usr/lib
77         install -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/lib/$(PROG)
78 endif
79 endif
80         $(MAKE) -C $(DIR_LIBSRC) install
81
82 uninstall: uninstall-bin
83
84 uninstall-bin:
85 ifeq ($(OS), linux)
86         rm -f $(PREFIX)/usr/lib/freeradius/$(PROG)
87 else
88         rm -f $(PREFIX)/usr/lib/$(PROG)
89 endif
90
91 ifneq ($(MAKECMDGOALS),distclean)
92 ifneq ($(MAKECMDGOALS),clean)
93 ifneq ($(MAKECMDGOALS),uninstall)
94 -include deps
95 endif
96 endif
97 endif
98
99 deps:   $(SRCS) ../../Makefile.conf
100         $(MAKE) -C $(DIR_LIBSRC)
101         @>deps ;\
102         for file in $(SRCS); do\
103           echo "$$file" | grep ".c$$" > /dev/null;\
104           if [ $$? -eq 0 ];\
105           then\
106             echo "`$(CC) $(CFLAGS) -MM $$file` Makefile" >> deps ;\
107             printf '%b\n' '\t$$(CC) $(CFLAGS) -c $$<' >> deps ;\
108           else\
109             echo "`$(CXX) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
110             printf '%b\n' '\t$$(CXX) $(CXXFLAGS) -c $$<' >> deps ;\
111           fi;\
112         done