summaryrefslogtreecommitdiff
path: root/ruby/config/Make.rules
blob: de8f5b9acc0ce6e0352bd524f78f58d764a72bd3 (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
# **********************************************************************
#
# Copyright (c) 2003-2016 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 set
# to change the runpath added to Ice executables. The default is
# platform dependent (Linux only, on OS X the embedded runpath is always
# based on @loader_path).
#
#embedded_runpath_prefix ?= /opt/Ice-$(VERSION_MAJOR).$(VERSION_MINOR)

#
# Define embedded_runpath as no if you don't want any RPATH added to
# the executables (Linux only, on OS X we always add a runpath).
#
embedded_runpath 	?= yes

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

#OPTIMIZE		= yes

#
# Define LP64 as yes if you want to build in 64 bit mode on a platform
# that supports both 32 and 64 bit.
#
#LP64			:= yes

#
# If you have not built Ice for C++ from the cpp subdirectory or if
# you have installed the Ice for C++ development kit in a
# non-standard location, set the ICE_HOME to the installation directory.
#
#ICE_HOME		= C:\Program Files\ZeroC\Ice-$(VERSION)

#
# If the Ruby interpreter is in your PATH, the settings below will
# work properly in most cases. If you want to use a particular
# installation of Ruby, set RUBY_HOME with the installation directory.
#

ifneq ($(RUBY_HOME),)
    RUBY = $(RUBY_HOME)/bin/ruby
else
    RUBY = ruby
endif

ifeq ($(RUBY18), yes)
    RUBY_MAJOR_VERSION = $(shell $(RUBY) -e 'require "rbconfig"; puts Config::expand("$$(MAJOR)")')
    RUBY_MINOR_VERSION = $(shell $(RUBY) -e 'require "rbconfig"; puts Config::expand("$$(MINOR)")')
	ifeq ("$(RUBY_MAJOR_VERSION).$(RUBY_MINOR_VERSION)", "1.8")
        RUBY_FLAGS = -I$(shell $(RUBY) -e 'require "rbconfig"; puts Config::expand("$$(archdir)")')
	else
        RUBY_FLAGS = -I$(shell $(RUBY) -e 'require "rbconfig"; puts Config::expand("$$(rubyhdrdir)")') \
                     -I$(shell $(RUBY) -e 'require "rbconfig"; puts Config::expand("$$(rubyhdrdir)/$$(arch)")')
    endif

    LIB_DIR = $(shell $(RUBY) -e 'require "rbconfig"; puts Config::expand("$$(libdir)")')

    RUBY_SHARED = $(shell $(RUBY) -e 'require "rbconfig"; puts Config::MAKEFILE_CONFIG["ENABLE_SHARED"]')

    ifeq ("$(RUBY_SHARED)","yes")
        RUBY_LIB = $(shell $(RUBY) -e 'require "rbconfig"; puts Config::expand("-l$$(RUBY_SO_NAME)")')
    else
        RUBY_LIB = $(shell $(RUBY) -e 'require "rbconfig"; puts Config::expand("-l$$(RUBY_SO_NAME)-static")')
    endif
    RUBY_LIBS = -L$(LIB_DIR) $(RUBY_LIB)
else
    RUBY_MAJOR_VERSION = $(shell $(RUBY) -e 'require "rbconfig"; puts RbConfig::expand("$$(MAJOR)")')
    RUBY_MINOR_VERSION = $(shell $(RUBY) -e 'require "rbconfig"; puts RbConfig::expand("$$(MINOR)")')

    RUBY_LIB_DIR = $(shell $(RUBY) -e 'require "rbconfig"; puts RbConfig::expand("$$(rubylibdir)")')
    RUBY_ARCH = $(shell $(RUBY) -e 'require "rbconfig"; puts RbConfig::expand("$$(arch)")')

    ifeq ("$(RUBY_MAJOR_VERSION).$(RUBY_MINOR_VERSION)", "1.8")
        RUBY_FLAGS = -I$(shell $(RUBY) -e 'require "rbconfig"; puts RbConfig::expand("$$(archdir)")')
    else
        RUBY_FLAGS = -I$(shell $(RUBY) -e 'require "rbconfig"; puts RbConfig::expand("$$(rubyhdrdir)")')
        RUBY_CONFIG_DIR = $(shell $(RUBY) -e 'require "rbconfig"; puts RbConfig::expand("$$(includedir)/$$(arch)/ruby-$$(ruby_version)")')
        ifneq ($(wildcard $(RUBY_CONFIG_DIR)/ruby/config.h),)
            RUBY_FLAGS := $(RUBY_FLAGS) -I$(RUBY_CONFIG_DIR)
        else
            RUBY_CONFIG_DIR = $(shell $(RUBY) -e 'require "rbconfig"; puts RbConfig::expand("$$(rubyhdrdir)/$$(arch)")')
            ifneq ($(wildcard $(RUBY_CONFIG_DIR)/ruby/config.h),)
                RUBY_FLAGS := $(RUBY_FLAGS) -I$(RUBY_CONFIG_DIR)
            endif
        endif
    endif

    RUBY_LIBS = $(shell $(RUBY) -e 'require "rbconfig"; puts RbConfig::expand("$$(LIBRUBYARG)")')

    ifneq ($(findstring MINGW, $(shell uname)),)
        RUBY_BIN_DIR = $(shell $(RUBY) -e 'require "rbconfig"; puts RbConfig::expand("$$(bindir)")')
        RUBY_LIBS := -L$(RUBY_BIN_DIR) $(RUBY_LIBS)
    else
        LIB_DIR = $(shell $(RUBY) -e 'require "rbconfig"; puts RbConfig::expand("$$(libdir)")')
        ifneq ($(LIB_DIR),)
            RUBY_LIBS := -L$(LIB_DIR) $(RUBY_LIBS)
        endif
    endif
endif

#
# The build architectures for gcc based builds. The format of these
# build flags are OS dependent. For example, under 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

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

#
# Common definitions
#
ice_language     = ruby
ice_require_cpp  = yes

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

libdir			= $(top_srcdir)/ruby
ifeq ($(UNAME),MINGW)
ifneq ($(findstring x64,$(RUBY_ARCH)),)
install_rubydir		= $(prefix)/ruby/x64
install_libdir		= $(prefix)/ruby/x64
else
install_rubydir		= $(prefix)/ruby
install_libdir		= $(prefix)/ruby
endif
else
ifndef usr_dir_install
install_rubydir		= $(prefix)/ruby
install_libdir		= $(prefix)/ruby
else
install_rubydir		= $(RUBY_LIB_DIR)
install_libdir		= $(RUBY_LIB_DIR)/$(RUBY_ARCH)
endif
endif

install_bindir		= $(prefix)/$(binsubdir)

#
# Platform specific definitions
#
ifeq ($(shell test -f $(top_srcdir)/config/Make.rules.$(UNAME) && echo 0),0)
    configdir = $(top_srcdir)/config
else
    configdir = $(top_srcdir)/../cpp/config
endif

ifndef usr_dir_install
    RPATH_DIR   = $(prefix)/$(libsubdir)
endif

include	 $(configdir)/Make.rules.$(UNAME)

ifdef ice_src_dist
    ICE_LIB_DIR = -L$(ice_cpp_dir)/$(libsubdir)
    ICE_FLAGS 	= -I$(ice_cpp_dir)/include
else
    ICE_LIB_DIR	= -L$(ice_dir)/$(libsubdir)
    ICE_FLAGS	= -I$(ice_dir)/include
endif
ICE_LIBS = $(ICE_LIB_DIR) -lIceDiscovery -lIce -lIceSSL -lSlice -lIceUtil

CPPFLAGS		=
ICECPPFLAGS		= -I$(slicedir)
SLICE2RBFLAGS		= $(ICECPPFLAGS)
LDFLAGS			= $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(libdir)

ifdef ice_src_dist
    SLICEPARSERLIB	= $(ice_cpp_dir)/$(libsubdir)/$(call mklibfilename,Slice,$(VERSION))
	SLICE2RB	= $(top_srcdir)/config/s2rb.rb
else
    SLICEPARSERLIB	=
    SLICE2RB		= slice2rb
endif

EVERYTHING		= all depend clean install

.SUFFIXES:
.SUFFIXES:		.cpp .o .rb

all:: $(SRCS)

%.rb: $(SDIR)/%.ice
	rm -f $(*F).rb
	$(SLICE2RB) $(SLICE2RBFLAGS) $<
	@mkdir -p .depend
	@$(SLICE2RB) $(SLICE2RBFLAGS) $< > .depend/$(*F).ice.d

.cpp.o:
	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $<
	@mkdir -p .depend
	@$(CXX) -DMAKEDEPEND -MM $(CPPFLAGS) $< > .depend/$(*F).d

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

all:: $(SRCS) $(TARGETS)

include $(wildcard .depend/*.d)

install::