Skip to content

Commit

Permalink
Updated Linux makefile to support both iODBC and unixODBC
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbeach committed Jul 16, 2015
1 parent 877097d commit 75d8d99
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
30 changes: 14 additions & 16 deletions Builds/Gcc.lin/makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
#
#
#
ifndef DEBUG
DEBUG = No
endif
#
.PHONY: all createdirs IscDbc OdbcJdbc OdbcJdbcSetup clean postbuild install uninstall package
#
GCC = g++


#Override default variables for this build
#ARCH = x86
#FIREBIRD=/usr/lib64/firebird
Expand All @@ -53,6 +54,11 @@ ODBCMANAGER = unixODBC
#ODBCMANAGER = iODBC
endif

ifndef ODBCMANAGERDIR
INCLUDEDIR = -I/usr/include -I$(FBINCDIR)
EXTLIBDIR = -L/usr/$(LIB) -L$(FBLIBDIR)
endif

ifeq ($(ARCH),x86_64)
LIB = lib64
else
Expand All @@ -61,18 +67,12 @@ 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)
INCLUDEDIR = -I/usr/include -I$(FBINCDIR) -I$(ODBCMANAGERDIR)/include
EXTLIBDIR = -L/usr/$(LIB) -L$(FBLIBDIR) -L$(ODBCMANAGERDIR)/lib

ifeq (Yes,$(DEBUG))
TARGETDIR = Debug_$(ARCH)
Expand All @@ -91,13 +91,13 @@ 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)
COMPFLAGS = -w -D_REENTRANT -D_PTHREADS -DEXTERNAL -D$(ODBCMANAGER) $(INCLUDEDIR) -I$(FBINCDIR)

ifeq ($(ARCH),x86_64)
COMPFLAGS := -fPIC -m64
COMPFLAGS += -fPIC -m64
LINKFLAGS = -shared -m64
else
COMPFLAGS := -m32
COMPFLAGS += -m32
LINKFLAGS = -shared -m32
endif
#
Expand All @@ -117,7 +117,7 @@ ODBCJDBCDEFFILE = $(ODBCJDBCDIR)/OdbcJdbc.def
ODBCJDBCSDEFFILE= $(ODBCJDBCSETUPDIR)/OdbcJdbcSetup.def
#
ifeq (Yes,$(DEBUG))
DEBUGFLAGS = -D_DEBUG -DDEBUG -DLOGGING -fexceptions
DEBUGFLAGS = -g3 -O0 -D_DEBUG -DDEBUG -DLOGGING -fexceptions
else
DEBUGFLAGS = -DNDEBUG
endif
Expand All @@ -133,8 +133,6 @@ ISCDBCLIB = $(ISCDBCDLL:.so=.a)
ODBCJDBCLIB = $(ODBCJDBCDLL:.so=.a)
ODBCJDBCSETUPLIB= $(ODBCJDBCSETUPDLL:.so=.a)



#
all : createdirs $(ISCDBCDLL) $(ODBCJDBCDLL) $(ODBCJDBCSETUPDLL)
#
Expand Down Expand Up @@ -176,7 +174,7 @@ $(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)
$(GCC) $(LINKFLAGS) $(LIST_ISCDBCOBJ) $(LIST_ODBCJDBCOBJ) $(LIST_ODBCJDBCSETUPOBJ) $(EXTLIBS) $(LIBODBCINST) -o $(ODBCJDBCDLL)
#
postbuild : $(ISCDBCDLL) $(ODBCJDBCDLL) $(ODBCJDBCSETUPDLL)
@-strip -s $(ISCDBCDLL) $(ODBCJDBCDLL) $(ODBCJDBCSETUPDLL)
Expand Down
5 changes: 5 additions & 0 deletions Builds/Gcc.lin/readme.linux
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ regards,
Yves

3)==================================================================

To build the Firebird ODBC driver, the following environment variables should also be set:
ODBCMANAGER (should be set to either "iODBC" or "unixODBC")
ODBCMANAGERDIR (should be set according to the installation folder of the required ODBC driver manager specified above)

14 changes: 4 additions & 10 deletions Builds/makefile.environ
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
#
# examples for solaris
#FBINCDIR = /mnt/third_party/interbase/sun5-2003-3-10/include
#FBLIBDIR = /mnt/third_party/interbase/sun5-2003-3-10/lib
#

# Define ARCH in the calling makefile if you want to target a different architecture
ifndef ARCH
ARCH=$(shell uname -m)
endif

ifndef ODBCMANAGERDIR
$(warning ARCH is $(ARCH))

ifeq ($(ARCH),x86_64)
UNIXODBCDIR = $(shell if [ -d /usr/lib64/unixODBC ]; then echo /usr/lib64/unixODBC; else echo /usr/lib64; fi)
else
UNIXODBCDIR = $(shell if [ -d /usr/lib/unixODBC ]; then echo /usr/lib/unixODBC; else echo /usr/lib; fi)
endif
else
UNIXODBCDIR = $(ODBCMANAGERDIR)
endif

ifndef ODBCMANAGER
# This test is a mess. iodbc isn't even shipped with most distros
# and libodbc.so is not in the UNIXODBCDIR on openSUSE. In fact, only Debian
# and ubuntu still seem to ship iodbc, so lets turn the test around.
# ODBCMANAGER = $(shell if [ -f $(UNIXODBCDIR)/libodbc.so ]; then echo unixODBC; else echo iODBC; fi)
ODBCMANAGER = $(shell if [ -f $(UNIXODBCDIR)/libiodbc.so ]; then echo iODBC; else echo unixODBC; fi)
endif
Expand Down

0 comments on commit 75d8d99

Please sign in to comment.