summaryrefslogtreecommitdiff
path: root/config/Make.common.rules
blob: 31c6eba9b7be5b0ae9bbd19102b2b01767f2dd6b (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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# **********************************************************************
#
# Copyright (c) 2003-2015 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.
#
# **********************************************************************

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

SHELL		= /bin/sh
VERSION_MAJOR   = 3
VERSION_MINOR   = 7
VERSION_PATCH   = 0
VERSION         = 3.7.0
SHORT_VERSION   = 3.7
SOVERSION	= 37

INSTALL		= cp -fp
INSTALL_PROGRAM	= ${INSTALL}
INSTALL_LIBRARY	= ${INSTALL}
INSTALL_DATA	= ${INSTALL}

OBJEXT		= .o

UNAME		:= $(shell uname)
MACHINE_TYPE	:= $(shell uname -m)

#
# Ensure ice_language has been set by the file that includes this one.
#
ifndef ice_language
$(error ice_language must be defined)
endif

ifeq ($(USE_BIN_DIST),yes)
ice_bin_dist = 1
endif

ifeq ($(UNAME),Darwin)
    usr_dir = /usr/local
else
    usr_dir = /usr
endif

#
# usr_dir_install means we want to install with a /usr style layout.
#
ifeq ($(prefix), /usr)
    usr_dir_install = 1
endif

ifeq ($(prefix), /usr/local)
    usr_dir_install = 1
endif

#
# A /usr style layout can be forced by setting USR_DIR_INSTALL=yes.
#
ifeq ($(USR_DIR_INSTALL),yes)
    usr_dir_install = 1
endif

ifeq ($(UNAME),SunOS)
    ifeq ($(MACHINE_TYPE),sun4u)
       lp64suffix	= /64
       lp64binsuffix	= /sparcv9
    endif
    ifeq ($(MACHINE_TYPE),sun4v)
       lp64suffix       = /64
       lp64binsuffix    = /sparcv9
    endif
    ifeq ($(MACHINE_TYPE),i86pc)
	lp64suffix	= /amd64
	lp64binsuffix	= /amd64
    endif
endif

ifeq ($(UNAME),HP-UX)
    lp64suffix		= /pa20_64
    lp64binsuffix	= /pa20_64
endif

ifeq ($(UNAME),Linux)
   ifeq ($(MACHINE_TYPE),x86_64)
      #
      # Ubuntu.
      #
      ifeq ($(shell test -d $(usr_dir)/lib/x86_64-linux-gnu && echo 0),0)
         lp64suffix	= /x86_64-linux-gnu
      endif

      #
      # Rhel/SLES
      #
      ifeq ($(shell test -d $(usr_dir)/lib64 && echo 0),0)
          lp64suffix	= 64
      endif

      ifeq ($(LP64),)
          LP64      	= yes
      endif
   endif
   ifneq ($(STATICLIBS),yes)
	ifneq ($(LP64),yes)
	    binsuffix     = 32
	endif
    endif
endif

ifeq ($(shell test -d $(usr_dir)/lib/i386-linux-gnu && echo 0),0)
    lp32suffix     = /i386-linux-gnu
endif

ifeq ($(CPP11_MAPPING),yes)
    cpp11libdirsuffix		= /c++11
    cpp11libsuffix		= ++11
    cpp11sonamedir		= ../
    binsuffix 		:= $(binsuffix)$(cpp11libsuffix)
endif

ifneq ($(findstring MINGW,$(UNAME)),)
    UNAME	                := MINGW
    lp64suffix                  := /x64
    COMPILER_MACHINE := $(shell $(CXX) -dumpmachine)
    ifeq ($(COMPILER_MACHINE),x86_64-w64-mingw32)
        LP64                    := yes
    endif
endif

ifeq ($(LP64),yes)
    libsubdir		:= lib$(lp64suffix)
    binsubdir		:= bin$(lp64binsuffix)
else
    libsubdir		:= lib$(lp32suffix)
    binsubdir		:= bin
    #
    # For x86 builds in x86_64 machines lib64subdir points to the x86_64 lib
    # directory and libsubdir to the x86 lib directory.
    #
    ifeq ($(MACHINE_TYPE),x86_64)
	lib64subdir               = lib$(lp64suffix)
    endif
endif

#
# The following variables might also be defined:
#
# - slice_translator: the name of the slice translator required for the build.
#   Setting this variable is required when building source trees other than the
#   the source distribution (e.g.: the demo sources).
#
# - ice_require_cpp: define this variable to check for the presence of the C++
#   dev kit and check for the existence of the include/Ice/Config.h header.
#

#
# First, check if we're building a source distribution.
#
# If building from a source distribution, ice_dir is defined to the
# top-level directory of the source distribution and ice_cpp_dir is
# defined to the directory containing the C++ binaries and headers to
# use to build the sources.
#
ifndef ice_bin_dist
    ifeq ($(shell test -d $(top_srcdir)/../$(ice_language) && echo 0),0)
        ice_dir = $(top_srcdir)/..
        ice_src_dist = 1

        #
        # When building a source distribution, if ICE_HOME is specified, it takes precedence over
        # the source tree for building the language mappings. For example, this can be used to
        # build the Python language mapping using the translators from the distribution specified
        # by ICE_HOME.
        #
	ifneq ($(ICE_HOME),)
	    ifeq ($(shell test -d $(ICE_HOME)/cpp/bin && echo 0), 0)
	        #
		# ICE_HOME is pointing at the source distribution, so we just ignore it.
		#
	        ice_cpp_dir = $(ice_dir)/cpp
	    else
	        ifdef slice_translator
		    ifneq ($(shell test -f $(ICE_HOME)/$(binsubdir)/$(slice_translator) && echo 0), 0)
$(error Unable to find $(slice_translator) in $(ICE_HOME)/$(binsubdir), please verify ICE_HOME is properly configured and Ice is correctly installed.)
		    endif
		    ifeq ($(shell test -f $(ice_dir)/cpp/bin/$(slice_translator) && echo 0), 0)
$(warning Found $(slice_translator) in both ICE_HOME/bin and $(ice_dir)/cpp/bin, ICE_HOME/bin/$(slice_translator) will be used!)
		    endif
		    ice_cpp_dir = $(ICE_HOME)
	        else
$(warning Ignoring ICE_HOME environment variable to build current source tree.)
		    ice_cpp_dir = $(ice_dir)/cpp
	        endif
	    endif
	else
	    ice_cpp_dir = $(ice_dir)/cpp
	endif

    endif
    ifeq ($(shell test -d $(top_srcdir)/ice/$(ice_language) && echo 0),0)
        ice_dir = $(top_srcdir)/ice
        ice_src_dist = 1

        #
        # When building a source distribution, if ICE_HOME is specified, it takes precedence over
        # the source tree for building the language mappings. For example, this can be used to
        # build the Python language mapping using the translators from the distribution specified
        # by ICE_HOME.
        #
	ifneq ($(ICE_HOME),)
	    ifdef slice_translator
		ifneq ($(shell test -f $(ICE_HOME)/$(binsubdir)/$(slice_translator) && echo 0), 0)
$(error Unable to find $(slice_translator) in $(ICE_HOME)/$(binsubdir), please verify ICE_HOME is properly configured and Ice is correctly installed.)
		endif
		ifeq ($(shell test -f $(ice_dir)/cpp/bin/$(slice_translator) && echo 0), 0)
$(warning Found $(slice_translator) in both ICE_HOME/bin and $(ice_dir)/cpp/bin, ICE_HOME/bin/$(slice_translator) will be used!)
		endif
		ice_cpp_dir = $(ICE_HOME)
	    else
$(warning Ignoring ICE_HOME environment variable to build current source tree.)
		ice_cpp_dir = $(ice_dir)/cpp
	    endif
	else
	    ice_cpp_dir = $(ice_dir)/cpp
	endif
    endif
endif

#
# Then, check if we're building against a binary distribution.
#
ifndef ice_src_dist

    ifndef slice_translator
        slice_translator = slice2cpp
    endif

    ifneq ($(ICE_HOME),)
        ifneq ("$(ice_language)", "python")
            ifneq ($(shell test -f $(ICE_HOME)/$(binsubdir)/$(slice_translator) && echo 0), 0)
$(error Unable to find $(slice_translator) in $(ICE_HOME)/$(binsubdir), please verify ICE_HOME is properly configured and Ice is correctly installed.)
            endif
        endif
        ice_dir = $(ICE_HOME)
    else
        ifeq ($(shell test -f $(top_srcdir)/bin/$(slice_translator) && echo 0), 0)
            ice_dir = $(top_srcdir)
        else
	        ifeq ($(shell test -f $(usr_dir)/bin/$(slice_translator) && echo 0), 0)
                ice_dir = $(usr_dir)
                ifeq ($(shell test -f /opt/Ice-$(VERSION)/bin/$(slice_translator) && echo 0), 0)
                   $(warning Found $(slice_translator) in both $(usr_dir)/bin and /opt/Ice-$(VERSION)/bin, $(usr_dir)/bin/$(slice_translator) will be used!)
                endif
            else
                ifeq ($(shell test -f /opt/Ice-$(VERSION)/$(binsubdir)/$(slice_translator) && echo 0), 0)
                    ice_dir = /opt/Ice-$(VERSION)
                endif
            endif
        endif
    endif

    ifndef ice_dir
$(error Unable to find a valid Ice distribution, please verify ICE_HOME is properly configured and Ice is correctly installed.)
    endif
    ice_bin_dist = 1
    ice_cpp_dir = $(ice_dir)
endif

#
# If ice_require_cpp is defined, ensure the C++ headers exist
#
ifeq ("$(ice_language)", "python")
    ifdef ice_bin_dist
        skip_cpp_check = 1
    endif
endif

ifndef skip_cpp_check
    ifeq ("$(ice_require_cpp)", "yes")
        ifdef ice_src_dist
            ice_cpp_header = $(ice_cpp_dir)/include/Ice/Ice.h
        else
            ice_cpp_header = $(ice_dir)/include/Ice/Ice.h
        endif
        ifneq ($(shell test -f $(ice_cpp_header) && echo 0),0)
    $(error Unable to find the C++ header file $(ice_cpp_header), please verify ICE_HOME is properly configured and Ice is correctly installed.)
        endif
    endif
endif

#
# Clear the embedded runpath prefix if building against RPM distribution.
#
ifeq ($(ice_dir), $(usr_dir))
    embedded_runpath_prefix =
endif

#
# Set slicedir to the path of the directory containing the Slice files.
#
ifeq ($(ice_dir), $(usr_dir))
    slicedir = $(usr_dir)/share/slice
else
    slicedir = $(ice_dir)/slice
endif

#
# Installation location for slice and doc files.
#
ifdef usr_dir_install
    install_slicedir = $(prefix)/share/Ice-$(VERSION)/slice
    install_docdir = $(prefix)/share/Ice-$(VERSION)
else
    install_slicedir = $(prefix)/slice
    install_docdir = $(prefix)
endif

#
# Set environment variables for the Slice translator.
#
ifneq ($(ice_dir), $(usr_dir))
    ifdef ice_src_dist
        ice_lib_dir = $(ice_cpp_dir)/$(libsubdir)
    else
        ifndef lib64subdir
            ice_lib_dir = $(ice_dir)/$(libsubdir)
        else
            ice_lib_dir = $(ice_dir)/$(lib64subdir)
        endif
    endif

    #
    # We always set library path because the build needs to work
    # whe slice compiler was built without RPATH
    #
    ifeq ($(UNAME),Linux)
        export LD_LIBRARY_PATH := $(ice_lib_dir):$(LD_LIBRARY_PATH)
    endif

    ifeq ($(UNAME),SunOS)
        ifeq ($(LP64),yes)
            export LD_LIBRARY_PATH_64 := $(ice_lib_dir):$(LD_LIBRARY_PATH_64)
        else
            export LD_LIBRARY_PATH := $(ice_lib_dir):$(LD_LIBRARY_PATH)
	endif
    endif

    ifeq ($(UNAME),AIX)
        export LIBPATH := $(ice_lib_dir):$(LIBPATH)
    endif

    ifeq ($(UNAME),HP-UX)
        ifeq ($(LP64),yes)
	    export LD_LIBRARY_PATH := $(ice_lib_dir)$(lp64dir):$(SHLIB_PATH)
	else
	    export SHLIB_PATH := $(ice_lib_dir):$(LD_LIBRARY_PATH)
	endif
    endif

    ifeq ($(UNAME),FreeBSD)
        export LD_LIBRARY_PATH := $(ice_lib_dir):$(LD_LIBRARY_PATH)
    endif

    ifeq ($(UNAME),OSF1)
        export LD_LIBRARY_PATH := $(ice_lib_dir):$(LD_LIBRARY_PATH)
    endif

    ifneq ($(findstring MINGW,$(UNAME)),)
	set PATH := $(ice_lib_dir);$(PATH)
    endif
endif


#
# Default functions for shared library names (we have to defined them here
# for the SLICE2PARSERLIB dependency)
#
ifeq ($(mklibfilename),)
    ifeq ($(UNAME),Darwin)
        mklibfilename   = $(if $(2),lib$(1)$(cpp11libsuffix).$(2).dylib,lib$(1)$(cpp11libsuffix).dylib)
    else
        mklibfilename	= $(if $(2),lib$(1)$(cpp11libsuffix).so.$(2),lib$(1)$(cpp11libsuffix).so)
    endif
endif

ifeq ($(mksoname),)
    ifeq ($(UNAME),Darwin)
        mksoname    = $(if $(2),lib$(1)$(cpp11libsuffix).$(2).dylib,lib$(1).dylib)
    else
        mksoname    = $(if $(2),lib$(1)$(cpp11libsuffix).so.$(2),lib$(1).so)
    endif
endif

ifeq ($(mklibname),)
    ifeq ($(STATICLIBS),yes)
	mklibname	= lib$(1)$(cpp11libsuffix).a
    else
        ifeq ($(UNAME),Darwin)
	    mklibname   = lib$(1).dylib
	else
	    mklibname	= lib$(1).so
	endif
    endif
endif

ifndef mklibtargets
    ifeq ($(STATICLIBS),yes)
	mklibtargets	= $(3)
    else
	mklibtargets	= $(1) $(2) $(3)
    endif
endif

ifeq ($(installlib),)
    ifeq ($(STATICLIBS),yes)
	installlib = $(INSTALL) $(2)/$(5) $(1); \
		     chmod a+rx $(1)/$(5)
    else
	installlib = $(INSTALL) $(2)/$(3) $(1); \
		     rm -f $(1)/$(4); ln -s $(3) $(1)/$(4); \
		     rm -f $(1)$(cpp11libdirsuffix)/$(5); ln -s $(cpp11sonamedir)$(4) $(1)$(cpp11libdirsuffix)/$(5); \
		     chmod a+rx $(1)/$(3)
    endif
endif

ifeq ($(installdata),)
    installdata		= $(INSTALL_DATA) $(1) $(2); \
			  chmod a+r $(2)/$(notdir $(1))
endif

ifeq ($(installprogram),)
    installprogram	= $(INSTALL_PROGRAM) $(1) $(2); \
			 chmod a+rx $(2)/$(notdir $(1))
endif

ifeq ($(mkdir),)
    mkdir		= $(if $(2),mkdir $(2) $(1),mkdir $(1)); \
			  chmod a+rx $(1)
endif

all::

ifeq ($(wildcard $(top_srcdir)/../ICE_LICENSE.txt),)
    TEXT_EXTENSION =
else
    TEXT_EXTENSION = .txt
endif

install-common::
	@if test ! -d $(DESTDIR)$(prefix) ; \
	then \
	    echo "Creating $(prefix)..." ; \
	    $(call mkdir,$(DESTDIR)$(prefix), -p) ; \
	fi

	@if test ! -d $(DESTDIR)$(install_slicedir) ; \
	then \
	    echo "Creating $(DESTDIR)$(install_slicedir)..." ; \
	    $(call mkdir, $(DESTDIR)$(install_slicedir), -p) ; \
	    if test ! -z "$(usr_dir_install)" ; \
	    then \
		    ln -s Ice-$(VERSION)/slice $(DESTDIR)/$(prefix)/share/slice ; \
	    fi ; \
	    cd $(top_srcdir)/../slice ; \
	    for subdir in * ; \
	    do \
	        echo "Copying slice/$$subdir to $(DESTDIR)$(install_slicedir)..." ; \
	        cp -fpr $$subdir $(DESTDIR)$(install_slicedir) ; \
	    done ; \
	    fi

	@if test ! -f $(DESTDIR)$(install_docdir)/ICE_LICENSE$(TEXT_EXTENSION) ; \
	then \
	    $(call installdata,$(top_srcdir)/../ICE_LICENSE$(TEXT_EXTENSION),$(DESTDIR)$(install_docdir)) ; \
	fi

	@if test ! -f $(DESTDIR)$(install_docdir)/LICENSE$(TEXT_EXTENSION) ; \
	then \
	    $(call installdata,$(top_srcdir)/../LICENSE$(TEXT_EXTENSION),$(DESTDIR)$(install_docdir)) ; \
	fi