]> git.stg.codes - stg.git/blob - projects/sgconf/Makefile
Version bump
[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
12 STGLIBS = conffiles \
13           srvconf \
14           common \
15           crypto
16
17 STGLIBS_INCS = $(addprefix -I ../../stglibs/,$(addsuffix .lib/include,$(STGLIBS)))
18 STGLIBS_LIBS = $(addprefix -L ../../stglibs/,$(addsuffix .lib,$(STGLIBS)))
19
20 LIBS += -lexpat $(LIB_THREAD) $(addprefix -lstg,$(STGLIBS))
21
22 ifeq ($(OS),linux)
23 else
24 LIBS += -lc \
25         -liconv
26 endif
27
28 SEARCH_DIRS = -I ../../include
29
30 ifeq ($(OS),bsd)
31 SEARCH_DIRS += -I/usr/local/include
32 CXXFLAGS += -DHAVE_DECL_GETOPT=1
33 endif
34
35 ifeq ($(OS),bsd5)
36 SEARCH_DIRS += -I/usr/local/include
37 CXXFLAGS += -DHAVE_DECL_GETOPT=1
38 endif
39
40 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
41
42 CXXFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
43 CFLAGS += $(DEFS) $(STGLIBS_INCS) $(SEARCH_DIRS)
44 LDFLAGS += -Wl,-E $(STGLIBS_LIBS)
45
46 .PHONY: all clean distclean libs install uninstall install-bin install-data uninstall-bin uninstall-data
47 all: libs $(PROG) ../../Makefile.conf
48
49 libs:
50         $(MAKE) -C $(DIR_LIBSRC)
51
52 $(PROG): $(OBJS)
53         $(CXX) $^ $(LDFLAGS) $(LIBS) -o $(PROG)
54
55 clean:
56         rm -f deps $(PROG) *.o tags *.*~ .OS
57         rm -f .OS
58         rm -f .store
59         rm -f .db.sql
60         rm -f core*
61         $(MAKE) -C $(DIR_LIBSRC) clean
62
63 distclean: clean
64         rm -f ../../Makefile.conf
65
66 install: install-bin
67
68 install-bin:
69         install -m $(BIN_MODE) -o $(OWNER) -s $(PROG) $(PREFIX)/usr/sbin/$(PROG)
70         $(MAKE) -C $(DIR_LIBSRC) install
71
72 uninstall: uninstall-bin
73
74 uninstall-bin:
75         rm -f $(PREFIX)/usr/sbin/$(PROG)
76
77
78 ifneq ($(MAKECMDGOALS),distclean)
79 ifneq ($(MAKECMDGOALS),clean)
80 ifneq ($(MAKECMDGOALS),uninstall)
81 -include deps
82 endif
83 endif
84 endif
85
86 deps:   $(SRCS) ../../Makefile.conf
87         $(MAKE) -C $(DIR_LIBSRC)
88         @>deps ;\
89         for file in $(SRCS); do\
90           echo "`$(CC) $(CXXFLAGS) -MM $$file` Makefile" >> deps ;\
91           echo -e '\t$$(CC) -c $$< $(CXXFLAGS)' >> deps ;\
92         done
93
94