]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - make/template/main.mk
Rename configuration variable to CXX to match everything else.
[user/henk/code/inspircd.git] / make / template / main.mk
1 #
2 # InspIRCd -- Internet Relay Chat Daemon
3 #
4 #   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
5 #
6 # This file is part of InspIRCd.  InspIRCd is free software: you can
7 # redistribute it and/or modify it under the terms of the GNU General Public
8 # License as published by the Free Software Foundation, version 2.
9 #
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #
18
19
20 #
21 #               InspIRCd Main Makefile
22 #
23 # This file is automagically generated by configure, from
24 # make/template/main.mk. Any changes made to the generated
25 #     files will go away whenever it is regenerated!
26 #
27 # Please do not edit unless you know what you're doing. This
28 # needs to work in both GNU and BSD make; it is mangled for
29 # them by configure.
30 #
31
32
33 CXX = @CXX@
34 SYSTEM = @SYSTEM@
35 BUILDPATH = @BUILD_DIR@
36 SOCKETENGINE = @SOCKETENGINE@
37 CORECXXFLAGS = -fPIC -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow
38 LDLIBS = -pthread -lstdc++
39 CORELDFLAGS = -rdynamic -L. $(LDFLAGS)
40 PICLDFLAGS = -fPIC -shared -rdynamic $(LDFLAGS)
41 BASE = "$(DESTDIR)@BASE_DIR@"
42 CONPATH = "$(DESTDIR)@CONFIG_DIR@"
43 MODPATH = "$(DESTDIR)@MODULE_DIR@"
44 DATPATH = "$(DESTDIR)@DATA_DIR@"
45 BINPATH = "$(DESTDIR)@BINARY_DIR@"
46 INSTALL = install
47 INSTUID = @UID@
48 INSTMODE_DIR = 0755
49 INSTMODE_BIN = 0755
50 INSTMODE_LIB = 0644
51
52 @IFNEQ $(CXX) icc
53   CORECXXFLAGS += -pedantic -Woverloaded-virtual -Wshadow -Wformat=2 -Wmissing-format-attribute
54 @ENDIF
55
56 @IFNEQ $(SYSTEM) darwin
57   LDLIBS += -pthread
58 @ENDIF
59
60 @IFEQ $(SYSTEM) linux
61   LDLIBS += -ldl -lrt
62 @ENDIF
63 @IFEQ $(SYSTEM) gnukfreebsd
64   LDLIBS += -ldl -lrt
65 @ENDIF
66 @IFEQ $(SYSTEM) gnu
67   LDLIBS += -ldl -lrt
68 @ENDIF
69 @IFEQ $(SYSTEM) solaris
70   LDLIBS += -lsocket -lnsl -lrt -lresolv
71   INSTALL = ginstall
72 @ENDIF
73 @IFEQ $(SYSTEM) darwin
74   LDLIBS += -ldl
75   CORELDFLAGS = -dynamic -bind_at_load -L. $(LDFLAGS)
76   PICLDFLAGS = -fPIC -shared -twolevel_namespace -undefined dynamic_lookup $(LDFLAGS)
77 @ENDIF
78
79 @IFNDEF D
80   D=0
81 @ENDIF
82
83 DBGOK=0
84 @IFEQ $(D) 0
85   CORECXXFLAGS += -O2
86 @IFEQ $(CXX) g++
87     CORECXXFLAGS += -g1
88 @ENDIF
89   HEADER = std-header
90   DBGOK=1
91 @ENDIF
92 @IFEQ $(D) 1
93   CORECXXFLAGS += -O0 -g3 -Werror
94   HEADER = debug-header
95   DBGOK=1
96 @ENDIF
97 @IFEQ $(D) 2
98   CORECXXFLAGS += -O2 -g3
99   HEADER = debug-header
100   DBGOK=1
101 @ENDIF
102 FOOTER = finishmessage
103
104 @GNU_ONLY MAKEFLAGS += --no-print-directory
105
106 @GNU_ONLY SOURCEPATH = $(shell /bin/pwd)
107 @BSD_ONLY SOURCEPATH != /bin/pwd
108
109 @IFDEF V
110   RUNCC = $(CXX)
111   RUNLD = $(CXX)
112   VERBOSE = -v
113 @ELSE
114   @GNU_ONLY MAKEFLAGS += --silent
115   @BSD_ONLY MAKE += -s
116   RUNCC = perl $(SOURCEPATH)/make/run-cc.pl $(CXX)
117   RUNLD = perl $(SOURCEPATH)/make/run-cc.pl $(CXX)
118 @ENDIF
119
120 @IFDEF PURE_STATIC
121   CORECXXFLAGS += -DPURE_STATIC
122 @ENDIF
123
124 # Add the users CXXFLAGS to the base ones to allow them to override
125 # things like -Wfatal-errors if they wish to.
126 CORECXXFLAGS += $(CXXFLAGS)
127
128 @DO_EXPORT RUNCC RUNLD CORECXXFLAGS LDLIBS PICLDFLAGS VERBOSE SOCKETENGINE CORELDFLAGS
129 @DO_EXPORT SOURCEPATH BUILDPATH PURE_STATIC SPLIT_CC
130
131 # Default target
132 TARGET = all
133
134 @IFDEF M
135     HEADER = mod-header
136     FOOTER = mod-footer
137     @BSD_ONLY TARGET = modules/${M:S/.so$//}.so
138     @GNU_ONLY TARGET = modules/$(M:.so=).so
139 @ENDIF
140
141 @IFDEF T
142     HEADER =
143     FOOTER = target
144     TARGET = $(T)
145 @ENDIF
146
147 @IFEQ $(DBGOK) 0
148   HEADER = unknown-debug-level
149 @ENDIF
150
151 all: $(FOOTER)
152
153 target: $(HEADER)
154         $(MAKEENV) perl make/calcdep.pl
155         cd $(BUILDPATH); $(MAKEENV) $(MAKE) -f real.mk $(TARGET)
156
157 debug:
158         @${MAKE} D=1 all
159
160 debug-header:
161         @echo "*************************************"
162         @echo "*    BUILDING WITH DEBUG SYMBOLS    *"
163         @echo "*                                   *"
164         @echo "*   This will take a *long* time.   *"
165         @echo "*  Please be aware that this build  *"
166         @echo "*  will consume a very large amount *"
167         @echo "*  of disk space (~350MB), and may  *"
168         @echo "*  run slower. Use the debug build  *"
169         @echo "*  for module development or if you *"
170         @echo "*    are experiencing problems.     *"
171         @echo "*                                   *"
172         @echo "*************************************"
173
174 mod-header:
175 @IFDEF PURE_STATIC
176         @echo 'Cannot build single modules in pure-static build'
177         @exit 1
178 @ENDIF
179         @echo 'Building single module:'
180
181 mod-footer: target
182         @echo 'To install, copy $(BUILDPATH)/$(TARGET) to $(MODPATH)'
183         @echo 'Or, run "make install"'
184
185 std-header:
186         @echo "*************************************"
187         @echo "*       BUILDING INSPIRCD           *"
188         @echo "*                                   *"
189         @echo "*   This will take a *long* time.   *"
190         @echo "*     Why not read our wiki at      *"
191         @echo "*     http://wiki.inspircd.org      *"
192         @echo "*  while you wait for make to run?  *"
193         @echo "*************************************"
194
195 finishmessage: target
196         @echo ""
197         @echo "*************************************"
198         @echo "*        BUILD COMPLETE!            *"
199         @echo "*                                   *"
200         @echo "*   To install InspIRCd, type:      *"
201         @echo "*         make install              *"
202         @echo "*************************************"
203
204 install: target
205         @if [ "$(INSTUID)" = 0 -o "$(INSTUID)" = root ]; then \
206                 echo ""; \
207                 echo "Error: You must specify a non-root UID for the server"; \
208                 echo ""; \
209                 echo "If you are making a package, please specify using ./configure --uid"; \
210                 echo "Otherwise, rerun using 'make INSTUID=irc install', where 'irc' is the user"; \
211                 echo "who will be running the ircd. You will also need to modify the start script."; \
212                 echo ""; \
213                 exit 1; \
214         fi
215         @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(BASE)
216         @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(BASE)/data
217         @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(BASE)/logs
218         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(BINPATH)
219         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(CONPATH)/examples/aliases
220         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(CONPATH)/examples/modules
221         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(MODPATH)
222         [ $(BUILDPATH)/bin/ -ef $(BINPATH) ] || $(INSTALL) -m $(INSTMODE_BIN) $(BUILDPATH)/bin/inspircd $(BINPATH)
223 @IFNDEF PURE_STATIC
224         [ $(BUILDPATH)/modules/ -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) $(BUILDPATH)/modules/*.so $(MODPATH)
225 @ENDIF
226         -$(INSTALL) -m $(INSTMODE_BIN) @STARTSCRIPT@ $(BASE) 2>/dev/null
227         -$(INSTALL) -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null
228         -$(INSTALL) -m $(INSTMODE_LIB) tools/gdbargs $(BASE)/.gdbargs 2>/dev/null
229         -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/*.example $(CONPATH)/examples
230         -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/aliases/*.example $(CONPATH)/examples/aliases
231         -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/modules/*.example $(CONPATH)/examples/modules
232         @echo ""
233         @echo "*************************************"
234         @echo "*        INSTALL COMPLETE!          *"
235         @echo "*************************************"
236         @echo 'Paths:'
237         @echo '  Base install:' $(BASE)
238         @echo '  Configuration:' $(CONPATH)
239         @echo '  Binaries:' $(BINPATH)
240         @echo '  Modules:' $(MODPATH)
241         @echo '  Data:' $(DATPATH)
242         @echo 'To start the ircd, run:' $(BASE)/inspircd start
243         @echo 'Remember to create your config file:' $(CONPATH)/inspircd.conf
244         @echo 'Examples are available at:' $(CONPATH)/examples/
245
246 @GNU_ONLY RCS_FILES = $(wildcard .git/index src/version.sh)
247 @BSD_ONLY RCS_FILES = src/version.sh
248 GNUmakefile BSDmakefile: make/template/main.mk configure $(RCS_FILES)
249         ./configure -update
250 @BSD_ONLY .MAKEFILEDEPS: BSDmakefile
251
252 clean:
253         @echo Cleaning...
254         -rm -f $(BUILDPATH)/bin/inspircd $(BUILDPATH)/include $(BUILDPATH)/real.mk
255         -rm -rf $(BUILDPATH)/obj $(BUILDPATH)/modules
256         @-rmdir $(BUILDPATH)/bin 2>/dev/null
257         @-rmdir $(BUILDPATH) 2>/dev/null
258         @echo Completed.
259
260 deinstall:
261         -rm -f $(BINPATH)/inspircd
262         -rm -rf $(CONPATH)/examples
263         -rm -f $(MODPATH)/*.so
264         -rm -f $(BASE)/.gdbargs
265         -rm -f $(BASE)/org.inspircd.plist
266
267 configureclean:
268         rm -f .config.cache
269         rm -f BSDmakefile
270         rm -f GNUmakefile
271         rm -f include/config.h
272         rm -f inspircd
273         -rm -f org.inspircd.plist
274
275 distclean: clean configureclean
276         -rm -rf $(SOURCEPATH)/run
277         find $(SOURCEPATH)/src/modules -type l | xargs rm -f
278
279 help:
280         @echo 'InspIRCd Makefile'
281         @echo ''
282         @echo 'Use: ${MAKE} [flags] [targets]'
283         @echo ''
284         @echo 'Flags:'
285         @echo ' V=1       Show the full command being executed instead of "BUILD: dns.cpp"'
286         @echo ' D=1       Enable debug build, for module development or crash tracing'
287         @echo ' D=2       Enable debug build with optimizations, for detailed backtraces'
288         @echo ' DESTDIR=  Specify a destination root directory (for tarball creation)'
289         @echo ' -j <N>    Run a parallel build using N jobs'
290         @echo ''
291         @echo 'Targets:'
292         @echo ' all       Complete build of InspIRCd, without installing (default)'
293         @echo ' install   Build and install InspIRCd to the directory chosen in ./configure'
294         @echo '           Currently installs to ${BASE}'
295         @echo ' debug     Compile a debug build. Equivalent to "make D=1 all"'
296         @echo ''
297         @echo ' M=m_foo   Builds a single module (cmd_foo also works here)'
298         @echo ' T=target  Builds a user-specified target, such as "inspircd" or "modules"'
299         @echo '           Other targets are specified by their path in the build directory'
300         @echo '           Multiple targets may be separated by a space'
301         @echo ''
302         @echo ' clean     Cleans object files produced by the compile'
303         @echo ' distclean Cleans all generated files (build, configure, run, etc)'
304         @echo ' deinstall Removes the files created by "make install"'
305         @echo
306
307 .PHONY: all target debug debug-header mod-header mod-footer std-header finishmessage install clean deinstall configureclean help