Oratcl on Linux /w Oracle 8.0.5 (makefile attached)

From: Tom Poindexter <tpoindex_at_nyx.nyx.net>
Date: 1998/10/08
Message-ID: <907863323.121585_at_iris.nyx.net>


Just a note to pass along from Martin Vetter <vetter_at_fokus.gmd.de>:

> Hi Tom,
>
> I'm sure someone out there already notified you,
> but just in case I would like to make sure you know:
>
> Oratcl 2.5 run's on linux,
> using Oracle 8 pre-production for linux!
>
> Both statically and dynamically linked versions
> seem to work fine - even "package require Oratcl"
> in a vanilla tclsh does what it's expected to do...
>
> At least as far as I tested it until now ;^)
>
> ...
> And if it's of interest to you,
> I send you the Makefile I used
> (borrowed mostly from yours 8^)
>
> Thank you for your time,
> and have a good one,
>
> Martin
>

Note to comp.lang.tcl readers. Oracle has released a version of it's 8.0.5 database product for Linux, joining Sybase and Informix offerings. You can download a copy for development from

        http://technet.oracle.com

You will need to use the following Makefile, as created by Martin. You will probably need to adjust some of the location definitions.

The upcoming Oratcl-3.0 release will include Oracle 8.0x configure and Makefile support.

-----cut here------

###############################################################################
#
# Oratcl-2.5
# Makefile for Oratcl
#

# Shamelessly stolen from
# Tom Poindexter

ORATCL_VERSION = 2.5
ORATCL_LIBVER = 25 SHELL = /bin/sh

###############################################################################
#
# set the following defines as needed:

prefix = /usr/local/tcl
exec_prefix = /usr/local/tcl

#------------------------------------------------------------------------------
# define where Oratcl should put binaries, libraries, and mapages #
BIN_DIR      = $(exec_prefix)/bin
LIB_DIR      = $(exec_prefix)/lib
MAN_DIR      = $(prefix)/man
MANN_DIR     = $(MAN_DIR)/mann

#------------------------------------------------------------------------------
# define where X11 include and libraries are located

X11_INC_DIR = /usr/X11R6/include
X11_LIB_DIR = /usr/X11R6/lib

#------------------------------------------------------------------------------
# define where Tcl include and libraries are located
# Oratcl assumes that Tcl, Tk (and possibly Extended Tcl) are installed # in the same locations

TCL_INC_DIR = /usr/local/tcl/include
TCL_LIB_DIR = /usr/local/tcl/lib

#------------------------------------------------------------------------------
# define Tcl, Tk libraries and extra libs

TCL_VERSION = 8.0
TK_VERSION = 8.0 TCL_LIB_SPEC = -ltcl8.0
TCL_LIBS = -ldl -lm

TK_LIB_SPEC = -ltk8.0
TK_LIBS = -lX11

#------------------------------------------------------------------------------
# define where Oracle libraries are located

ORACLE_HOME = /usr/local/oracle/product/8.0.5

ORA_LIB_DIR	= $(ORACLE_HOME)/lib
ORA_RLIB_DIR	= $(ORACLE_HOME)/rdbms/lib

ORATCL_VER	= -DVERSION7
ORATCL_72FEATURES = -DNONBLOCK_CURSOR
ORATCL_DEFS	= $(ORATCL_VER) $(ORATCL_72FEATURES)

OCILIB_OBJ	= \
$(ORA_LIB_DIR)/naect.o\
$(ORA_LIB_DIR)/naeet.o\
$(ORA_LIB_DIR)/naedhs.o\

$(ORA_LIB_DIR)/nautab.o\
$(ORA_RLIB_DIR)/defopt.o

OCILIB_A = \

$(ORA_LIB_DIR)/libclient.a\
$(ORA_LIB_DIR)/libcommon.a\
$(ORA_LIB_DIR)/libcore4.a\
$(ORA_LIB_DIR)/libepc.a\
$(ORA_LIB_DIR)/libepcpt.a\
$(ORA_LIB_DIR)/libgeneric.a\
$(ORA_LIB_DIR)/libmm.a\
$(ORA_LIB_DIR)/libncr.a\
$(ORA_LIB_DIR)/libnetv2.a\
$(ORA_LIB_DIR)/libnetwork.a\
$(ORA_LIB_DIR)/libnlsrtl3.a\
$(ORA_LIB_DIR)/libnttcp.a

