]> git.stg.codes - stg.git/blob - projects/sgconf/Makefile
Implemented some user management functions.
[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        ./common_sg.cpp \
11        ./options.cpp \
12        ./actions.cpp \
13        ./admins.cpp \
14        ./tariffs.cpp \
15        ./users.cpp \
16        ./xml.cpp
17
18 STGLIBS = conffiles \
19           srvconf \
20           crypto \
21           common
22
23 STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
24 STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
25
26 LIBS += $(addprefix -lstg,$(STGLIBS)) -lexpat $(LIB_THREAD)
27
28 ifeq ($(OS),linux)
29 else
30 LIBS += -lc \
31         -liconv
32 endif
33
34 SEARCH_DIRS = -I ../../include
35
36 ifeq ($(OS),bsd)
37 SEARCH_DIRS += -I/usr/local/include
38 CXXFLAGS += -DHAVE_DECL_GETOPT=1
39 endif
40
41 ifeq ($(OS),bsd5)
42 SEARCH_DIRS += -I/usr/local/include
43 CXXFLAGS += -DHAVE_DECL_GETOPT=1
44 endif
45
46 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
47
48 CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
49 CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
50 LDFLAGS += $(STGLIBS_LIBS)
51
52 ifneq ($(OS),darwin)
53 LDFLAGS += -Wl,-E
54 endif
55
56 .PHONY: all clean distclean libs install uninstall install-bin install-data uninstall-bin uninstall-data
57 all: libs $(PROG) ../../Makefile.conf
58
59 libs:
60         $(MAKE) -C $(DIR_LIBSRC)
61
62 $(PROG): $(OBJS)
63         $(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
64
65 clean:
66         rm -f deps $(PROG) *.o tags *.*~ .OS
67         rm -f .OS
68         rm -f .store
69         rm -f .db.sql
70         rm -f core*
71         $(MAKE) -C $(DIR_LIBSRC) clean
72
73 distclean: clean
74         rm -f ../../Makefile.conf
75
76 install: install-bin
77
78 install-bin:
79 ifeq ($(DEBUG), yes)
80         install -D -m $(BIN_MODE) -o $(OWNER) $(PROG) $(PREFIX)/usr/bin/$(PROG)
81 else
82         install -D -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/bin/$(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