summaryrefslogtreecommitdiff
path: root/cpp/config/Make.rules
blob: 878b330e3ce2f92fa9b9ade75e82b7a2c486807f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# **********************************************************************
#
# Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************

#
# Select an installation base directory. The directory will be created
# if it does not exist.
#
prefix			?= /opt/Ice-$(VERSION)

#
# The "root directory" for runpath embedded in executables. Can be unset
# to avoid adding a runpath to Ice executables.
#
embedded_runpath_prefix ?= /opt/Ice-$(VERSION_MAJOR).$(VERSION_MINOR)

#
# Define create_runpath_symlink as yes if you would like 'make install'
# to automatically create a symbolic link for the embedded runpath
# directory. Only applies if embedded_runpath_prefix is also set.
#
create_runpath_symlink	?= no

#
# Define OPTIMIZE as yes if you want to build with
# optimization. Otherwise Ice is build with debug information.
#
#OPTIMIZE		= yes

#
# Define LP64 as yes or no if you want force a 32 or 64 bit. The
# default is platform-dependent. This property has no effect in Mac
# OS X. In Mac OS X use CXXARCHFLAGS bellow to establish the build 
# architectures.
#
#LP64			?= yes

#
# The build architectures for gcc/llvm based builds. The format of these
# build flags are OS dependent. For example, under Mac OS X to build
# binaries which support both i386 and x86_64 you would use "-arch
# i386 -arch x86_64".  The default is OS version dependent. Be aware
# that this value may conflict with the setting of LP64 above.
#
#CXXARCHFLAGS		     = -arch i386 -arch x86_64

#
# Define USE_READLINE as yes if you want to build parts of Ice using
# readline on platforms where readline is available (see
# PLATFORM_HAS_READLINE in Make.rules.$(UNAME))
#
# readline is used by a number of Ice admin programs to provide
# command history, an optional feature.
#
# readline is licensed by the Free Software Foundation under the GNU
# Public License v2, and cannot be combined with GPL-incompatible
# software in any program. In particular the OpenSSL license is
# GPL-incompatible.
#
# If you combine Ice with more GPL-incompatible software, or have
# licensed Ice under a commercial (non-GPL) license, you should ponder
# the licensing implications of using readline.
# 

USE_READLINE		?= no

#
# If libbzip2 is not installed in a standard location where the
# compiler can find it, set BZIP2_HOME to the bzip2 installation
# directory.
#
#BZIP2_HOME		?= /opt/bzip2


#
# If Berkeley DB is not installed in a standard location where the
# compiler can find it, set DB_HOME to the Berkeley DB installation
# directory.
#
#DB_HOME		?= /opt/db

#
# If expat is not installed in a standard location where the compiler
# can find it, set EXPAT_HOME to the expat installation directory.
#
#EXPAT_HOME		?= /opt/expat

#
# If OpenSSL is not installed in a standard location where the
# compiler can find it, set OPENSSL_HOME to the OpenSSL installation
# directory.
#
#OPENSSL_HOME		?= /opt/openssl

#
# If MCPP is not installed in a standard location where the compiler 
# can find it, set MCPP_HOME to the Mcpp installation directory.
#
#MCPP_HOME		?= /opt/mcpp

#
# If libiconv is not installed in a standard location where the compiler 
# can find it, set ICONV_HOME to the libiconv installation directory.
#
#ICONV_HOME		?= /opt/libiconv

#
# If readline is not installed in a standard location where the
# compiler can find it, AND you want to use readline, set
# READLINE_HOME to the readline installation directory.
#
#READLINE_HOME		?= /opt/readline

#
# If you want to build the SQL database plugins for IceStorm and
# IceGrid, set QT_HOME to the Qt installation directory.
#
#
#QT_HOME	= /usr/local/Trolltech/Qt-4.5.3
#QT_HOME	= /Library/Frameworks

#
# Generate position independent code unless GENPIC is set to no
#
#GENPIC                     ?= yes

#
# If building with MinGW and Ice third party packages is not installed
# in the default location set THIRDPARTY_HOME to the Ice third party
# installation directory.
#
#THIRDPARTY_HOME		?= C:\Program Files\ZeroC\Ice-$(VERSION)-ThirdParty

