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