原来只需在makefile中追加include $(ORACLE_HOME)/precomp/lib/env_precomp.mk,其他一切按照makefile的书写规则即可,CODE也是需要指定的,尤其Oracle缺省并不是ansi_c
以下是sample:
include $(ORACLE_HOME)/precomp/lib/env_precomp.mk
LIBDIR=lib32
CC = /opt/SUNWspro/bin/cc
CFLAGS= -c -g
OCFLAGS= code=ansi_c line=yes sqlcheck=semantics
TARGET= test
OBJS= test.o
.SUFFIXES: .pc .c .o
$(TARGET): $(OBJS)
$(CC) -o $@ $(OBJS) -L$(LIBHOME) $(PROLDLIBS)
.pc.c:
$(PROC) $(ORADEF) $(PROCFLAGS) iname=$*
.pc.o:
$(PROC) $(ORADEF) $(PROCFLAGS) iname=$* $(ORADEF)
$(CC) $(CFLAGS) $*.c
.c.o:
$(CC) $(CFLAGS) $*.c
clean :
$(RM) -f $(TARGET) $(OBJS) $(TARGET:%=%.c)
==========================下面是个正式项目makefile文件==================
include $(ORACLE_HOME)/precomp/lib/env_precomp.mk
COMPILE_MODE = 64
APP_DIR = ..
OBJ_DIR = $(APP_DIR)/obj
CC_DIR = $(APP_DIR)/cc
EXE_DIR = $(APP_DIR)/bin
SRC_DIR = $(APP_DIR)/src
ORA_PRE_HEAD= $(ORACLE_HOME)/precomp/public/
ORA_OCI_HEAD = $(ORACLE_HOME)/rdbms/public/
ORA_LIB_DIR = $(ORACLE_HOME)/lib
ORA_LIB_FLAG = -lclntsh -locci
OCICPP_LIB_HEAD = $(APP_DIR)/include/ocicpp
OCICPP_LIB_DIR = $(APP_DIR)/lib
OCICPP_LIB_FLAG = -locicpp$(COMPILE_MODE)
DCETL_HEAD = $(APP_DIR)/include/dcetl
DCETL_LIB_DIR = $(APP_DIR)/lib
DCETL_LIB_FLAG = -ldcetl$(COMPILE_MODE)
CXX = xlC -DISUNIX -DDONT_HAVE_STRUPR
COMPILE_FLAGS = -c -q$(COMPILE_MODE) -qstaticinline -bhalt:5 -lnoquiet -g -bhalt:5 -bmaxdata:0x100000000 -DCOMPILE_MODE=$(COMPILE_MODE)
LINKING_FLAGS = -q$(COMPILE_MODE) -qstaticinline -bhalt:5 -g -bmaxdata:0x100000000
PROCPLSFLAGS = code=cpp cpp_suffix=cc sqlcheck=syntax parse=none lname=err
ARFLAGS = -v -q
# Command ----------------------------------------------------------------------
PROC = proc
########################### compile cpp #############################################
all : CommonDemo DbDemo DCEtlDemo PathTest
APP_NAME = CommonDemo DbDemo DCEtlDemo Test PathTest
$(APP_NAME) :
$(CXX) $(COMPILE_FLAGS) $(APP_DIR)/$@.cpp \
-I$(ORA_OCI_HEAD) -I$(OCICPP_LIB_HEAD) -I$(DCETL_HEAD) \
-o $(OBJ_DIR)/$@.o
$(CXX) $(LINKING_FLAGS) $(OBJ_DIR)/$@.o \
-o $(EXE_DIR)/$@ \
-L$(DCETL_LIB_DIR) $(DCETL_LIB_FLAG) \
-L$(ORA_LIB_DIR) $(ORA_LIB_FLAG) \
-L$(OCICPP_LIB_DIR) $(OCICPP_LIB_FLAG)
########################### compile Pro*C/C++ ##########################################
PROC_NAME = helloworld DCETLScheduler DCETLInstAnalyse DCETLInitFlow \
etlInit etlSchedule etlAnalyse \
etlInit_temp etlSchedule_temp etlAnalyse_temp \
etlAudit \
rptStream \
rptStreamInst \
rptTaskInst
$(PROC_NAME) :
$(PROC) $(PROCPLSFLAGS) iname=$(APP_DIR)/$@.pc oname=$(CC_DIR)/$@.cc INCLUDE=$(APP_DIR)
$(CXX) $(COMPILE_FLAGS) $(CC_DIR)/$@.cc \
-I$(APP_DIR) \
-I$(ORA_PRE_HEAD) \
-I$(DCETL_HEAD) \
-I$(DC_OLD_HEAD) \
-o $(OBJ_DIR)/$@.o
$(CXX) $(LINKING_FLAGS) $(OBJ_DIR)/$@.o \
-o $(EXE_DIR)/$@ \
-L$(ORA_LIB_DIR) $(ORA_LIB_FLAG)
-L$(DCETL_LIB_DIR) $(DCETL_LIB_FLAG) \
-L$(OCICPP_LIB_DIR) $(OCICPP_LIB_FLAG)
########################### compile my ETL base lib #################################
base: IniFile DCFtpClient DCFtpUtils DCUtils DCArgsParser DCLogger DCLoggerDb DCEtlBase release_base
BASE_CLASS = IniFile DCUtils DCArgsParser DCLogger DCLoggerDb DCFtpClient DCFtpUtils DCEtlBase
$(BASE_CLASS) :
$(CXX) $(COMPILE_FLAGS) $(SRC_DIR)/dcetl/$@.cpp -I$(ORA_OCI_HEAD) \
-I$(OCICPP_LIB_HEAD) \
-I$(DCETL_HEAD) \
-o $(OBJ_DIR)/dcetl/$@.o
release_base:
rm -f $(OCICPP_LIB_DIR)/libdcetl$(COMPILE_MODE).a
ar -X$(COMPILE_MODE) $(ARFLAGS) $(DCETL_LIB_DIR)/libdcetl$(COMPILE_MODE).a $(OBJ_DIR)/dcetl/*.o
#####################################################################################
clean:
rm -f $(OBJ_DIR)/*.o
list :
ls -l $(APP_DIR)/*.c*
ls -l $(APP_DIR)/*.pc
阅读(2453) | 评论(1) | 转发(0) |