#
# Default Mutex protocol: one of PrioNone or PrioInherit.
#
#DEFAULT_MUTEX_PROTOCOL  ?= PrioNone

# ----------------------------------------------------------------------
# Don't change anything below this line!
# ----------------------------------------------------------------------

ifeq ($(shell test -f $(top_srcdir)/config/Make.rules.common && echo 0),0)
	include $(top_srcdir)/config/Make.rules.common
else
	include $(top_srcdir)/../cpp/config/Make.rules.common
endif

#
# Common definitions
#
ice_language     = cpp
ifneq ($(shell test "$(USE_BIN_DIST)" != "yes" -a -d $(top_srcdir)/../$(ice_language) && echo 0),0)
    ifeq ($(MinGW), yes)
        slice_translator = slice2cpp.exe
    else
        slice_translator = slice2cpp
    endif
    ice_require_cpp  = 1
endif

ifeq ($(shell test -f $(top_srcdir)/config/Make.common.rules && echo 0),0)
    include $(top_srcdir)/config/Make.common.rules
else
    include $(top_srcdir)/../config/Make.common.rules
endif

bindir			= $(top_srcdir)/bin
libdir			= $(top_srcdir)/lib
headerdir		= $(top_srcdir)/include

#
# includedir is not handled the same as bindir and libdir
# because it is used in the .depend files
#
ifdef ice_src_dist
    includedir		= $(top_srcdir)/include
else
    includedir		= $(ice_dir)/include
endif

#
# Platform specific definitions
#
ifeq ($(MinGW), yes)
	include	 $(top_srcdir)/config/Make.rules.MinGW
else
	include	 $(top_srcdir)/config/Make.rules.$(UNAME)
endif

install_includedir	:= $(prefix)/include
install_docdir		:= $(prefix)/doc
install_bindir	  	:= $(prefix)/$(binsubdir)
install_libdir	  	:= $(prefix)/$(libsubdir)
install_configdir 	:= $(prefix)/config

ifneq ($(embedded_runpath_prefix),)
    runpath_libdir	:= $(embedded_runpath_prefix)/$(libsubdir)
else
    create_runpath_symlink = no
endif

ifeq ($(DEFAULT_MUTEX_PROTOCOL), PrioInherit)
    ICEUTIL_FLAGS           = -DICE_PRIO_INHERIT
endif

ifeq ($(MinGW), yes)
	OPENSSL_LIBS            = -leay32_mingw -lssleay32_mingw
	BZIP2_LIBS			= -lbzip2_mingw
	MCPP_LIBS              = -lmcpp
	slicedir_win 		= $(shell $(top_srcdir)/../cpp/config/cygpath-win.sh $(slicedir))
	ICECPPFLAGS		= -I"$(slicedir_win)"
