1 #
   2 # Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 #
  27 # Makefile for JDBC-ODBC Bridge Driver 
  28 #
  29 # Note - the native library for the bridge may be linked with the 
  30 # shared library for the ODBC driver manager.  Or dummy libraries
  31 # may be used to just create libJdbcOdbc.so with a dependency on
  32 # libodbc.so and libodbcinst.so.
  33 #
  34 
  35 BUILDDIR = ../..
  36 MODULE  = jdbc-odbc
  37 PACKAGE = sun.jdbc.odbc
  38 LIBRARY = JdbcOdbc
  39 PRODUCT = sun
  40 include $(BUILDDIR)/common/Defs.gmk
  41 
  42 #
  43 # Files
  44 #
  45 
  46 AUTO_FILES_JAVA_DIRS = sun/jdbc/odbc
  47 
  48 FILES_c = \
  49         JdbcOdbc.c
  50 
  51 FILES_export = \
  52     sun/jdbc/odbc/JdbcOdbc.java 
  53 
  54 # Use fake libraries on Solaris and Linux just so the library we create has
  55 #   a dependency on these two library names. (which are not part of the jdk)
  56 ifneq ($(PLATFORM), windows)
  57   # In jdk5 and jdk6, and on Solaris 32bit, we would have required that
  58   #    these two libraries exist at: $(ALT_ODBCDIR)/ISLIodbc/2.11/lib
  59   #    In jdk7, we just fake them out like we did on Linux in jdk5 and jdk6.
  60   #
  61   # If you wanted to use the real odbc libraries, change the value of
  62   #    ODBC_LIBRARY_LOCATION, and delete the variable assignments below.
  63   #
  64   # Tell linker to ignore missing externals when building this shared library.
  65   LDFLAGS_DEFS_OPTION = -z nodefs
  66   # Define a place to create the fake libraries and their names.
  67   ODBC_LIBRARY_LOCATION = $(TEMPDIR)
  68   ODBC_FAKE_LIBRARIES = $(ODBC_LIBRARY_LOCATION)/libodbcinst.so $(ODBC_LIBRARY_LOCATION)/libodbc.so
  69   # Make sure they get created early.
  70   INIT += $(ODBC_FAKE_LIBRARIES)
  71 endif
  72 
  73 #
  74 # Rules
  75 #
  76 include $(BUILDDIR)/common/Library.gmk
  77 
  78 #
  79 # The UNIX define specifies conditional compilation for UNIX
  80 #
  81 ifeq ($(PLATFORM), windows)
  82   LDLIBS += odbc32.lib odbccp32.lib
  83 else
  84   CFLAGS += -DUNIX
  85   LDFLAGS += -L$(ODBC_LIBRARY_LOCATION) -lodbcinst -lodbc
  86 endif
  87 
  88 #
  89 # The native code for the bridge uses conditional compilation to 
  90 # support Solaris, Win95 and Mac PPC. This is the path to the shared C files
  91 # (which unfortunately are in the same directory as shared Java files).
  92 #
  93 vpath %.c $(CLOSED_SHARE_SRC)/classes/sun/jdbc/odbc
  94 
  95 #
  96 # Rules to generate fake libraries
  97 #
  98 
  99 ifdef ODBC_FAKE_LIBRARIES
 100 $(TEMPDIR)/dummyodbc.c: 
 101         @$(prep-target)
 102         $(ECHO) "void dummyOdbc(void){}" >> $@
 103 $(TEMPDIR)/dummyodbc.o: $(TEMPDIR)/dummyodbc.c
 104         @$(prep-target)
 105         $(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $<
 106 $(ODBC_FAKE_LIBRARIES): $(TEMPDIR)/dummyodbc.o
 107         @$(prep-target)
 108         $(CC) $(SHARED_LIBRARY_FLAG) $(LDFLAGS_COMMON) -o $@ $< $(EXTRA_LIBS)
 109 clean::
 110         $(RM) -f $(ODBC_FAKE_LIBRARIES)
 111         $(RM) -f $(TEMPDIR)/dummyodbc.c
 112         $(RM) -f $(TEMPDIR)/dummyodbc.o
 113 endif
 114 
 115 #
 116 # Files that need to be copied
 117 #
 118 SERVICEDIR = $(CLASSBINDIR)/META-INF/services
 119 
 120 FILES_copy = \
 121         $(SERVICEDIR)/java.sql.Driver
 122 
 123 
 124 FILES_mkdirs = \
 125         $(CLASSBINDIR)/META-INF \
 126         $(CLASSBINDIR)/META-INF/services
 127 
 128 FILES_copydirs = \
 129         $(CLASSBINDIR) \
 130         $(FILES_mkdirs)
 131 
 132 build: copy-files
 133 
 134 copy-files: $(FILES_copy)
 135 
 136 $(SERVICEDIR)/%: $(CLOSED_SHARE_SRC)/classes/sun/jdbc/odbc/META-INF/services/%
 137         $(install-file)
 138 
 139 clean clobber::
 140         $(RM) $(FILES_copy)
 141 
 142 .PHONY: copy-files
 143