]> git.stg.codes - stg.git/blob - projects/sgconf/Makefile
Ticket. The checking if(!data.tariffConf.changePolicyTimeout.emplty)
[stg.git] / projects / sgconf / Makefile
1 ###############################################################################
2 # $Id: Makefile,v 1.21 2010/02/11 12:34:14 faust Exp $
3 ###############################################################################
4
5 include ../../Makefile.conf
6
7 PROG = sgconf
8
9 SRCS = ./main.cpp \
10        ./options.cpp \
11        ./api_action.cpp \
12        ./actions.cpp \
13        ./admins.cpp \
14        ./tariffs.cpp \
15        ./users.cpp \
16        ./services.cpp \
17        ./corps.cpp \
18        ./info.cpp \
19        ./xml.cpp
20
21 STGLIBS = srvconf \
22           crypto \
23           common
24
25 STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
26 STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
27
28 LIBS += $(addprefix -lstg,$(STGLIBS)) -lexpat $(LIB_THREAD)
29
30 ifeq ($(OS),linux)
31 else
32 LIBS += -lc \
33         -liconv
34 endif
35
36 SEARCH_DIRS = -I ../../include
37
38 ifeq ($(OS),bsd)
39 SEARCH_DIRS += -I/usr/local/include
40 CXXFLAGS += -DHAVE_DECL_GETOPT=1
41 endif
42
43 ifeq ($(OS),bsd5)
44 SEARCH_DIRS += -I/usr/local/include
45 CXXFLAGS += -DHAVE_DECL_GETOPT=1
46 endif
47
48 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
49
50 CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
51 CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
52 LDFLAGS += $(STGLIBS_LIBS)
53
54 ifneq ($(OS),darwin)
55 LDFLAGS += -Wl,-E
56 endif
57
58 .PHONY: all clean distclean libs install uninstall install-bin install-data uninstall-bin uninstall-data
59 all: libs $(PROG) ../../Makefile.conf
60
61 libs:
62         $(MAKE) -C $(DIR_LIBSRC)
63
64 $(PROG): $(OBJS)
65         $(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
66
67 clean:
68         rm -f deps $(PROG) *.o
69         $(MAKE) -C $(DIR_LIBSRC) clean
70
71 distclean: clean
72         rm -f ../../Makefile.conf
73
74 install: install-bin
75
76 install-bin:
77 ifeq ($(DEBUG), yes)
78         mkdir -m $(DIR_MODE) -p $(PREFIX)/usr/sbin
79         install -m $(BIN_MODE) -o $(OWNER) $(PROG) $(PREFIX)/usr/sbin/$(PROG)
80 else
81         mkdir -m $(DIR_MODE) -p $(PREFIX)/usr/sbin
82         install -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/sbin/$(PROG)
83 endif
84         $(MAKE) -C $(DIR_LIBSRC) install
85
86 uninstall: uninstall-bin
87
88 uninstall-bin:
89         rm -f $(PREFIX)/usr/sbin/$(PROG)
90
91
92 ifneq ($(MAKECMDGOALS),distclean)
93 ifneq ($(MAKECMDGOALS),clean)
94 ifneq ($(MAKECMDGOALS),uninstall)
95 -include deps
96 endif
97 endif
98 endif
99
100 deps: $(SRCS) ../../Makefile.conf
101         $(MAKE) -C $(DIR_LIBSRC)
102         @>deps ;\
103         for file in $(SRCS); do\
104           echo "$$file" | grep ".c$$" > /dev/null;\
105           if [ $$? -eq 0 ];\
106           then\
107             echo "`$(CC) $(CFLAGS) -MM $$file` Makefile" >> deps ;\
108             printf '%b\n' '\t$$(CC) $(CFLAGS) -c $$<' >> deps ;\
109           else\
110             echo "`$(CXX) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
111             printf '%b\n' '\t$$(CXX) $(CXXFLAGS) -c $$<' >> deps ;\
112           fi;\
113         done