Makefile 4.1 KB
Newer Older
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
#
# Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

#
# Makefile for JDBC-ODBC Bridge Driver 
#
# Note - the native library for the bridge may be linked with the 
# shared library for the ODBC driver manager.  Or dummy libraries
# may be used to just create libJdbcOdbc.so with a dependency on
# libodbc.so and libodbcinst.so.
#

BUILDDIR = ../..
PACKAGE = sun.jdbc.odbc
LIBRARY = JdbcOdbc
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk

#
# Files
#

AUTO_FILES_JAVA_DIRS = sun/jdbc/odbc

FILES_c = \
	JdbcOdbc.c

FILES_export = \
    sun/jdbc/odbc/JdbcOdbc.java 

# Use fake libraries on Solaris and Linux just so the library we create has
#   a dependency on these two library names. (which are not part of the jdk)
ifneq ($(PLATFORM), windows)
  # In jdk5 and jdk6, and on Solaris 32bit, we would have required that
  #    these two libraries exist at: $(ALT_ODBCDIR)/ISLIodbc/2.11/lib
  #    In jdk7, we just fake them out like we did on Linux in jdk5 and jdk6.
  #
  # If you wanted to use the real odbc libraries, change the value of
  #    ODBC_LIBRARY_LOCATION, and delete the variable assignments below.
  #
  # Tell linker to ignore missing externals when building this shared library.
  LDFLAGS_DEFS_OPTION = -Xlinker -z -Xlinker nodefs
  # Define a place to create the fake libraries and their names.
  ODBC_LIBRARY_LOCATION = $(TEMPDIR)
  ODBC_FAKE_LIBRARIES = $(ODBC_LIBRARY_LOCATION)/libodbcinst.so $(ODBC_LIBRARY_LOCATION)/libodbc.so
  # Make sure they get created early.
  INIT += $(ODBC_FAKE_LIBRARIES)
endif

#
# Rules
#
include $(BUILDDIR)/common/Library.gmk

#
# The UNIX define specifies conditional compilation for UNIX
#
ifeq ($(PLATFORM), windows)
  LDLIBS += odbc32.lib odbccp32.lib
else
  CFLAGS += -DUNIX
  LDFLAGS += -L$(ODBC_LIBRARY_LOCATION) -lodbcinst -lodbc
endif

#
# The native code for the bridge uses conditional compilation to 
# support Solaris, Win95 and Mac PPC. This is the path to the shared C files
# (which unfortunately are in the same directory as shared Java files).
#
vpath %.c $(CLOSED_SHARE_SRC)/classes/sun/jdbc/odbc

#
# Rules to generate fake libraries
#

ifdef ODBC_FAKE_LIBRARIES
$(TEMPDIR)/dummyodbc.c: 
	@$(prep-target)
	$(ECHO) "void dummyOdbc(void){}" >> $@
$(TEMPDIR)/dummyodbc.o: $(TEMPDIR)/dummyodbc.c
	@$(prep-target)
	$(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $<
$(ODBC_FAKE_LIBRARIES): $(TEMPDIR)/dummyodbc.o
	@$(prep-target)
	$(CC) $(SHARED_LIBRARY_FLAG) $(LDFLAGS_COMMON) -o $@ $< $(EXTRA_LIBS)
clean::
	$(RM) -f $(ODBC_FAKE_LIBRARIES)
	$(RM) -f $(TEMPDIR)/dummyodbc.c
	$(RM) -f $(TEMPDIR)/dummyodbc.o
endif

#
# Files that need to be copied
#
SERVICEDIR = $(CLASSBINDIR)/META-INF/services

FILES_copy = \
	$(SERVICEDIR)/java.sql.Driver


FILES_mkdirs = \
	$(CLASSBINDIR)/META-INF \
	$(CLASSBINDIR)/META-INF/services

FILES_copydirs = \
	$(CLASSBINDIR) \
	$(FILES_mkdirs)

build: copy-files

copy-files: $(FILES_copy)

$(SERVICEDIR)/%: $(CLOSED_SHARE_SRC)/classes/sun/jdbc/odbc/META-INF/services/%
	$(install-file)

clean clobber::
	$(RM) $(FILES_copy)

.PHONY: copy-files