]> git.gag.com Git - fw/altos/blob - ao-tools/libaltos/Makefile
add install target for libaltos
[fw/altos] / ao-tools / libaltos / Makefile
1 OS:=$(shell uname)
2
3 #
4 # Linux
5 #
6 ifeq ($(OS),Linux)
7
8 JAVA_CFLAGS=-I/usr/lib/jvm/java-6-openjdk/include
9
10 OS_CFLAGS=-DLINUX -DPOSIX_TTY $(JAVA_CFLAGS)
11
12 OS_LDFLAGS=
13
14 LIBNAME=libaltos.so
15 EXEEXT=
16
17 install:        $(LIBNAME)
18         /usr/bin/install -c $(LIBNAME) $(DESTDIR)/usr/lib/altos/$(LIBNAME)
19
20 endif
21
22 #
23 # Darwin (Mac OS X)
24 #
25 ifeq ($(OS),Darwin)
26
27 OS_CFLAGS=\
28         -DDARWIN -DPOSIX_TTY -arch i386 -arch x86_64 \
29         --sysroot=/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 \
30         -iwithsysroot /System/Library/Frameworks/JavaVM.framework/Headers \
31         -iwithsysroot /System/Library/Frameworks/IOKit.framework/Headers \
32         -iwithsysroot /System/Library/Frameworks/CoreFoundation.framework/Headers
33
34 OS_LDFLAGS =\
35         -framework IOKit -framework CoreFoundation
36
37 LIBNAME=libaltos.dylib
38 EXEEXT=
39
40 endif
41
42 #
43 # Windows
44 #
45 ifneq (,$(findstring MINGW,$(OS)))
46
47 CC=gcc
48
49 OS_CFLAGS = -DWINDOWS -mconsole
50
51 OS_LDFLAGS = -lgdi32 -luser32 -lcfgmgr32 -lsetupapi -lole32 \
52         -ladvapi32 -lcomctl32 -mconsole -Wl,--add-stdcall-alias
53
54 LIBNAME=altos.dll
55
56 EXEEXT=.exe
57
58 endif
59
60 .SUFFIXES: .java .class
61
62 CLASSPATH=".:jnitest/*:libaltosJNI:/usr/share/java/*"
63
64 SWIG_DIR=swig_bindings/java
65 SWIG_FILE=$(SWIG_DIR)/libaltos.swig
66 SWIG_WRAP=$(SWIG_DIR)/libaltos_wrap.c
67
68 JNI_DIR=libaltosJNI
69 JNI_FILE=$(JNI_DIR)/libaltosJNI.java 
70 JNI_SRCS=$(JNI_FILE) \
71         $(JNI_DIR)/SWIGTYPE_p_altos_file.java \
72         $(JNI_DIR)/SWIGTYPE_p_altos_list.java \
73         $(JNI_DIR)/altos_device.java \
74         $(JNI_DIR)/libaltos.java
75
76 JAVAFILES=\
77         $(JNI_SRCS)
78
79 CLASSFILES = $(JAVAFILES:%.java=%.class)
80
81 JAVAFLAGS=-Xlint:unchecked
82
83 CJNITEST=cjnitest$(EXEEXT)
84
85 all: $(LIBNAME) $(CJNITEST) $(CLASSFILES)
86
87 .java.class:
88         javac -encoding UTF8 -classpath "$(CLASSPATH)" $(JAVAFLAGS) $*.java
89
90 CFLAGS=$(OS_CFLAGS) -O0 -g -I.
91
92 LDFLAGS=$(OS_LDFLAGS)
93
94 HEADERS=libaltos.h
95 SRCS = libaltos.c $(SWIG_WRAP)
96 OBJS = $(SRCS:%.c=%.o)
97 LIBS = $(DARWIN_LIBS)
98
99 $(CJNITEST): cjnitest.o $(OBJS)
100         cc -o $@ $(CFLAGS) cjnitest.o $(OBJS) $(LIBS)
101
102 $(LIBNAME): $(OBJS)
103         gcc -shared $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
104
105 clean:
106         rm -f $(CLASSFILES) $(OBJS) $(LIBNAME) $(CJNITEST) cjnitest.o
107         rm -rf swig_bindings libaltosJNI
108
109 $(JNI_FILE): libaltos.i0 $(HEADERS)
110         mkdir -p $(SWIG_DIR)
111         mkdir -p libaltosJNI
112         sed 's;//%;%;' libaltos.i0 $(HEADERS) > $(SWIG_FILE)
113         swig -java -package libaltosJNI $(SWIG_FILE)
114         cp swig_bindings/java/*.java libaltosJNI
115
116 $(SWIG_WRAP): $(JNI_FILE)