OCILIB		= $(OCILIB_OBJ) $(OCILIB_A)

# objects which need to be removed,
# otherwise there are ambigious defined symbols

OCIIGNORE = nautab1.o

# other machine specific libs that oracle might need.  these are initially
# populated from ORACLE_HOME/rdbms/lib/sysliblist 
# by configure.  adjust as needed.

ORATCL_LIBS	= 

# some versions of oracle require explicit linking with libc,  without -lc,
# the link appears fine, but executing 'oralogon' causes a core dump. default # is to define libc explicitly.

LIBC = -lc

# for direct linking

ORA_LIB_CORE	= -lnlsrtl3 -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3
ORA_LIB_NET	= -lnetv2 -lnttcp -lnetwork -lncr -lnetv2 -lnttcp -lnetwork
ORA_LIB_CLIENT	= -lclient -lcommon -lgeneric
ORA_LIB_MM	= -lmm
ORA_LIB_EPC	= -lepc -lepcpt
ORA_LIBS	= \
	$(ORA_OBJ_NAU) $(ORA_OBJ_NAE) $(ORA_OBJ_DEFOPT) \
	$(ORA_LIB_NET) $(ORA_LIB_CLIENT) $(ORA_LIB_MM) $(ORA_LIB_CORE) \
	$(ORA_LIB_NET) $(ORA_LIB_CLIENT) $(ORA_LIB_EPC) $(ORA_LIB_CORE) \
	$(ORA_LIB_CLIENT) $(ORA_LIB_CORE)

#------------------------------------------------------------------------------
# define names for Oratcl library files, static and shared
ORATCL_LIB	= libOratcl$(ORATCL_LIBVER).a
ORATCL_LIB_SH	= libOratcl$(ORATCL_LIBVER)$(TCL_SHLIB_SUFFIX)

ORATCL_LIB_SPEC		= $(ORATCL_LIB)
ORATCL_LIB_SPEC_SH	= -L$(ORA_LIB_DIR) -lclntsh $(ORA_LIB_DIR)/scorept.o -lcore4 -lnlsrtl3
ORATCL_LD_FLAGS		= $(ORATCL_LIB_SPEC) $(ORATCL_LIBS)
ORATCL_LD_FLAGS_SH	= -L. -lOratcl$(ORATCL_LIBVER)

#------------------------------------------------------------------------------
# compiler and flags from tcl config, so don't change CC # without some thought, otherwise you might break the shared flags.  
CC		= gcc
OPT_DEBUG	= -g -O2

TCL_CONFIG	= -DHAVE_GETCWD=1 -DHAVE_OPENDIR=1 -DHAVE_STRSTR=1 -DHAVE_STRTOL=1 -DHAVE_TMPNAM=1 -DHAVE_WAITPID=1 -DHAVE_UNISTD_H=1 -DUSE_TERMIOS=1 -DHAVE_SYS_TIME_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_TZNAME=1 -DHAVE_TIMEZONE_VAR=1 -DTCL_USE_TIMEZONE_VAR=1 -DHAVE_ST_BLKSIZE=1 -Dstrtod=fixstrtod -DSTDC_HEADERS=1 -DNO_UNION_WAIT=1 -DNEED_MATHERR=1 -Dvfork=fork -DHAVE_SIGNED_CHAR=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_SYS_FILIO_H=1

TCL_DEFS	= $(OPT_DEBUG) -I$(TCL_INC_DIR) $(TCL_CONFIG)
TK_DEFS		= $(TCL_DEFS) -I$(X11_INC_DIR)

TCL_LD_FLAGS	= -L$(TCL_LIB_DIR) $(TCL_LIB_SPEC) $(TCL_LIBS)
TK_LD_FLAGS	= -L$(TCL_LIB_DIR) -L$(X11_LIB_DIR) $(TK_LIB_SPEC) $(TK_LIBS) $(TCL_LIB_SPEC) $(TCL_LIBS)

TCL_SHLIB_SUFFIX  = .so
TCL_SHLIB_CFLAGS  = -fPIC
TCL_SHLIB_LD      = gcc -shared

TCL_SHLIB_LD_LIBS = ${LIBS}
#------------------------------------------------------------------------------
# define names for Oratcl tclsh/tcl executable # define names for Oratcl wish/wishx executable
EXEC_TCL	= oratclsh
EXEC_WISH	= orawish

