]> git.stg.codes - stg.git/blob - projects/sgconf/Makefile
Hide or add proper copy ctor and assignement operator, initialize
[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 =  -lstgconffiles \
13            -lstgsrvconf \
14            -lstgcommon \
15            -lstgcrypto
16
17 LIBS += -lexpat \
18         $(LIB_THREAD)
19
20 ifeq ($(OS),linux)
21 LIBS += -ldl
22 else
23 LIBS += -lc \
24         -liconv
25 endif
26
27 SEARCH_DIRS = -I $(DIR_INCLUDE)
28
29 ifeq ($(OS),bsd)
30 SEARCH_DIRS += -I/usr/local/include
31 CXXFLAGS += -DHAVE_DECL_GETOPT=1
32 endif
33
34 ifeq ($(OS),bsd5)
35 SEARCH_DIRS += -I/usr/local/include
36 CXXFLAGS += -DHAVE_DECL_GETOPT=1
37 endif
38
39 OBJS = $(notdir $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS))))
40
41 CXXFLAGS += -Wall
42 LDFLAGS += -Wl,-E -L$(DIR_LIB) -Wl,-rpath,$(PREFIX)/usr/lib/stg -Wl,-rpath-link,$(DIR_LIB)
43
44 vpath %.a $(DIR_LIB)
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) $(STGLIBS)
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) includes
88         @>deps ;\
89         for file in $(SRCS); do\
90           echo "`$(CC) $(CXXFLAGS) $(SEARCH_DIRS) -MM $$file` Makefile" >> deps ;\
91           echo -e '\t$$(CC) -c $$< $(CXXFLAGS) $(SEARCH_DIRS) $(DEFS)' >> deps ;\
92         done
93
94