-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile.linux
226 lines (205 loc) · 7.15 KB
/
makefile.linux
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
#
# 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.
#
#
# 07-Aug-2012: Contribution by Embarcadero Technologies Inc.
# Changes for InterBase ODBC driver
#
#
DEBUG = No
#
.PHONY: all createdirs IscDbc OdbcJdbc OdbcJdbcSetup clean postbuild install uninstall package
DEFAULT_USR_LIB = /usr/lib
#
GCC = g++
#Override default variables for this build
#ARCH = x86
#INTERBASE=/opt/interbase
ARCH = x86_64
INTERBASE=/opt/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
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
LIBODBCINST = -lodbcinst
INCLUDEDIR = -I/usr/include
EXTLIBDIR = -L/usr/$(LIB)
endif
INCLUDEDIR := -I$(FBINCDIR) -I/usr/include/odbc $(INCLUDEDIR)
EXTLIBDIR := -L$(FBLIBDIR -L$(UNIXODBCDIR) $(EXTLIBDIR)
ifeq (Yes,$(DEBUG))
TARGETDIR = Debug_$(ARCH)
else
TARGETDIR = Release_$(ARCH)
endif
#
BUILDDIR = $(TARGETDIR)/obj
#
DRVTMPL = ../../Install/Linux/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))
#
COMPFLAGS = -g -w -D_REENTRANT -D_PTHREADS -DEXTERNAL -D$(ODBCMANAGER) $(INCLUDEDIR) -I$(FBINCDIR)
ifeq ($(ARCH),x86_64)
COMPFLAGS += -fPIC -m64
LINKFLAGS = -shared -m64
else
COMPFLAGS += -m32
LINKFLAGS = -shared -m32
endif
#
#LINKFLAGS = -rdynamic -export-dynamic -shared
EXTLIBS = $(EXTLIBDIR) -lcrypt -ldl
#
#ISCDBC = libIscDbc.so
ISCDBCDLL = $(TARGETDIR)/$(ISCDBC)
ODBCJDBC = lib$(LIB_ROOT_NAME).so
ODBCJDBCDLL = $(TARGETDIR)/$(ODBCJDBC)
#ODBCJDBCSETUP = libOdbcIBS.so
ODBCJDBCSETUPDLL= $(TARGETDIR)/$(ODBCJDBCSETUP)
ISCDBCDEFFILE = $(ISCDBCDIR)/IscDbc.def
ODBCJDBCDEFFILE = $(ODBCJDBCDIR)/OdbcJdbc.def
ODBCJDBCSDEFFILE= $(ODBCJDBCSETUPDIR)/OdbcJdbcSetup.def
#
ifeq (Yes,$(DEBUG))
DEBUGFLAGS = -D_DEBUG -DDEBUG -DLOGGING -fexceptions
else
DEBUGFLAGS = -DNDEBUG
endif
#
$(BUILDDIR)/%.o: $(ISCDBCDIR)/%.cpp
$(GCC) $(COMPFLAGS) $(DEBUGFLAGS) -c $(firstword $<) -o $@
#
$(BUILDDIR)/%.o: $(ODBCJDBCDIR)/%.cpp
$(GCC) $(COMPFLAGS) $(DEBUGFLAGS) -c $(firstword $<) -o $@
#
ISCDBCLIB = $(ISCDBCDLL:.so=.a)
ODBCJDBCLIB = $(ODBCJDBCDLL:.so=.a)
ODBCJDBCSETUPLIB= $(ODBCJDBCSETUPDLL:.so=.a)
# Common modules for Tests
TESTCOMMON = Print.o JString.o Odbc.o
#
all : SimpleTest SqlTables
# SimpleTest
SimpleTest : SimpleTest.o $(TESTCOMMON)
$(GCC) SimpleTest.o $(TESTCOMMON) $(COMPFLAGS) -l$(LIB_ROOT_NAME) $(LIBODBCINST) -o $@
# SqlTables
SqlTables : SqlTables.o $(TESTCOMMON)
$(GCC) SqlTables.o $(TESTCOMMON) $(COMPFLAGS) -l$(LIB_ROOT_NAME) $(LIBODBCINST) -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)
# $(GCC) $(LINKFLAGS) $(LIST_ISCDBCOBJ) $(EXTLIBS) --def $(ISCDBCDEFFILE) -o $(ISCDBCDLL)
#
#$(ODBCJDBCDLL) : $(LIST_ODBCJDBCOBJ)
# ar crs $(ODBCJDBCLIB) $(LIST_ODBCJDBCOBJ)
# $(GCC) $(LINKFLAGS) $(BUILDDIR)/JString.o $(BUILDDIR)/Mutex.o $(LIST_ODBCJDBCOBJ) $(EXTLIBS) $(LIBODBCINST) --def $(ODBCJDBCDEFFILE) -o $(ODBCJDBCDLL)
#
$(ODBCJDBCSETUPDLL) : $(LIST_ODBCJDBCSETUPOBJ)
# ar crs $(ODBCJDBCSETUPLIB) $(LIST_ODBCJDBCSETUPOBJ)
# $(GCC) $(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)
$(GCC) $(LINKFLAGS) $(LIST_ISCDBCOBJ) $(LIST_ODBCJDBCOBJ) $(LIST_ODBCJDBCSETUPOBJ) $(EXTLIBS) $(LIBODBCINST) --def $(ODBCJDBCDEFFILE) -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/Linux/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/Linux -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
#