else
	OPENSSL_FLAGS           = $(if $(OPENSSL_HOME),-I$(OPENSSL_HOME)/include)
	OPENSSL_LIBS            = $(if $(OPENSSL_HOME),-L$(OPENSSL_HOME)/$(libsubdir)) -lssl -lcrypto
	OPENSSL_RPATH_LINK      = $(if $(OPENSSL_HOME),$(call rpathlink,$(OPENSSL_HOME)/$(libsubdir)))
	BZIP2_FLAGS             = $(if $(BZIP2_HOME),-I$(BZIP2_HOME)/include)
	BZIP2_LIBS              = $(if $(BZIP2_HOME),-L$(BZIP2_HOME)/$(libsubdir)) -lbz2
	BZIP2_RPATH_LINK        = $(if $(BZIP2_HOME),$(call rpathlink,$(BZIP2_HOME)/$(libsubdir)))
	ICONV_LIBS              = $(if $(ICONV_HOME),-L$(ICONV_HOME)/$(libsubdir)) $(ICONV_LIB)

	ifneq ($(DB_HOME),)
	   DB_FLAGS             = -I$(DB_HOME)/include
	   DB_LIBS              = -L$(DB_HOME)/$(libsubdir) -ldb_cxx
	   DB_RPATH_LINK        = $(call rpathlink,$(DB_HOME)/$(libsubdir))
	else
	   ifeq ($(shell if [ -d /usr/include/db48 -a -d /usr/$(libsubdir)/db48 ] ; then echo yes; fi), yes)
	      DB_FLAGS          = -I/usr/include/db48
	      DB_LIBS           = -L/usr/$(libsubdir)/db48 -ldb_cxx
	   else
	      DB_LIBS           = -ldb_cxx
	   endif
	endif
	EXPAT_FLAGS             = $(if $(EXPAT_HOME),-I$(EXPAT_HOME)/include)
	EXPAT_LIBS              = $(if $(EXPAT_HOME),-L$(EXPAT_HOME)/$(libsubdir)) -lexpat
	EXPAT_RPATH_LINK        = $(if $(EXPAT_HOME),$(call rpathlink,$(EXPAT_HOME)/$(libsubdir)))
	MCPP_LIBS              = $(if $(MCPP_HOME),-L$(MCPP_HOME)/$(libsubdir)) -lmcpp
	MCPP_RPATH_LINK        = $(if $(MCPP_HOME),$(call rpathlink,$(MCPP_HOME)/$(libsubdir)))

	ifeq ($(PLATFORM_HAS_READLINE),yes)
	    ifeq ($(USE_READLINE),yes)
		READLINE_FLAGS  = -DHAVE_READLINE $(if $(READLINE_HOME),-I$(READLINE_HOME)/include)
		READLINE_LIBS   = $(if $(READLINE_HOME),-L$(READLINE_HOME)/$(libsubdir)) -lreadline -lncurses        
	    endif
	endif
	ICECPPFLAGS		= -I$(slicedir)
endif


SLICE2CPPFLAGS		= $(ICECPPFLAGS)

ifeq ($(ice_dir), /usr) 
    CPPFLAGS		= 
    LDFLAGS		= $(LDPLATFORMFLAGS) $(CXXFLAGS)
else
    ifeq ($(MinGW), yes)
		includedir_win  = $(shell $(top_srcdir)/../cpp/config/cygpath-win.sh $(includedir))
		CPPFLAGS	= -I"$(includedir_win)"
		ice_dir_win	= $(shell $(top_srcdir)/../cpp/config/cygpath-win.sh $(ice_dir))
		ifdef ice_src_dist
			LDFLAGS		= $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(libdir)
	    else
			LDFLAGS		= $(LDPLATFORMFLAGS) $(CXXFLAGS) -L"$(ice_dir_win)\$(binsubdir)"
	    endif
    else
		CPPFLAGS	= -I$(includedir)
		ifdef ice_src_dist
			LDFLAGS		= $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(libdir)
	    else
			LDFLAGS		= $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(ice_dir)/$(libsubdir)
	    endif
    endif
endif

ifeq ($(FLEX_NOLINE),yes)
    FLEXFLAGS	       := -L
else
    FLEXFLAGS	       :=
endif

ifeq ($(BISON_NOLINE),yes)
    BISONFLAGS		:= -dvtl
else
    BISONFLAGS		:= -dvt
endif

ifneq ($(MinGW), yes)
ifeq ($(mkshlib),)
    $(error You need to define mkshlib in Make.rules.$(UNAME)) 
endif
endif

ifdef ice_src_dist
	ifeq ($(MinGW), yes)
		SLICEPARSERLIB	= $(bindir)/$(SLICE_LIBNAME).dll
		SLICE2CPP		= $(bindir)/slice2cpp.exe
	else
		SLICEPARSERLIB	= $(libdir)/$(call mklibfilename,Slice,$(VERSION))
		SLICE2CPP		= $(bindir)/slice2cpp
		SLICE2FREEZE	= $(bindir)/slice2freeze
    endif
else
	ifeq ($(MinGW), yes)
		SLICEPARSERLIB	= $(ice_dir)/$(binsubdir)/$(SLICE_LIBNAME).dll
		SLICE2CPP		= $(ice_dir)/$(binsubdir)/slice2cpp.exe
    else
		SLICEPARSERLIB	= $(ice_dir)/$(libsubdir)/$(call mklibfilename,Slice,$(VERSION))
		SLICE2CPP		= $(ice_dir)/$(binsubdir)/slice2cpp
		SLICE2FREEZE	= $(ice_dir)/$(binsubdir)/slice2freeze
     endif
