Menu
Simba Technologies
Simba Technologies

SimbaEngine X SDK 10.1.3
Developing Drivers for Data Stores Without SQL

SimbaEngine X SDK Documentation > Building Your Driver > Upgrading Your Makefile to 10.1

Upgrading Your Makefile to 10.1

In the 10.1 release, the SimbaEngine X SDK introduces a new, simplified makefile system which is very different from the ones used in previous versions. This section explains how to customize and upgrade the sample makefiles in SDK 10.1 for your own custom ODBC drivers.

Updated Name and Location of Makefiles

This section explains the name and location of the new makefiles, including how to invoke them when building your custom ODBC driver.

How to invoke the makefile

We recommend that you invoke the makefile using [DriverFolder]/Source/mk.sh. This script invokes and passes along all the arguments to the makefile, [DriverFolder]/Source/GNUmakefile.

Note:

We do not recommend using [DriverFolder]/Source/GNUmakefile directly, because all object files will be generated directly under the source directory.

The following table summarizes the differences in the makefiles between the 10.1 and 10.0 release.

10.1 10.0
How to invoke the makefile

From the [DriverFolder]/Source folder, type:

./mk.sh

From the [DriverFolder]/Makefile folder, type:

make -f [DriverName].mak

Main entry makefile

[DriverFolder]/Source/GNUmakefile

 

[DriverFolder]/Makefile/[DriverName].mak

Supporting makefiles for each driver
The content of the supporting makefiles for each driver is merged into the entry makefile.

These makefiles are invoked by the entry makefile:

[DriverFolder]/Source/Makefile

[DriverFolder]/Source/Makefile_FLAGS.mak

[DriverFolder]/Source/Makefile_SRCS.mak

Common makefiles shared by all drivers

These makefiles are invoked by the entry makefile:

[SIMBAENGINE_DIR]/Makefiles/kit.mk

[SIMBAENGINE_DIR]/Makefiles/kit.sh

  • Platform.mak, which was used to obtain platform-dependent information, has been replaced by the new kit.sh script file.
  • Settings_XXX.mak, Rule_XXX.mak and Master_Targets.mak have been merged into the new kit.mk file.

These makefiles are invoked by the entry makefile:

[SIMBAENGINE_DIR]/Makefiles/Platform.mak

[SIMBAENGINE_DIR]/Makefiles/Settings_[PlatformName].mak

[SIMBAENGINE_DIR]/Makefiles/Master_Targets.mak

[SIMBAENGINE_DIR]/Makefiles/Rules_[PlatformOrCompilerName].mak

Customizing the Sample Makefiles

The main entry makefile is [DriverFolder]/Source/GNUmakefile. In most cases, this is the only file that you need to modify for your custom ODBC driver. This section includes the following steps:

Step 1: Modify the name and location of the generated binary files

Step 2: Add source files and specify where to find them

Step 3: Add Search Paths for .h files and other compiler/linker flags

Step 1: Modify the name and location of the generated binary files

  1. Modify target.driver = libQuickstart${BITS}.${SO} and target.server = QuickstartServer${BITS} to change the default file name for the driver and server. Note the following:
    • ${BITS} represents the bitness of the current product, typically 32 or 64 (for OSX, it could also be 3264).
    • ${SO} is the default platform-dependendent extension name for shared library. Typically this is dylib for OSX and so for other UNIX systems.
  2. Optionally, update the location. By default, the final product is built under [DriverFolder]/Bin/[PlatformName]/[ConfigurationMode][BitNess], for example [DriverFolder]/Bin/Linux_x86_gcc/debug64. If this location needs to be changed, modify the DESTDIR.bin variable.

Example:

# SDK 10.1 [DriverFolder]/Source/GNUmakefile

### Define the product names

target.driver = libMyCustomDSII${BITS}.${SO}

target.server = MyCustomDSII${BITS}

#...

### Change default install location

DESTDIR.bin = $./../MyDirectory/${}/${MODE}${BITS}

Comparing 10.0 and 10.1 variables for this step:

This table shows how the 10.1 variables in this step map to the 10.0 variables. In 10.0, the variables are in [DriverFolder]/Source/Makefile.

Description Name in 10.1 Name in 10.0

name of driver 

target.driver

TARGET_SO

name of server

target.server

TARGET_BIN

location of generated binary

DESTDIR.bin

TARGET_BIN(SO)_PATH

config mode (release/debug)

MODE

No equivalence

bitness (32/64/3264) 

BITS

BITNESS

suffix of shared libs (so / dylib)

SO

SO_SUFFIX

In 10.0, [DriverFolder]/Source/Makefile uses TARGET_BIN and TARGET_SO to define binary file names. As well, destination directories are specified by TARGET_BIN_PATH and TARGET_SO_PATH, as shown in the following example:

Example:

