1 ###############################################################################
2 # $Id: Makefile,v 1.50 2010/10/07 18:27:27 faust Exp $
3 ###############################################################################
5 include ../../Makefile.conf
9 SRCS = ./admin_impl.cpp \
22 ./traffcounter_impl.cpp \
27 STGLIBS = scriptexecuter \
33 STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
34 STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
36 LIBS += $(addprefix -lstg,$(STGLIBS)) $(LIB_THREAD)
44 SEARCH_DIRS = -I ../../include
46 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
48 CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
49 CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
50 LDFLAGS += -Wl,-E $(STGLIBS_LIBS)
52 .PHONY: all clean distclean libs plugins install uninstall install-bin install-data
53 all: libs plugins $(PROG)
56 $(MAKE) -C $(DIR_LIBSRC)
59 $(MAKE) -C $(DIR_PLUGINS)
62 $(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
65 rm -f deps $(PROG) *.o tags *.*~ .OS
70 $(MAKE) -C $(DIR_LIBSRC) clean
71 $(MAKE) -C $(DIR_PLUGINS) clean
75 rm -f ../../Makefile.conf
77 install: install-bin install-data
80 install -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/sbin/$(PROG)
81 $(MAKE) -C $(DIR_INCLUDE) install
82 $(MAKE) -C $(DIR_LIBSRC) install
83 $(MAKE) -C $(DIR_PLUGINS) install
87 mkdir -m $(DIR_MODE) -p $(PREFIX)/etc/stargazer
88 mkdir -m $(DIR_MODE) -p $(PREFIX)/etc/stargazer/conf-available.d
89 mkdir -m $(DIR_MODE) -p $(PREFIX)/etc/stargazer/conf-enabled.d
90 install -m $(DATA_MODE) -o $(OWNER) $(ETC_DIR)/stargazer.conf $(PREFIX)/etc/stargazer/stargazer.conf
91 install -m $(DATA_MODE) -o $(OWNER) $(ETC_DIR)/conf-available.d/*.conf $(PREFIX)/etc/stargazer/conf-available.d
92 ln -s ../conf-available.d/mod_ao.conf $(PREFIX)/etc/stargazer/conf-enabled.d/mod_ao.conf
93 ln -s ../conf-available.d/mod_ia.conf $(PREFIX)/etc/stargazer/conf-enabled.d/mod_ia.conf
94 ln -s ../conf-available.d/mod_ping.conf $(PREFIX)/etc/stargazer/conf-enabled.d/mod_ping.conf
95 ln -s ../conf-available.d/mod_sg.conf $(PREFIX)/etc/stargazer/conf-enabled.d/mod_sg.conf
98 ln -s ../conf-available.d/mod_cap_ether.conf $(PREFIX)/etc/stargazer/conf-enabled.d/mod_cap_ether.conf
100 ln -s ../conf-available.d/mod_cap_bpf.conf $(PREFIX)/etc/stargazer/conf-enabled.d/mod_cap_bpf.conf
103 install -m $(DATA_MODE) -o $(OWNER) $(ETC_DIR)/rules $(PREFIX)/etc/stargazer/rules
104 install -m $(BIN_MODE) -o $(OWNER) $(ETC_DIR)/On* $(PREFIX)/etc/stargazer/
107 mkdir -m $(DIR_MODE) -p $(PREFIX)/var/stargazer/admins
108 mkdir -m $(DIR_MODE) -p $(PREFIX)/var/stargazer/tariffs
109 mkdir -m $(DIR_MODE) -p $(PREFIX)/var/stargazer/users/test
110 install -m $(DATA_MODE) -o $(OWNER) $(VAR_DIR)/admins/admin.adm $(PREFIX)/var/stargazer/admins/admin.adm
111 install -m $(DATA_MODE) -o $(OWNER) $(VAR_DIR)/tariffs/tariff.tf $(PREFIX)/var/stargazer/tariffs/tariff.tf
112 install -m $(DATA_MODE) -o $(OWNER) $(VAR_DIR)/users/test/conf $(PREFIX)/var/stargazer/users/test/conf
113 install -m $(DATA_MODE) -o $(OWNER) $(VAR_DIR)/users/test/stat $(PREFIX)/var/stargazer/users/test/stat
115 ifeq ($(CHECK_FBCLIENT),yes)
116 # Install firebird db
117 mkdir -p $(PREFIX)/var/stargazer
118 chown $(OWNER):$(FIREBIRD_GROUP) $(PREFIX)/var/stargazer
119 chmod g+rw $(PREFIX)/var/stargazer
120 echo "connect '$(DB_ADDRESS)' user '$(DB_USER)' password '$(DB_PASSWORD)';" > .db.sql
121 echo "drop database;" >> .db.sql
122 echo "create database '$(DB_ADDRESS)' user '$(DB_USER)' password '$(DB_PASSWORD)' default character set win1251;" >> .db.sql
123 cat $(VAR_DIR)/../00-base-00.sql >> .db.sql
124 $(FIREBIRD_ISQL) -i .db.sql
128 uninstall: uninstall-bin uninstall-data
131 rm -f $(PREFIX)/usr/sbin/$(PROG)
132 $(MAKE) -C $(DIR_LIBSRC) uninstall
133 $(MAKE) -C $(DIR_PLUGINS) uninstall
134 rm -rf $(PREFIX)/usr/lib/stg
138 rm -rf $(PREFIX)/etc/stargazer
139 rm -rf $(PREFIX)/var/stargazer
142 ifneq ($(MAKECMDGOALS),distclean)
143 ifneq ($(MAKECMDGOALS),clean)
144 ifneq ($(MAKECMDGOALS),uninstall)
150 deps: $(SRCS) ../../Makefile.conf
151 $(MAKE) -C $(DIR_LIBSRC)
153 for file in $(SRCS); do\
154 echo "`$(CC) $(CXXFLAGS) -MM $$file` Makefile ../../Makefile.conf" >> deps ;\
155 echo -e '\t$$(CC) -c $$< $(CXXFLAGS)' >> deps ;\