endif

ifeq ($(MinGW), yes)
	CPPFLAGS		:= $(CPPFLAGS) -I"$(THIRDPARTY_HOME_WIN)\include"
	LDFLAGS			:= $(LDFLAGS) -L"$(THIRDPARTY_HOME_WIN)\lib\mingw" -L"$(THIRDPARTY_HOME_WIN)\bin" -L$(libdir) -L$(bindir)
endif

EVERYTHING		= all depend clean install 

.SUFFIXES:
.SUFFIXES:		.cpp .c .o

.cpp.o:
	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $<

.c.o:
	$(CC) -c $(CPPFLAGS) $(CFLAGS) $<

$(HDIR)/%F.h: $(SDIR)/%F.ice $(SLICE2CPP) $(SLICEPARSERLIB)
	rm -f $(HDIR)/$(*F)F.h $(*F)F.cpp
	$(SLICE2CPP) $(SLICE2CPPFLAGS) $<
	mv $(*F)F.h $(HDIR)
	rm -f $(*F)F.cpp

$(HDIR)/%.h %.cpp: $(SDIR)/%.ice $(SLICE2CPP) $(SLICEPARSERLIB)
	rm -f $(HDIR)/$(*F).h $(*F).cpp
	$(SLICE2CPP) $(SLICE2CPPFLAGS) $<
	mv $(*F).h $(HDIR)

%.h %.cpp: %.ice $(SLICE2CPP) $(SLICEPARSERLIB)
	rm -f $(*F).h $(*F).cpp
	$(SLICE2CPP) $(SLICE2CPPFLAGS) $(*F).ice	

%.h %.cpp: %.y
	rm -f $(*F).h $(*F).cpp
	bison $(BISONFLAGS) $<
	mv $(*F).tab.c $(*F).cpp
	mv $(*F).tab.h $(*F).h
	rm -f $(*F).output

%.cpp: %.l
	flex $(FLEXFLAGS) $<
	rm -f $@
	echo '#include <IceUtil/ScannerConfig.h>' >> $@
	cat lex.yy.c >> $@
	rm -f lex.yy.c

all:: $(SRCS) $(TARGETS)

depend:: $(SRCS)  $(patsubst $(SDIR)/%.ice,$(HDIR)/%.h,$(wildcard $(SDIR)/*F.ice)) $(SLICE_SRCS)
	-rm -f .depend .depend.mak
	if test -n "$(SRCS)" ; then \
		$(CXX) -DMAKEDEPEND -M $(CXXFLAGS) $(CPPFLAGS) $(SRCS) | $(ice_dir)/config/makedepend.py; \
	fi
	if test -n "$(SLICE_SRCS)" ; then \
		if test -n "$(HDIR)"; then \
			$(SLICE2CPP) --depend $(SLICE2CPPFLAGS) $(SLICE_SRCS) | $(ice_dir)/config/makedepend.py "\$$(HDIR)"; \
		else \
			$(SLICE2CPP) --depend $(SLICE2CPPFLAGS) $(SLICE_SRCS) | $(ice_dir)/config/makedepend.py; \
		fi \
	fi

clean::
	-rm -f $(TARGETS)
	-rm -f core *.o *.bak

ifneq ($(SLICE_SRCS),)
clean::
	rm -f $(addsuffix .cpp, $(basename $(notdir $(SLICE_SRCS))))
	rm -f $(addsuffix .h, $(basename $(notdir $(SLICE_SRCS))))
endif

ifneq ($(HDIR),)
clean::
	rm -f $(addprefix $(HDIR), $(addsuffix .h, $(basename $(subst $(SDIR),, \
	$(filter $(SDIR)/%.ice, $(SLICE_SRCS))))))
endif

ifneq ($(TEMPLATE_REPOSITORY),)
clean::
	rm -fr $(TEMPLATE_REPOSITORY)
endif

install::