1#! /bin/sh
2#! /bin/sh
3
4# BEGIN LICENSE BLOCK
5# Version: CMPL 1.1
6#
7# The contents of this file are subject to the Cisco-style Mozilla Public
8# License Version 1.1 (the "License"); you may not use this file except
9# in compliance with the License.  You may obtain a copy of the License
10# at www.eclipse-clp.org/license.
11# 
12# Software distributed under the License is distributed on an "AS IS"
13# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
14# the License for the specific language governing rights and limitations
15# under the License. 
16# 
17# The Original Code is  The ECLiPSe Constraint Logic Programming System. 
18# The Initial Developer of the Original Code is  Cisco Systems, Inc. 
19# Portions created by the Initial Developer are
20# Copyright (C) 1997 - 2006 Cisco Systems, Inc.  All Rights Reserved.
21# 
22# Contributor(s): Joachim Schimpf, Stefano Novello, IC-Parc
23# 
24# END LICENSE BLOCK
25#
26# $Header: /cvsroot/eclipse-clp/Eclipse/Oci/Makefile.in,v 1.6 2013/06/20 20:59:09 kish_shen Exp $
27#
28
29#ORACLE_HOME=/home/mac/oracle
30#ODB_HOME=/opt/FNXodb
31#ORACLE_LIB=$(ORACLE_HOME)/lib
32
33MYSQLDIR = @MYSQLDIR@
34
35ARCH = @ARCH@
36top_srcdir = @top_srcdir@
37PREFIX = @prefix@
38MAKEFILE = Makefile.$(ARCH)
39
40CC = @CC@
41CFLAGS = @CFLAGS@
42OS_INCLUDES = @OS_INCLUDES@
43OPT_FLAGS = @OPT_FLAGS@
44LIBS = @LIBS@
45OBJ_SUFFIX = @OBJECTS_SUFFIX@
46DYNLDFLAGS = @DYNLDFLAGS@
47DYLD = @DYLD@
48ifeq "$(ARCH)" "ppc_macosx"
49	LD_LIB_PATH = DYLD_LIBRARY_PATH
50else 
51ifeq "$(ARCH)" "i386_macosx"
52	LD_LIB_PATH = DYLD_LIBRARY_PATH
53else
54	LD_LIB_PATH = LD_LIBRARY_PATH
55endif
56endif
57
58ECLIPSE = $(PREFIX)/bin/$(ARCH)/eclipse
59PERM = a+r,u+w,go-w
60
61ELIBS	= -L$(PREFIX)/lib/$(ARCH) -L$(MYSQLDIR)/lib -leclipse @GMP_LD@ $(LIBS)
62
63
64# MySQL libraries to link against
65#
66# Note about Windows cross-compilation with mingw: libmysql.dll.a has been
67# created from libmysql.dll using the following method:
68# 1. Make a file libmysql.def containing entries of the form mysql_xxx@N,
69#	at least for all the symbols that we need from the dll
70#	(attempt a link and process the error messages)
71# 2. Run dlltool -k -d libmydql.def --dllname libmysql.dll -l libmysql.dll.a
72# We've tried lots of other tricks, but this is the one that worked.
73
74MLIBS_i386_nt      = $(MYSQLDIR)/lib/libmysql.dll.a
75MLIBS_x86_64_nt      = $(MYSQLDIR)/lib/libmysql.dll
76MLIBS_unix	   = -lmysqlclient -lz -lpthread
77ifeq "$(ARCH)" "i386_nt"
78   MLIBS = $(MLIBS_i386_nt)
79else 
80 ifeq "$(ARCH)" "x86_64_nt"
81   MLIBS = $(MLIBS_x86_64_nt)
82 else
83  ifeq "$(ARCH)" "i386_macosx"
84    # -lgcc needed for linking against static mysql library
85    # ppc_macosx already have -lgcc, so no need to add it here
86    MLIBS = $(MLIBS_unix) -lgcc
87  else
88    MLIBS = $(MLIBS_unix)
89  endif
90 endif
91endif
92
93
94#OLIBS   = -L$(ORACLE_LIB) $(ORACLE_LIB)/osntab.o -locic -lsql\
95#-lsqlnet  -lora -lsqlnet  -lora -lnlsrtl -lcv6 -lcore -lnlsrtl -lcv6 -lcore
96
97
98#CPPFLAGS  = -I$(PREFIX)/include -I$(ORACLE_HOME)/rdbms/demo -DDEBUG
99CPPFLAGS  = -I$(PREFIX)/include/$(ARCH) -I$(MYSQLDIR)/include -I/usr/local/include
100MFLAGS = -DUSE_MYSQL
101
102
103# dynamic library for DBs
104OBJ_FILES = $(ARCH)/dbi_mysql.$(OBJ_SUFFIX)
105OBJ_DEST = $(OBJ_FILES:%=$(PREFIX)/lib/%)
106# support .ecl files
107ECL_FILES = mysqlopts.ecl
108ECL_DEST = $(ECL_FILES:%=$(PREFIX)/lib/%)
109ECO_FILES = dbi.eco
110ECO_DEST = $(ECO_FILES:%=$(PREFIX)/lib/%)
111ECI_FILES = dbi.eci
112ECI_DEST = $(ECI_FILES:%=$(PREFIX)/lib/%)
113
114
115.SUFFIXES:	$(SUFFIXES) $(OBJ_SUFFIX)
116
117
118# install is configured as either install_all or install_cross
119install:	@MAKE_TARGET@
120
121# these do nothing if we don't have mysql
122install_all:	@ALL_WITH_MYSQL@
123install_cross:	@ALL_CROSS_WITH_MYSQL@
124
125all_with_mysql:	all_cross_with_mysql $(ECO_DEST) $(ECI_DEST) $(ECL_DEST)
126all_cross_with_mysql:	$(OBJ_DEST) 
127
128
129
130MOBJ= $(ARCH)/mysql.o $(ARCH)/dbi.o 
131
132
133$(ARCH)/dbi.o : dbi.h dbi.c
134	[ -d $(ARCH) ] || mkdir $(ARCH)
135	$(CC) $(OPT_FLAGS) $(CFLAGS) $(CPPFLAGS) -c -o $(ARCH)/dbi.o dbi.c
136
137$(ARCH)/mysql.o: dbi.h mysql.c
138	[ -d $(ARCH) ] || mkdir $(ARCH)
139	$(CC) $(OPT_FLAGS) $(CFLAGS) $(CPPFLAGS) $(MFLAGS) -c -o $(ARCH)/mysql.o mysql.c
140
141$(ARCH)/dbi_mysql.$(OBJ_SUFFIX): $(MOBJ)
142	[ -d $(ARCH) ] || mkdir $(ARCH)
143	$(DYLD) $(DYNLDFLAGS) \
144	    $(MOBJ) $(MLIBS) $(ELIBS) \
145	    -o $(ARCH)/dbi_mysql.$(OBJ_SUFFIX)
146
147
148$(PREFIX)/lib/%.eci: %.ecl
149	@$(MAKE) -f $(MAKEFILE) $(OBJ_FILES)
150	$(LD_LIB_PATH)=$(MYSQLDIR)/lib:$($(LD_LIB_PATH)) $(ECLIPSE) -e 'get_flag(library_path,P),set_flag(library_path,["."|P]),lib(document),icompile("$<","$(@D)")'
151	-@/bin/chmod $(PERM) $@
152
153$(PREFIX)/lib/%.eco: %.ecl mysqlopts.ecl
154	@$(MAKE) -f $(MAKEFILE) $(OBJ_FILES)
155	$(LD_LIB_PATH)=$(MYSQLDIR)/lib:$($(LD_LIB_PATH)) $(ECLIPSE) -e 'get_flag(library_path,P),set_flag(library_path,["."|P]),lib(fcompile), set_flag(variable_names,off), fcompile("$<", [outdir:"$(@D)"])'
156	-@/bin/chmod $(PERM) $@
157
158$(PREFIX)/lib/$(ARCH)/%.$(OBJ_SUFFIX):	$(ARCH)/%.$(OBJ_SUFFIX)
159	cp $< $@
160	-@/bin/chmod $(PERM) $@
161
162$(PREFIX)/lib/%.ecl:	%.ecl
163	cp $< $@
164	-@/bin/chmod $(PERM) $@
165
166
167clean:	archclean
168
169archclean:
170	rm -rf *.o *.$(OBJSUFFIX) $(ARCH)
171
172ecoclean:
173	rm -f $(ECO_FILES) $(ECO_DEST)
174
175