]> git.stg.codes - stg.git/blob - projects/sgauthstress/Makefile
Allowed to build sgconf_xml on Darwin.
[stg.git] / projects / sgauthstress / Makefile
1 include ../../Makefile.conf
2
3 PROG = sgauthstress
4
5 SRCS = main.cpp \
6        settings.cpp \
7        store_loader.cpp \
8        user.cpp \
9        proto.cpp
10
11 STGLIBS = dotconfpp \
12           crypto \
13           common
14
15 STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
16 STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
17
18 LIBS += $(addprefix -lstg,$(STGLIBS)) $(LIB_THREAD)
19
20 ifeq ($(OS),linux)
21 LIBS += -ldl
22 else
23 LIBS += -lintl \
24         -lc \
25         -liconv
26 endif
27
28 SEARCH_DIRS = -I ../../include
29
30 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
31
32 CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
33 CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
34 LDFLAGS += -Wl,-E $(STGLIBS_LIBS)
35
36 .PHONY: all clean distclean libs plugins
37 all: libs plugins $(PROG) ../../Makefile.conf
38
39 libs:
40         $(MAKE) -C $(DIR_LIBSRC)
41
42 plugins: libs
43         $(MAKE) -C $(DIR_PLUGINS)
44
45 $(PROG): $(OBJS)
46         $(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
47
48 clean:
49         rm -f deps $(PROG) *.o *.*~
50         $(MAKE) -C $(DIR_LIBSRC) clean
51         $(MAKE) -C $(DIR_PLUGINS) clean
52
53 distclean: clean
54         rm -f ../../Makefile.conf
55
56 ifneq ($(MAKECMDGOALS),distclean)
57 ifneq ($(MAKECMDGOALS),clean)
58 ifneq ($(MAKECMDGOALS),uninstall)
59 -include deps
60 endif
61 endif
62 endif
63
64 deps:   $(SRCS) ../../Makefile.conf
65         $(MAKE) -C $(DIR_LIBSRC)
66         @>deps ;\
67         for file in $(SRCS); do\
68           echo "$$file" | grep ".c$$" > /dev/null;\
69           if [ $$? -eq 0 ];\
70           then\
71             echo "`$(CC) $(CFLAGS) -MM $$file` Makefile" >> deps ;\
72             printf '%b\n' '\t$$(CC) $(CFLAGS) -c $$<' >> deps ;\
73           else\
74             echo "`$(CXX) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
75             printf '%b\n' '\t$$(CXX) $(CXXFLAGS) -c $$<' >> deps ;\
76           fi;\
77         done