604aac5b15b40cd83714fa9354c8e54845a77308
[clsql.git] / db-mysql / Makefile
1 #!/usr/bin/make
2 # FILE IDENTIFICATION
3 #
4 #  Name:         Makefile
5 #  Purpose:      Makefile for CLSQL MySQL interface
6 #  Programer:    Kevin M. Rosenberg
7 #  Date Started: Mar 2002
8 #
9 # This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
10 #
11 # CLSQL users are granted the rights to distribute and use this software
12 # as governed by the terms of the Lisp Lesser GNU Public License
13 # (http://opensource.franz.com/preamble.html), also known as the LLGPL.
14
15 SUBDIRS=
16
17 include ../Makefile.common
18
19 base=clsql_mysql
20 source=$(base).c
21 object=$(base).o
22 shared_lib=$(base).so
23 shared64_lib=$(base)64.so
24 dylib=$(base).dylib
25
26 .PHONY: all
27 all: $(shared_lib)
28
29 CFLAGS:=-I /usr/local/include/mysql -I /usr/include/mysql -I /sw/include/mysql -I /opt/local/include/mysql -I /opt/local/include/mysql55/mysql -I /usr/local/mysql/include
30 LDFLAGS:=-L/usr/local/lib64/mysql -L/usr/local/lib/mysql -L/usr/lib64/mysql -L/usr/lib/mysql -L/sw/lib -L/opt/local/lib/mysql -L/opt/local/lib/mysql5/mysql -L/usr/local/mysql/lib -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -lmysqlclient -lz -lc
31
32 CFLAGS32:=-I /usr/local/include/mysql -I /usr/include/mysql -I /sw/include/mysql -I /opt/local/include/mysql -I /opt/local/include/mysql5/mysql -I /usr/local/mysql/include -m32
33 LDFLAGS32:=-L/lib32 -L/usr/lib32 -melf_i386 -lmysqlclient -lz -lc
34
35 ifneq ($(OS_CYGWIN),0)
36   CFLAGS:=-I /cygdrive/c/Program\ Files/MySQL/MySQL\ Server\ 5.0/include
37   LDFLAGS:=-L/usr/local/lib64/mysql -L/usr/local/lib/mysql -L/usr/lib/mysql -L/sw/lib -L/opt/local/lib/mysql -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -lmysqlclient -lpthread -lz -lm -lgcc -lc
38 endif
39 ifneq ($(OS_DPKG_BUILDFLAGS),0)
40   CFLAGS:=$(CFLAGS) $(shell dpkg-buildflags --get CFLAGS)
41   LDFLAGS:=$(LDFLAGS) $(shell dpkg-buildflags --get LDFLAGS | sed "s/-Wl\|,/ /ig")
42 endif
43
44 $(shared_lib): $(source) Makefile
45 ifneq ($(OS_AIX),0)
46         gcc $(CFLAGS) -c -D_BSD -D_NO_PROTO -D_NONSTD_TYPES -D_MBI=void $(source)
47         make_shared $(LDFLAGS) -o $(shared_lib) $(object)
48 else
49   ifneq ($(OS_SUNOS),0)
50         cc $(CFLAGS) -KPIC -c $(source) -o $(object)
51         cc -G $(object) $(LDFLAGS) -o $(shared_lib)
52   else
53     ifneq ($(OS_DARWIN64),0)
54         cc $(CFLAGS) -arch x86_64 -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress $(source) -o $(dylib)
55         cc -arch x86_64 -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
56     else
57       ifneq ($(OS_DARWIN),0)
58         cc $(CFLAGS) -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress $(source) -o $(dylib)
59         cc -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
60       else
61         ifneq ($(OS_CYGWIN),0)
62           gcc $(CFLAGS) -DWIN32 -c $(source) -o $(object)
63           ld -shared -soname=$(base)  $(object) $(LDFLAGS) -o $(shared_lib)
64         else
65           ifneq ($(OS_LINUX64),0)
66             gcc $(CFLAGS) -fPIC -c $(source) -o $(object)
67             ld $(LDFLAGS) -shared -soname=$(base) $(object) -o $(shared64_lib)
68             rm $(object)
69             @echo "Ensure that you have multiarch i386 build tools and libraries if you want to build 32-bit library"
70             -gcc $(CFLAGS32) -fPIC -c $(source) -o $(object)
71             -ld -shared -soname=$(base) $(object) $(LDFLAGS32) -o $(shared_lib)
72           else
73             gcc $(CFLAGS) -fPIC -c $(source) -o $(object)
74             ld -shared -soname=$(base) $(object) $(LDFLAGS) -o $(shared_lib)
75           endif
76         endif
77       endif
78     endif
79   endif
80 endif
81         rm -f $(object)
82
83 .PHONY: distclean
84 distclean: clean
85         @rm -f $(dylib) $(shared_lib) $(shared64_lib) $(object) z.dylib