6f4467ac25f7bffccb185f7e03fb48d6a87e2d69
[clsql.git] / uffi / Makefile
1 #!/usr/bin/make
2 # FILE IDENTIFICATION
3 #
4 #  Name:         Makefile
5 #  Purpose:      Makefile for CLSQL UFFI interface
6 #  Programer:    Kevin M. Rosenberg
7 #  Date Started: Mar 2002
8 #
9 # This file, part of CLSQL, is Copyright (c) 2002-2006 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_uffi
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 ifneq ($(OS_DPKG_BUILDFLAGS),0)
27   CFLAGS:=$(CFLAGS) $(shell dpkg-buildflags --get CFLAGS)
28   LDFLAGS:=$(LDFLAGS) $(shell dpkg-buildflags --get LDFLAGS | sed "/-Wl,\(.*\)/ s//\1/")
29 endif
30
31
32 .PHONY: all
33 all: $(shared_lib)
34
35 $(shared_lib): $(source) Makefile
36 ifneq ($(OS_AIX),0)
37         gcc -c -D_BSD -D_NO_PROTO -D_NONSTD_TYPES -D_MBI=void $(source)
38         make_shared -o $(shared_lib) $(object)
39 else
40   ifneq ($(OS_SUNOS),0)
41         cc -KPIC -c $(source) -o $(object)
42         cc -G $(object) -o $(shared_lib)
43   else
44     ifneq ($(OS_DARWIN64),0)
45         cc -arch x86_64 -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress $(source) -o $(dylib)
46         cc -arch x86_64 -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
47     else
48       ifneq ($(OS_DARWIN),0)
49           cc -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress $(source) -o $(dylib)
50           cc -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress /usr/lib/libz.dylib -o z.dylib
51       else
52         ifneq ($(OS_CYGWIN),0)
53           gcc -c $(source) -o $(object)
54           ld -shared -soname=$(base) $(LDFLAGS) $(object) -o $(shared_lib)
55         else
56           ifneq ($(OS_LINUX64),0)
57             gcc $(CFLAGS) -fPIC -DPIC -c $(source) -o $(object)
58             ld $(LDFLAGS) -shared -soname=$(base) -lc $(object) -o $(shared64_lib)
59             rm -f $(object)
60             @echo "Ensure that you have multiarch i386 build tools if you want to build 32-bit library"
61             -gcc -m32 $(CFLAGS) -fPIC -DPIC -c $(source) -o $(object)
62             -ld -melf_i386 $(LDFLAGS) -shared -soname=$(base) -lc $(object) -o $(shared_lib)
63           else
64             gcc -fPIC -DPIC -c $(source) -o $(object)
65             ld -shared -soname=$(base) -lc $(object) -o $(shared_lib)
66         endif
67       endif
68     endif
69   endif
70 endif
71 endif
72         rm -f $(object)
73
74
75 .PHONY: distclean
76 distclean: clean
77         @rm -f $(dylib) $(shared_lib) $(shared64_lib) $(object) z.dylib