]> git.stg.codes - stg.git/blob - projects/sgauth/Makefile
ef6491194847a7486ceb072b17c7e715bf702ff3
[stg.git] / projects / sgauth / Makefile
1 ###############################################################################
2 # $Id: Makefile,v 1.18 2009/08/06 12:50:55 faust Exp $
3 ###############################################################################
4
5 include ../../Makefile.conf
6
7 PROG = sgauth
8
9 SRCS = ./main.cpp \
10        ./settings_impl.cpp \
11        ./web.cpp
12
13 STGLIBS =  conffiles \
14            ia \
15            crypto \
16            common
17
18 STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
19 STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
20
21 LIBS += $(addprefix -lstg,$(STGLIBS)) $(LIB_THREAD)
22
23 ifneq ($(OS),linux)
24 LIBS += -lintl \
25         -lc \
26         -liconv
27 endif
28
29 SEARCH_DIRS = -I ../../include
30
31 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
32
33 CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
34 CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
35 LDFLAGS += $(STGLIBS_LIBS)
36
37 .PHONY: all clean distclean libs install uninstall install-bin install-data uninstall-bin uninstall-data
38 all: libs $(PROG) ../../Makefile.conf
39
40 libs:
41         $(MAKE) -C $(DIR_LIBSRC)
42
43 $(PROG): $(OBJS)
44         $(CXX) $^ $(LDFLAGS) -o $(PROG) $(LIBS)
45
46 clean:
47         rm -f deps $(PROG) *.o tags *.*~ .OS
48         rm -f .OS
49         rm -f .store
50         rm -f .db.sql
51         rm -f core*
52         rm -f css.h
53         $(MAKE) -C $(DIR_LIBSRC) clean
54
55 distclean: clean
56         rm -f ../../Makefile.conf
57
58 install: install-bin install-data
59
60 install-bin:
61 ifeq ($(DEBUG), yes)
62         install -D -m $(BIN_MODE) -o $(OWNER) $(PROG) $(PREFIX)/usr/sbin/$(PROG)
63 else
64         install -D -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/sbin/$(PROG)
65 endif
66         $(MAKE) -C $(DIR_LIBSRC) install
67
68 install-data:
69         # Install etc
70         mkdir -m $(DIR_MODE) -p $(PREFIX)/etc
71         install -m $(DATA_MODE) -o $(OWNER) ./sgauth.conf $(PREFIX)/etc/sgauth.conf
72
73 uninstall: uninstall-bin uninstall-data
74
75 uninstall-bin:
76         rm -f $(PREFIX)/usr/sbin/$(PROG)
77
78 uninstall-data:
79         # Uninstall etc
80         rm -f $(PREFIX)/etc/sgauth.conf
81
82
83 ifneq ($(MAKECMDGOALS),distclean)
84 ifneq ($(MAKECMDGOALS),clean)
85 ifneq ($(MAKECMDGOALS),uninstall)
86 -include deps
87 endif
88 endif
89 endif
90
91 deps:   $(SRCS) ../../Makefile.conf sgauth.css
92         $(MAKE) -C $(DIR_LIBSRC)
93         @>deps ;\
94         ./make_css.sh ;\
95         for file in $(SRCS); do\
96           echo "$$file" | grep ".c$$" > /dev/null;\
97           if [ $$? -eq 0 ];\
98           then\
99             echo "`$(CC) $(CFLAGS) -MM $$file` Makefile" >> deps ;\
100             printf '%b\n' '\t$$(CC) $(CFLAGS) -c $$<' >> deps ;\
101           else\
102             echo "`$(CXX) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
103             printf '%b\n' '\t$$(CXX) $(CXXFLAGS) -c $$<' >> deps ;\
104           fi;\
105         done