# SDK 10.0 [DriverFolder]/Source/Makefile

PROJECT = MyCustomDSII

MAKEFILE_PATH = ../Makefiles

ifeq ($(BUILDSERVER),exe)

TARGET_BIN_PATH = ../Bin/$()

TARGET_BIN = $(TARGET_BIN_PATH)/$(PROJECT)_server_<TARGET>

else

TARGET_SO_PATH = ../Bin/$()

TARGET_SO = $(TARGET_SO_PATH)/lib$(PROJECT)_<TARGET>.$(SO_SUFFIX)

endif

#...

Note:

In 10.0, the _<TARGET> suffix in TARGET_BIN(SO) is not a variable. Instead, this is a special string that was replaced by either a _Debug suffix or an empty string (depending on the config mode) in the master makefiles provided under SIMBAENGINE_DIR. By default, both debug and release drivers were generated into the same folder, and relied on suffixes in filenames to differentiate release and debug builds.

In 10.1, binary files do not have a release or debug suffix in their name. Instead, release and debug builds are put under different folders.

Step 2: Add source files and specify where to find them

  1. Modify the file names. To do this, modify the following line to list your own source files:
  2. ${target}: Main_Unix.o QSConnection.o QSDataEngine.o...

    Note:

    This list actually contains object files, so they should all have .o extension, rather than their original .cpp extension names. As well, you do not need to include the paths to the source files.

  3. Modify the target-specific files. If some source files should only be included when the DSII is built as a server, then you must add these files to a ${target.server}: ... dependency list, instead of the common object file list ${target}: ...; As well, when the DSII is build as a driver (a shared library), these files should be added to ${target.driver}: ...
  4. Modify the file paths. To do this modify the following line to include all directories that contain source files for the driver:
  5. drvsrcdirs = $./Common $./Core $./DataEngine $./DataEngine/Metadata

    Note:

    The symbol $. is a variable defined in kit.mk that represents the full path of the directory where GNUmakefile is located, for example [DriverFolder]/Source/. We recommend using this variable instead of using [DriverFolder]/Source/.

    Example:

    Suppose the source files of the MyCustomDSII driver are laid out in the following folder hierarchy:

    Source

    --/MySourceDir1

    ----MyCommonSource1.cpp # Common source files for both driver and server

    ----MyCommonSource2.cpp

    ----MyDriverSpecificSource1.cpp # Driver specific source file.

    ----MyCommonSource1.h # Common header files

    ----MyCommonSource2.h

    ----MyDriverSpecificSource1.h # Driver specific header file.

    --/MyFolder2

    ----MyCommonSource3.cpp

    ----MyServerSpecificSource1.cpp # Server specific source file

    ----MyCommonSource3.h

    ----MyServerSpecificSource1.h # Server specific header file

    --/MyIncludeDir1

    ----MyOtherInclude1.h

    --/MyIncludeDir2

    ----MyOtherInclude2.h

    In this case, the filename and path lists should be configured as follows:

    makefile # SDK 10.1 [DriverFolder]/Source/GNUmakefile #... ### Specify directories to all folders that contain source files for this driver drvsrcdirs = $./MySourceDir1 $./MySourceDir2

  6. Add the source file specific to "driver". For example:
  7. ${target.driver} : MyDriverSpecificSource1.o ${target.driver} : LDLIBS += $(call Mutual, ${CORESDK.a} ${SQLENGINE.a} ${ODBCSDK.a}) #...

  8. Add source file specific to "server". For example:
  9. ${target.server} : MyServerSpecificSource1.o ${target.server} : CPPFLAGS += ${SERVERSDK_CPPFLAGS} #...

  10. Modify source file list shared by both "driver" and "server". For example:
  11. ${target} : MyCommonSource1.o MyCommonSource2.o MyCommonSource3.o #...

Comparing 10.0 and 10.1 variables:

The 10.1 variables involved in this step corresponds to variables in [DriverFolder]/Source/Makefile_SRCS.mak in 10.0:

Description Name in 10.1 Name in 10.0

list of files

listed directly in target rules as .o

COMMON_SRCS

list of directories

drvsrcdirs

COMMON_SRCS

In 10.0, the list of source files, along with their paths, are specified by the COMMON_SRCS variable in [DriverFolder]/Source/Makefile_SRCS.mak.

Example:

# SDK 10.0 [DriverFolder]/Source/Makefile_FLAGS.mak

## Common Sources used to build this project.

COMMON_SRCS = \

Common/QSTableMetadataFile.cpp \

Common/TabbedUnicodeFileReader.cpp \

Core/QSConnection.cpp \

Core/QSDriver.cpp \

Core/QSEnvironment.cpp \

Core/QSStatement.cpp \

DataEngine/QSDataEngine.cpp \

DataEngine/QSMetadataHelper.cpp \