#------------------------------------------------------------------------------
# OTHER_LD_SEARCH_FLAGS so that dynamic loader will look for Oracle libraries
# NOTE: these are hacked from TCL_LD_SEARCH_FLAGS, and may need tweaking
# for a particular platform.  LIB_INSTALL_DIR used in tcl7.5,
# LIB_RUNTIME_DIR used in tcl7.5p1+.  If your linker doesn't like a colon
# separated path, then you will have to figure out what works, or 
# possible leave off the second lib. The inclusion of the Tcl lib dir is
# for the occasion you are building a static lib, but a shared Tcl lib is # found during linking.
LIB_INSTALL_DIR        = $(TCL_LIB_DIR):$(ORA_LIB_DIR):$(X11_LIB_DIR)
LIB_RUNTIME_DIR        = $(LIB_INSTALL_DIR)
OTHER_LD_SEARCH_FLAGS  =

# Include tcl's cc flags for dynamic lib search path.  This is in case you
# are builing a static binary for Oratcl, but have both static and dynamic
# tcl libraries, of which the loader will probably prefer the dynamic verisons.
# Without this flag, the resulting binary won't have lib search information.
# Note that TCL_LD_SEARCH_FLAGS only works when LIB_RUNTIME_DIR has been set # as above.  

TCL_LD_SEARCH_FLAGS = -Wl,-R${LIB_RUNTIME_DIR}

#------------------------------------------------------------------------------
# define man page

MAN_PAGE = oratcl.n

#------------------------------------------------------------------------------
# define ranlib command for systems that need it; touch otherwise

RANLIB = ranlib

#------------------------------------------------------------------------------
# how to install
INSTALL         = install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA    = ${INSTALL} -m 644

#
# end of defines

#
###############################################################################

all:	${EXEC_TCL} ${EXEC_TCL}-static ${EXEC_WISH} ${EXEC_WISH}-static

#------------------------------------------------------------------------------
# how to build objects for oratcl and libOratcl
oratcl.o:	../generic/oratcl.c
		$(CC) -o $_at_ -c $(TCL_DEFS) $(ORATCL_DEFS) $<

oratcl..o:	../generic/oratcl.c
		$(CC) -o $_at_ -c $(TCL_DEFS) $(ORATCL_DEFS) $(TCL_SHLIB_CFLAGS) $<

