blob: d520b22cf850e08f047b217270299badecd696a7 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001#
2# Copyright 1996-2007 Sun Microsystems, Inc. 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. Sun designates this
8# particular file as subject to the "Classpath" exception as provided
9# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22# CA 95054 USA or visit www.sun.com if you need additional information or
23# have any 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
35BUILDDIR = ../..
36PACKAGE = sun.jdbc.odbc
37LIBRARY = JdbcOdbc
38PRODUCT = sun
39include $(BUILDDIR)/common/Defs.gmk
40
41#
42# Files
43#
44
45AUTO_FILES_JAVA_DIRS = sun/jdbc/odbc
46
47FILES_c = \
48 JdbcOdbc.c
49
50FILES_export = \
51 sun/jdbc/odbc/JdbcOdbc.java
52
53# Use fake libraries on Solaris and Linux just so the library we create has
54# a dependency on these two library names. (which are not part of the jdk)
55ifneq ($(PLATFORM), windows)
56 # In jdk5 and jdk6, and on Solaris 32bit, we would have required that
57 # these two libraries exist at: $(ALT_ODBCDIR)/ISLIodbc/2.11/lib
58 # In jdk7, we just fake them out like we did on Linux in jdk5 and jdk6.
59 #
60 # If you wanted to use the real odbc libraries, change the value of
61 # ODBC_LIBRARY_LOCATION, and delete the variable assignments below.
62 #
63 # Tell linker to ignore missing externals when building this shared library.
64 LDFLAGS_DEFS_OPTION = -z nodefs
65 # Define a place to create the fake libraries and their names.
66 ODBC_LIBRARY_LOCATION = $(TEMPDIR)
67 ODBC_FAKE_LIBRARIES = $(ODBC_LIBRARY_LOCATION)/libodbcinst.so $(ODBC_LIBRARY_LOCATION)/libodbc.so
68 # Make sure they get created early.
69 INIT += $(ODBC_FAKE_LIBRARIES)
70endif
71
72ifeq ($(PLATFORM),windows)
73 # Files built here do not compile with warning level 3 if warnings are fatal
74 COMPILER_WARNINGS_FATAL=false
75endif
76
77#
78# Rules
79#
80include $(BUILDDIR)/common/Library.gmk
81
82#
83# The UNIX define specifies conditional compilation for UNIX
84#
85ifeq ($(PLATFORM), windows)
86 LDLIBS += odbc32.lib odbccp32.lib
87else
88 CFLAGS += -DUNIX
89 LDFLAGS += -L$(ODBC_LIBRARY_LOCATION) -lodbcinst -lodbc
90endif
91
92#
93# The native code for the bridge uses conditional compilation to
94# support Solaris, Win95 and Mac PPC. This is the path to the shared C files
95# (which unfortunately are in the same directory as shared Java files).
96#
97vpath %.c $(CLOSED_SHARE_SRC)/classes/sun/jdbc/odbc
98
99#
100# Rules to generate fake libraries
101#
102
103ifdef ODBC_FAKE_LIBRARIES
104$(TEMPDIR)/dummyodbc.c:
105 @$(prep-target)
106 $(ECHO) "void dummyOdbc(void){}" >> $@
107$(TEMPDIR)/dummyodbc.o: $(TEMPDIR)/dummyodbc.c
108 @$(prep-target)
109 $(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $<
110$(ODBC_FAKE_LIBRARIES): $(TEMPDIR)/dummyodbc.o
111 @$(prep-target)
112 $(CC) $(SHARED_LIBRARY_FLAG) $(LDFLAGS_COMMON) -o $@ $< $(EXTRA_LIBS)
113clean::
114 $(RM) -f $(ODBC_FAKE_LIBRARIES)
115 $(RM) -f $(TEMPDIR)/dummyodbc.c
116 $(RM) -f $(TEMPDIR)/dummyodbc.o
117endif
118
119#
120# Files that need to be copied
121#
122SERVICEDIR = $(CLASSBINDIR)/META-INF/services
123
124FILES_copy = \
125 $(SERVICEDIR)/java.sql.Driver
126
127
128FILES_mkdirs = \
129 $(CLASSBINDIR)/META-INF \
130 $(CLASSBINDIR)/META-INF/services
131
132FILES_copydirs = \
133 $(CLASSBINDIR) \
134 $(FILES_mkdirs)
135
136build: copy-files
137
138copy-files: $(FILES_copy)
139
140$(SERVICEDIR)/%: $(CLOSED_SHARE_SRC)/classes/sun/jdbc/odbc/META-INF/services/%
141 $(install-file)
142
143clean clobber::
144 $(RM) $(FILES_copy)
145
146.PHONY: copy-files
147