DataEngine/QSTable.cpp \

DataEngine/QSTypeInfoMetadataSource.cpp

Step 3: Add Search Paths for .h files and other compiler/linker flags

  1. Add search paths for headers. To do this, modify the following line to include your own search directories for header files:
  2. ${target} : CPPFLAGS += $(addprefix -I, $. ${drvsrcdirs} $(patsubst %,%/Include, ${drvsrcdirs}) $./Setup)

    In this sample makefile, all directories listed in drvsrcdirs, and an Include directory under each of those directories are automatically added as search directories. You may append additional directories if they are not already in this default list.

  3. Add or modify other compiler and preprocessor flags other than the header file search paths. To do this, add or modify existing target dependency lists that contains ${target}: CXXFLAGS+= and ${target}: CPPFLAGS+=... respectively.
  4. Modify the linker flags. To add or modify linker flags and thirdparty libraries to be linked, add or modify existing target dependency lists that contains ${target}: LDFLAGS+= and ${target}: LDLIBS+=..., respectively.
  5. Modify the target specific flags. If a flag should be added when building driver but not server (or the other way around), then it should be listed under ${target.driver} or ${target.server}, instead of the common ${target}. For example, ${target.server}: LDFLAGS+=... means this LDFLAGS list only applies when building a server.
  6. Modify the config mode specific flags. If a flag should be added only for either "release" or "debug", but not both, then users can append a .release or .debug suffix to the corresponding XXXFLAGS variable to allow such config mode specific flags. For example, CXXFLAGS.release += -myflag1 indicates -myflag1 will only be added to CXXFLAGS in release mode. Similarly, CPPFLAGS.debug += -DMY_MACRO and LDFLAGS.debug += -LMySearchPath indicates -DMY_MACRO and -LMySearchPath will only be added to CPPFLAGS and LDFLAGS in debug mode.

For more information on implicit variables CXXFLAGS, CPPFLAGS, LDFLAGS, LDLIBS used in GNU make, see the GNU make documentation at https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html.

Example:

# SDK 10.1 [DriverFolder]/Source/GNUmakefile`

### Add a flag only for driver

#...

${target.driver} : CPPFLAGS += -DMY_DRIVER_MACRO

### Add preprocessor flags only for driver in debug mode

${target.driver} : LDFLAGS.debug += -LMyLibSearchPath_Driver_Debug/

### Add linker flag only for driver in release mode

${target.driver} : LDFLAGS.release += -LMyLibSearchPath_Driver_Release/

### Add preprocessor flags only for server in release mode

${target.server} : LDFLAGS.release += -LMyLibSearchPath_Server_Release/

### Add a CXXFLAG for both driver and server in all config modes

${target} : CXXFLAGS += -Weffc++

### Add a CXXFLAG for both driver and server only in debug mode

${target} : CPPFLAGS += -DMY_COMMON_MACRO

### Add common search path

${target} : CPPFLAGS += $(addprefix -I, $. ${drvsrcdirs} $./MyIncludeDir1 $./MyIncludeDir2)

#...

Comparing 10.0 and 10.1 variables:

The 10.1 variables involved in this step corresponds to variables in [DriverFolder]/Source/Makefile_FLAGS.mak in 10.0:

Description Name in 10.1 Name in 10.0

list of header search paths

CPPFLAGS

COMMON_CFLAGS

preprocessor flags

CPPFLAGS

COMMON_CFLAGS

compiler flags

CFLAGS, CXXFLAGS

CFLAGS

CXXFLAGSCFLAGS

linker flags

LDFLAGS

BIN_LDFLAGS(_DEBUG)

SO_LDFLAGS(_DEBUG)

In 10.0, compiler and preprocessor flags that are common to all config mode (release/debug) and target type (driver/server) are added to COMMON_CFLAGS in [DriverFolder]/Source/Makefile_FLAGS.mak. As well, COMMON_CFLAGS are always added into the implicit CLFAGS variable. Target-type or config-mode specific flags are conditionally appended to CFLAGS using if-else blocks.

Also in 10.0, linker flags that are common to all config mode and target type are added to COMMON_LDFLAGS. There are four other variables that represent the different combinations of target-type and config-mode specific flags: BIN_LDFLAGS, BIN_LDFLAGS_DEBUG, SO_LDFLAGS and SO_LDFLAGS_DEBUG . In 10.1, the target-type specificity is represented as target-specific rules such as ${target.driver}: LDFLAGS +=..., and the config-mode specificity is represented with a release or debug suffix, such as ${target.server}: LDFLAGS.release +=....

Example

This example shows a 10.0 [DriverFolder]/Source/Makefile_FLAGS.mak file that is roughly equivalent to the 10.1 GNU makefile example above.

# SDK 10.0 [DriverFolder]/Source/Makefile_FLAGS.mak

