-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile.darwin
295 lines (268 loc) · 10.1 KB
/
makefile.darwin
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
#
# The contents of this file are subject to the Initial
# Developer's Public License Version 1.0 (the "License");
# you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
# https://www.firebirdsql.org/en/initial-developer-s-public-license-version-1-0/
#
# Software distributed under the License is distributed on
# an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
# express or implied. See the License for the specific
# language governing rights and limitations under the License.
#
#
# The Original Code was created by Vladimir Tsvigun.
#
# Copyright (c) 2003 Vladimir Tsvigun
# All Rights Reserved.
#
# 18-Jun-2024: Contribution by Embarcadero Technologies Inc.
# Changes for InterBase ODBC driver
# Cloned makefile.linux to makefile.darwin, and enabled support for macOS
#
#
.SUFFIXES: .o .c .cpp
.c.o:
$(CC) -c $(COMPFLAGS) $(VERSION_FLAG) $<
.cpp.o:
$(CPP_CMD) -c $(COMPFLAGS) $(VERSION_FLAG) $<
DEBUG = No
#
.PHONY: all createdirs IscDbc OdbcJdbc OdbcJdbcSetup clean postbuild install uninstall package
DEFAULT_USR_LIB = /usr/local/lib
#
# use clang/clang++ instead of gcc toolchain
CC=$(shell xcrun --sdk macosx --find clang)
CXX=$(shell xcrun --sdk macosx --find clang++)
MY_XCODE_VERSION=$(shell xcodebuild -version | grep Xcode | cut -d'.' -f1)
ifeq ("$(MY_XCODE_VERSION)","Xcode 4")
SDK_PATH_ROOT=/Developer/SDKs/MacOSX10.6.sdk
else
SDK_PATH_ROOT=$(shell xcrun --sdk macosx --show-sdk-path)
endif
ifeq ("$(MY_XCODE_VERSION)","Xcode 14")
# x86_64 and arm64 build machine on developer machine, MacBook-Air, running Xcode 14. Build for 10.9 min version
UNIVERSAL_64BIT=YES
LIBSTDCPP=NO
#SYS_ARCH_FLAGS= -arch x86_64 -arch arm64
SYS_ARCH_FLAGS= -arch arm64
#SYS_ARCH_FLAGS= -arch x86_64
else ifeq ("$(MY_XCODE_VERSION)","Xcode 12")
# x86_64 and arm64 build machine on macmini-m1-01, running Xcode 12. Build for 10.9 min version
UNIVERSAL_64BIT=YES
LIBSTDCPP=NO
SYS_ARCH_FLAGS= -arch x86_64 -arch arm64
#SYS_ARCH_FLAGS= -arch x86_64
# x86 and x86_64 build if working with something other than Xcode 12. Build for 10.8 min version
else ifeq ("$(MY_XCODE_VERSION)","Xcode 11")
UNIVERSAL_64BIT=NO
LIBSTDCPP=NO
SYS_ARCH_FLAGS= -arch x86_64
else ifeq ("$(MY_XCODE_VERSION)","Xcode 9")
# Use the following when Sanctuary and OpenSSL 1.1.1 builds have libc++ support
UNIVERSAL_64BIT=YES
LIBSTDCPP=NO
#UNIVERSAL_64BIT=NO
#LIBSTDCPP=YES
SYS_ARCH_FLAGS= -arch x86_64
else
UNIVERSAL_64BIT=NO
LIBSTDCPP=YES
SYS_ARCH_FLAGS= -arch x86_64
endif
# Use libstdc++ if working with older builds; libc++ otherwise
ifeq ("$(LIBSTDCPP)","YES")
MACOS_MIN_VERSION=10.8
CPP_STDLIB= -lstdc++
else
MACOS_MIN_VERSION=10.9
CPP_STDLIB= -lc++
endif
CPP_CMD=$(CXX)
# If Mac OS/Darwin release is version 10, then use the SystemStubs library for some
# dummy definitions. Otherwise (starting from version Lion (11)), there is no need
# for this SystemStubs library
# http://opensource.apple.com/source/SystemStubs/SystemStubs-6/dummy.c
SYSTEMSTUBS_LIB=
OSRELEASE=$(shell uname -r | cut -d'.' -f1)
ifeq ($(OSRELEASE),9) # Mac OS X Leopard
SYSTEMSTUBS_LIB=-lSystemStubs
endif
ifeq ($(OSRELEASE),10) # Mac OS X Snow Leopard
SYSTEMSTUBS_LIB=-lSystemStubs
endif
#Override default variables for this build
#ARCH = x86
#INTERBASE=/Applications/interbase
ARCH = arm64
INTERBASE=/Applications/interbase_ib2020
# Get version info
MAJOR_VERSION = $(shell cat ../../SetupAttributes.h | grep "define MAJOR_VERSION" | cut -f 3)
MINOR_VERSION = $(shell cat ../../SetupAttributes.h | grep "define MINOR_VERSION" | cut -f 3)
REVISION = $(shell cat ../../SetupAttributes.h | grep "define REVNO_VERSION" | cut -f 3)
BUILD_NUMBER = $(shell cat ../../WriteBuildNo.h | grep "define BUILDNUM_VERSION" | cut -f 3)
#and use it
LIB_ROOT_NAME = OdbcIB
PACKAGE_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(REVISION).$(BUILD_NUMBER)
LIB_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(REVISION)
PACKAGE_NAME = $(LIB_ROOT_NAME)-$(PACKAGE_VERSION).tar
#
# Start build
#
include ../Builds/makefile.sources
include ../Builds/makefile.environ
#
ifndef ODBCMANAGER
ODBCMANAGER = unixODBC
#ODBCMANAGER = iODBC
endif
ifeq ($(ARCH),x86_64)
#LIB = lib64
LIB = lib
else
LIB = lib
endif
ifeq (iODBC,$(ODBCMANAGER))
LIBODBCINST = -liodbcinst
INCLUDEDIR = -I/usr/local/include \
-I/usr/include
EXTLIBDIR = -L/usr/local/$(LIB) \
-L/usr/$(LIB)
else
UNIXODBCDIR = /opt/homebrew/Cellar/unixodbc/2.3.12
LIBODBCINST = -L$(UNIXODBCDIR)/lib -lodbcinst
INCLUDEDIR = -I/usr/include
EXTLIBDIR = -L/usr/local/$(LIB)
endif
INCLUDEDIR := -I$(FBINCDIR) -I$(UNIXODBCDIR)/include -I/usr/include/odbc $(INCLUDEDIR) -I$(SDK_PATH_ROOT)/usr/include -F$(SDK_PATH_ROOT)/System/Library/Frameworks
EXTLIBDIR := -L$(FBLIBDIR) -L$(UNIXODBCDIR) $(EXTLIBDIR)
ifeq (Yes,$(DEBUG))
TARGETDIR = Debug_$(ARCH)
COMPFLAGS = -fpic -Wno-return-type -Wno-incompatible-pointer-types -g -w -D$(ODBCMANAGER) $(INCLUDEDIR) -I$(FBINCDIR) -mmacosx-version-min=$(MACOS_MIN_VERSION) $(SYS_ARCH_FLAGS)
else
TARGETDIR = Release_$(ARCH)
COMPFLAGS = -O2 -fpic -Wno-return-type -Wno-incompatible-pointer-types -w -D$(ODBCMANAGER) $(INCLUDEDIR) -I$(FBINCDIR) -mmacosx-version-min=$(MACOS_MIN_VERSION) $(SYS_ARCH_FLAGS)
endif
#
BUILDDIR = $(TARGETDIR)/obj
#
DRVTMPL = ../../Install/darwin/DriverTemplate.ini
LIST_ISCDBCSRC = $(addprefix $(ISCDBCDIR)/, $(ISCDBCSRC))
LIST_ISCDBCOBJ = $(addprefix $(BUILDDIR)/, $(ISCDBCSRC:.cpp=.o))
LIST_ODBCJDBCSRC = $(addprefix $(ODBCJDBCDIR)/, $(ODBCJDBCSRC))
LIST_ODBCJDBCOBJ = $(addprefix $(BUILDDIR)/, $(ODBCJDBCSRC:.cpp=.o))
LIST_ODBCJDBCSETUPSRC = $(addprefix $(ODBCJDBCDIR)/, $(ODBCJDBCSETUPSRC_LINUX))
LIST_ODBCJDBCSETUPOBJ = $(addprefix $(BUILDDIR)/, $(ODBCJDBCSETUPSRC_LINUX:.cpp=.o))
#
#
LINKFLAGS = $(SYS_ARCH_FLAGS) -mmacosx-version-min=$(MACOS_MIN_VERSION) -Wl,-syslibroot,$(SDK_PATH_ROOT)
#
EXTLIBS = -lc -lz $(CPP_STDLIB) -lgcc_s.1 -lm -ldl -lSystem $(SYSTEMSTUBS_LIB)
#
#ISCDBC = libIscDbc.dylib
ISCDBCDLL = $(TARGETDIR)/$(ISCDBC)
ODBCJDBC = lib$(LIB_ROOT_NAME).dylib
ODBCJDBCDLL = $(TARGETDIR)/$(ODBCJDBC)
#ODBCJDBCSETUP = libOdbcIBS.dylib
ODBCJDBCSETUPDLL= $(TARGETDIR)/$(ODBCJDBCSETUP)
ISCDBCDEFFILE = $(ISCDBCDIR)/IscDbc.def
ODBCJDBCDEFFILE = $(ODBCJDBCDIR)/OdbcJdbc.def
ODBCJDBCSDEFFILE= $(ODBCJDBCSETUPDIR)/OdbcJdbcSetup.def
#
ifeq (Yes,$(DEBUG))
DEBUGFLAGS = -D_DEBUG -DDEBUG -DLOGGING -fexceptions -g
else
DEBUGFLAGS = -DNDEBUG
endif
#
$(BUILDDIR)/%.o: $(ISCDBCDIR)/%.cpp
$(CC) $(COMPFLAGS) $(DEBUGFLAGS) -c $(firstword $<) -o $@
#
$(BUILDDIR)/%.o: $(ODBCJDBCDIR)/%.cpp
$(CC) $(COMPFLAGS) $(DEBUGFLAGS) -c $(firstword $<) -o $@
#
ISCDBCLIB = $(ISCDBCDLL:.dylib=.a)
ODBCJDBCLIB = $(ODBCJDBCDLL:.dylib=.a)
ODBCJDBCSETUPLIB= $(ODBCJDBCSETUPDLL:.dylib=.a)
# Common modules for Tests
TESTCOMMON = Print.o JString.o Odbc.o
#
#all : createdirs $(ISCDBCDLL) $(ODBCJDBCDLL) $(ODBCJDBCSETUPDLL)
all : SimpleTest SqlTables
# SimpleTest
SimpleTest : SimpleTest.o $(TESTCOMMON)
$(CPP_CMD) SimpleTest.o $(TESTCOMMON) $(COMPFLAGS) -L$(EXTLIBDIR) -l$(LIB_ROOT_NAME) $(LIBODBCINST) $(LINKFLAGS) $(EXTLIBS) -o $@
# SqlTables
SqlTables : SqlTables.o $(TESTCOMMON)
$(CPP_CMD) SqlTables.o $(TESTCOMMON) $(COMPFLAGS) -L$(EXTLIBDIR) -l$(LIB_ROOT_NAME) $(LIBODBCINST) $(LINKFLAGS) $(EXTLIBS) -o $@
#
# If required, print out the version info
getVersion :
$(warning MAJOR_VERSION is $(MAJOR_VERSION) )
$(warning MINOR_VERSION is $(MINOR_VERSION) )
$(warning REVISION is $(REVISION) )
$(warning BUILD_NUMBER is $(BUILD_NUMBER) )
#
# Silently creates the target and build directories
createdirs :
@-mkdir $(TARGETDIR)
@-mkdir $(BUILDDIR)
#
# Silently cleanup and deletes the target and build directories
clean :
@-rm -fr $(TARGETDIR)
@-rm -f *.o
#
IscDbc : $(ISCDBCDLL)
OdbcJdbc : $(ODBCJDBCDLL)
OdbcJdbcSetup : $(ODBCJDBCSETUPDLL)
#
# Build the library from the object modules
#
$(ISCDBCDLL) : $(LIST_ISCDBCOBJ)
# ar crs $(ISCDBCLIB) $(LIST_ISCDBCOBJ)
# $(CC) $(LINKFLAGS) $(LIST_ISCDBCOBJ) $(EXTLIBS) --def $(ISCDBCDEFFILE) -o $(ISCDBCDLL)
#
#$(ODBCJDBCDLL) : $(LIST_ODBCJDBCOBJ)
# ar crs $(ODBCJDBCLIB) $(LIST_ODBCJDBCOBJ)
# $(CC) $(LINKFLAGS) $(BUILDDIR)/JString.o $(BUILDDIR)/Mutex.o $(LIST_ODBCJDBCOBJ) $(EXTLIBS) $(LIBODBCINST) --def $(ODBCJDBCDEFFILE) -o $(ODBCJDBCDLL)
#
$(ODBCJDBCSETUPDLL) : $(LIST_ODBCJDBCSETUPOBJ)
# ar crs $(ODBCJDBCSETUPLIB) $(LIST_ODBCJDBCSETUPOBJ)
# $(CC) $(LINKFLAGS) $(LIST_ODBCJDBCSETUPOBJ) $(EXTLIBS) -o $(ODBCJDBCSETUPDLL)
#
$(ODBCJDBCDLL) : $(ISCDBCDLL) $(ODBCJDBCSETUPDLL) $(LIST_ODBCJDBCOBJ)
ar crs $(ODBCJDBCLIB) $(LIST_ISCDBCOBJ)
ar crs $(ODBCJDBCLIB) $(LIST_ODBCJDBCOBJ)
ar crs $(ODBCJDBCLIB) $(LIST_ODBCJDBCSETUPOBJ)
$(CPP_CMD) $(LINKFLAGS) -Wl,-dylib,-install_name,libOdbcIB.dylib $(LIST_ISCDBCOBJ) $(LIST_ODBCJDBCOBJ) $(LIST_ODBCJDBCSETUPOBJ) $(EXTLIBS) $(LIBODBCINST) -o $(ODBCJDBCDLL)
#
postbuild : $(ISCDBCDLL) $(ODBCJDBCDLL) $(ODBCJDBCSETUPDLL)
#@-strip -s $(ISCDBCDLL) $(ODBCJDBCDLL) $(ODBCJDBCSETUPDLL)
@-tar -cf OdbcJdbc_Snapshot.tar $(ISCDBCDLL) $(ODBCJDBCDLL) $(ODBCJDBCSETUPDLL)
@-gzip -9 -S .gz OdbcJdbc_Snapshot.tar
#
install :
cp $(ODBCJDBCDLL) $(UNIXODBCDIR)/$(ODBCJDBC).$(LIB_VERSION)
ln -s $(UNIXODBCDIR)/$(ODBCJDBC).$(LIB_VERSION) $(UNIXODBCDIR)/$(ODBCJDBC)
ln -s $(UNIXODBCDIR)/$(ODBCJDBC).$(LIB_VERSION) $(UNIXODBCDIR)/$(ODBCJDBC).$(MAJOR_VERSION)
#
uninstall :
@-rm -f $(UNIXODBCDIR)/$(ODBCJDBC)*.*
#
package :
#-strip -s $(ISCDBCDLL) $(ODBCJDBCDLL) $(ODBCJDBCSETUPDLL)
-rm $(PACKAGE_NAME).gz
chmod 740 ../../Install/darwin/install.sh
tar -C $(TARGETDIR) -cvf OdbcJdbcLibs.tar $(ISCDBC) $(ODBCJDBC) $(ODBCJDBCSETUP)
tar -C ../../Install/HtmlHelp --exclude=CVS -cvf OdbcJdbcDocs.tar html/
tar -C ../../Install -uf OdbcJdbcDocs.tar ReleaseNotes_v2.0.html
cat $(DRVTMPL) | grep -v "^Driver.*=.*" >$(DRVTMPL).tmp && echo "Driver = $(UNIXODBCDIR)/$(ODBCJDBC)" >>$(DRVTMPL).tmp && mv $(DRVTMPL).tmp $(DRVTMPL)
tar -C ../../Install/darwin -cf $(PACKAGE_NAME) install.sh readme.txt DriverTemplate.ini InterBaseDSNTemplate.ini
tar -uf $(PACKAGE_NAME) OdbcJdbcLibs.tar OdbcJdbcDocs.tar
rm OdbcJdbcLibs.tar OdbcJdbcDocs.tar
gzip -9 -S .gz $(PACKAGE_NAME)
#
#
# End
#