$(ORATCL_LIB):	oratcl.o $(OCILIB)
		_at_echo "building static library $(ORATCL_LIB)"
		-rm $(ORATCL_LIB)
		-mkdir libtmp
		-rm -f libtmp/*
		_at_echo "  copying oratcl.o"
		-cp oratcl.o libtmp
		-for O in $(OCILIB_OBJ) ; do		\
		    echo "  copying $$O" ;		\
		    cp $$O libtmp ;			\
		 done ;
		-for L in $(OCILIB_A) ; do 		\
		    cd libtmp ;				\
		    echo "  extracting objects from $$L" ; \
		    ar x $$L ;				\
		    cd .. ;				\
		 done ;
		-for O in $(OCIIGNORE) ; do		\
		   echo "  removing $$O" ; 		\
		   rm -f $$O ;				\
		 done ;
		_at_echo "  create library $(ORATCL_LIB)"
		-cd libtmp ; \
		 ar cr ../$(ORATCL_LIB) *.o ; \
		 cd ..
		_at_echo "  clean up object files"
		-rm -f libtmp/*
		-rmdir libtmp

$(ORATCL_LIB_SH): oratcl..o
		$(TCL_SHLIB_LD) -o $_at_ $< $(TCL_LD_SEARCH_FLAGS) $(ORATCL_LIB_SPEC_SH)

#------------------------------------------------------------------------------
# how to build objects for standard tcl
TCL_APPINIT	= $(TCL_LIB_DIR)/tcl$(TCL_VERSION)/tclAppInit.c
TK_APPINIT	= $(TCL_LIB_DIR)/tk$(TK_VERSION)/tkAppInit.c

tclAppInit.c:	$(TCL_APPINIT)
		sed -f orainit.sed < $(TCL_APPINIT) > tclAppInit.c

tkAppInit.c:	$(TK_APPINIT)
		sed -f orainit.sed < $(TK_APPINIT) > tkAppInit.c

tclAppInit.o:	tclAppInit.c
		$(CC) -c $(TCL_DEFS) tclAppInit.c

tkAppInit.o:	tkAppInit.c
		$(CC) -c $(TK_DEFS) tkAppInit.c

#------------------------------------------------------------------------------
# how to build static executables and man page

$(EXEC_TCL)-static: $(ORATCL_LIB) tclAppInit.o

                $(CC) -o $_at_ tclAppInit.o $(TCL_LD_FLAGS) $(TCL_LD_SEARCH_FLAGS) $(ORATCL_LD_FLAGS)

$(EXEC_TCL):	$(ORATCL_LIB_SH) tclAppInit.o
		$(CC) -o $_at_ tclAppInit.o $(TCL_LD_FLAGS) $(TCL_LD_SEARCH_FLAGS) $(ORATCL_LD_FLAGS_SH)

$(EXEC_WISH)-static: $(ORATCL_LIB) tkAppInit.o
		$(CC) -o $_at_ tkAppInit.o $(TK_LD_FLAGS) $(TCL_LD_SEARCH_FLAGS) $(ORATCL_LD_FLAGS)

$(EXEC_WISH):	$(ORATCL_LIB_SH) tkAppInit.o
		$(CC) -o $_at_ tkAppInit.o $(TK_LD_FLAGS) $(TCL_LD_SEARCH_FLAGS) $(ORATCL_LD_FLAGS_SH)

$(MAN_PAGE):	../doc/oratcl.man
		cp ../doc/oratcl.man $(MAN_PAGE)

#------------------------------------------------------------------------------
# install targets

install: install-static install-shared install-man

install-shared:	$(ORATCL_LIB_SH) $(EXEC_TCL) $(EXEC_WISH)
		_at_echo installing $(ORATCL_LIB_SH)
		$(INSTALL_PROGRAM) $(ORATCL_LIB_SH) $(LIB_DIR)/$(ORATCL_LIB_SH)
		_at_echo installing $(EXEC_TCL)
		$(INSTALL_PROGRAM) $(EXEC_TCL) $(BIN_DIR)/$(EXEC_TCL)
		_at_echo installing $(EXEC_WISH)
		$(INSTALL_PROGRAM) $(EXEC_WISH) $(BIN_DIR)/$(EXEC_WISH)
		_at_echo installing pkgIndex.tcl
		-mkdir $(LIB_DIR)/Oratcl$(ORATCL_LIBVER)
		$(INSTALL_PROGRAM) pkgIndex.tcl $(LIB_DIR)/Oratcl$(ORATCL_LIBVER)/pkgIndex.tcl

install-static:	$(ORATCL_LIB)
		_at_echo installing $(LIB_ORATCL)
		$(INSTALL_DATA) $(ORATCL_LIB) $(LIB_DIR)/$(ORATCL_LIB)

install-static-bin: $(EXEC_TCL)-static $(EXEC_WISH)-static
		_at_echo installing $(EXEC_TCL)-static
		$(INSTALL_PROGRAM) $(EXEC_TCL)-static $(BIN_DIR)/$(EXEC_TCL)
		_at_echo installing $(EXEC_WISH)-static
		$(INSTALL_PROGRAM) $(EXEC_WISH)-static $(BIN_DIR)/$(EXEC_WISH)

install-man:	$(MAN_PAGE)
		_at_echo installing $(MAN_PAGE)
		$(INSTALL_DATA) $(MAN_PAGE) $(MANN_DIR)/$(MAN_PAGE)

install-wosql:
		sed -e '1s_at_^.*$$@#!$(BIN_DIR)/$(W_EXEC)@p' < samples/wosql > $(BIN_DIR)/wosql
		chmod 755 $(BIN_DIR)/wosql

clean:
		rm -f $(EXEC_TCL) $(EXEC_TCL)-static $(EXEC_WISH) $(EXEC_WISH)-static $(MAN_PAGE) \
		      oratcl.o oratcl..o $(ORATCL_LIB) $(ORATCL_LIB_SH)  \
		      tclXAppInit.c tkXAppInit.c tclXAppInit.o tkXAppInit.o     \
		      tclAppInit.c  tkAppInit.c  tclAppInit.o  tkAppInit.o  \
		      config.cache config.log

###############################################################################
# end of Makefile
###############################################################################







-- 
Tom Poindexter
tpoindex_at_nyx.net
http://www.nyx.net/~tpoindex/
Received on Thu Oct 08 1998 - 00:00:00 CEST

Original text of this message