### Common compiler and preprocessor flags

COMMON_CFLAGS = $(DMFLAGS) \

-I./MySourceDir1 \

-I./MySourceDir2 \

-I./MyIncludeDir1 \

-I./MyIncludeDir2 \

-DMY_COMMON_MACRO \

-Weffc++

ifeq ($(BUILDSERVER),exe)

### Add conditional preprocessor flags for server

CFLAGS = $(COMMON_CFLAGS)

else

CFLAGS = $(COMMON_CFLAGS) -DMY_DRIVER_MACRO

endif

### Define the common linker flags

COMMON_LDFLAGS = ...

#...

ifeq ($(BUILDSERVER),exe)

### Config-mode specific linker flags for server

BIN_LDFLAGS = $(COMMON_LDFLAGS) -LMyLibSearchPath_Server_Release/

BIN_LDFLAGS_DEBUG = $(COMMON_LDFLAGS)

else

### Config-mode specific linker flags for driver

SO_LDFLAGS = $(COMMON_LDFLAGS) -LMyLibSearchPath_Driver_Release/

SO_LDFLAGS_DEBUG = $(COMMON_LDFLAGS) -LMyLibSearchPath_Driver_Debug/

Example Customized Makefile

This example shows a customized GNUmakefile that incorporates the modifications described in this section. All modifications are preceded with a ### comment line.

# Makefile for MyCustomDSII

#--------------- Target Definition

buildtype = $(if ${BUILDSERVER},server,driver)

target = ${target.${buildtype}}

### Change the product names

target.driver = libMyCustomDSII${BITS}.${SO}

target.server = MyCustomDSIIServer${BITS}

### Specify directories to all folders that contain source files for this driver

drvsrcdirs = $./MySourceDir1 $./MySourceDir2

#----------------

.DEFAULT_GOAL := install

clean += ${target.driver} ${target.server}

bin.install : ${target}

### Change default install location

DESTDIR.bin = $./../MyDirectory/${MODE}${BITS}

#---------------- Target dependencies.

### Add source file specific to "driver"

${target.driver} : MyDriverSpecificSource1.o

### Add a flag only for driver

${target.driver} : CPPFLAGS += -DMY_DRIVER_MACRO

### Add a flag only for driver in debug

${target.driver} : CPPFLAGS.debug -DMY_DRIVER_DEBUG_MACRO

### Add preprocessor flags only for driver in debug mode

${target.driver} : LDFLAGS.debug += -LMyLibSearchPath_Driver_Debug/

### Add linker flag only for driver in release mode

${target.driver} : LDFLAGS.release += -LMyLibSearchPath_Driver_Release/

${target.driver} : LDLIBS += $(call Mutual, ${CORESDK.a} ${SQLENGINE.a} ${ODBCSDK.a})

${target.driver} : LDFLAGS += $(call LD.soname,$@)

${target.driver} : LDFLAGS += ${LD.exports}

### Add source file specific to "server"

${target.server} : MyServerSpecificSource1.o

### Add preprocessor flags only for server in release mode

${target.server} : LDFLAGS.release += -LMyLibSearchPath_Server_Release/

### Add preprocessor flags only for server in debug mode

${target.server} : LDFLAGS.release += -LMyLibSearchPath_Server_Debug/

### Add a third party library only for server

${target.server} : LDLIBS += -mythirdpartylib

### Add release-specific flags linker flag

${target.driver} : LDFLAGS.release += -lmy_release_lib

${target.server} : CPPFLAGS += ${SERVERSDK_CPPFLAGS}

${target.server} : LDLIBS += $(call Mutual, ${CORESDK.a} ${SQLENGINE.a} ${SERVERSDK.a})

${target.server} : LDLIBS += ${OPENSSL_LDLIBS}

${target.server} :; ${LINK.o} -o $@ $^ ${LDLIBS}

### Modify source file list shared by both "driver" and "server"

${target} : MyCommonSource1.o MyCommonSource2.o MyCommonSource3.o

### Add a CXXFLAG for both driver and server in all config modes

${target} : CXXFLAGS += -Weffc++

### Add a CXXFLAG for both driver and server only in debug mode

${target} : CPPFLAGS.debug += -DMY_COMMON_DEBUG_MACRO

### Remove some default search paths and add user search paths

${target} : CPPFLAGS += $(addprefix -I, $. ${drvsrcdirs} $./MyIncludeDir1 $./MyIncludeDir2)

${target} : CPPFLAGS += ${CORESDK_CPPFLAGS} ${SQLENGINE_CPPFLAGS} ${EXPAT_FLAGS}

${target} : LDLIBS += ${ICU_LDLIBS}

#--- Define search paths

vpath %.cpp ${drvsrcdirs}

vpath %.mm ${drvsrcdirs}