]> git.stg.codes - stg.git/blob - projects/sgauth/Makefile
Minor echo fix
[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 += -Wl,-E $(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         install -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/sbin/$(PROG)
62         $(MAKE) -C $(DIR_LIBSRC) install
63
64 install-data:
65         # Install etc
66         mkdir -m $(DIR_MODE) -p $(PREFIX)/etc
67         install -m $(DATA_MODE) -o $(OWNER) ./sgauth.conf $(PREFIX)/etc/sgauth.conf
68
69 uninstall: uninstall-bin uninstall-data
70
71 uninstall-bin:
72         rm -f $(PREFIX)/usr/sbin/$(PROG)
73
74 uninstall-data:
75         # Uninstall etc
76         rm -f $(PREFIX)/etc/sgauth.conf
77
78
79 ifneq ($(MAKECMDGOALS),distclean)
80 ifneq ($(MAKECMDGOALS),clean)
81 ifneq ($(MAKECMDGOALS),uninstall)
82 -include deps
83 endif
84 endif
85 endif
86
87 deps:   $(SRCS) ../../Makefile.conf sgauth.css
88         $(MAKE) -C $(DIR_LIBSRC)
89         @>deps ;\
90         ./make_css.sh ;\
91         for file in $(SRCS); do\
92           echo "$$file" | grep ".c$$" > /dev/null;\
93           if [ $$? -eq 0 ];\
94           then\
95             echo "`$(CC) $(CFLAGS) -MM $$file` Makefile" >> deps ;\
96             printf '%b\n' '\t$$(CC) $(CFLAGS) -c $$<' >> deps ;\
97           else\
98             echo "`$(CXX) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
99             printf '%b\n' '\t$$(CXX) $(CXXFLAGS) -c $$<' >> deps ;\
100           fi;\
101         done