Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9952967f322dc4f0af8affc14745cae0a76ad8b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#*******************************************************************************
# Copyright (c) 2002, 2009 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
#     QNX Software Systems - initial API and implementation
#     Alex Blewitt - MacOSX with a 64-bit vm 
#*******************************************************************************/

JAVA_HOME = $(shell echo /Library/Java/JavaVirtualMachines/jdk1.8.0_*.jdk/Contents/Home)
UNAME = $(shell uname)

# Defaults which can be overridden.
ifeq ($(UNAME),Darwin)
OS = macosx
ARCHS = x86_64
endif

ARCH_X86 = x86
ARCH_X86_64 = x86_64

CC=gcc
LD=libtool
CPPFLAGS = -I. -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
CFLAGS +=-fPIC -D_REENTRANT

ARCH_FLAG_X86 = -arch i386
ARCH_FLAG_X86_64 = -arch x86_64

INSTALL_DIR_X86 = ../../os/$(OS)/$(ARCH_X86)
INSTALL_DIR_X86_64 = ../../os/$(OS)/$(ARCH_X86_64)

LIB_NAME_FULL_SERIAL_X86 = $(INSTALL_DIR_X86)/libserial.jnilib
LIB_NAME_FULL_SERIAL_X86_64 = $(INSTALL_DIR_X86_64)/libserial.jnilib

OBJS_SERIAL_X86 = serial_$(ARCH_X86).o
OBJS_SERIAL_X86_64 = serial_$(ARCH_X86_64).o

OBJS_X86 = $(OBJS_SERIAL_X86)
OBJS_X86_64 = $(OBJS_SERIAL_X86_64)

all: $(ARCHS)

x86: $(LIB_NAME_FULL_SERIAL_X86)

x86_64:  $(LIB_NAME_FULL_SERIAL_X86_64)

rebuild: clean all

$(LIB_NAME_FULL_SERIAL_X86): $(OBJS_SERIAL_X86)
	mkdir -p $(INSTALL_DIR_X86)
	$(CC) -dynamiclib  $(ARCH_FLAG_X86) -o $(LIB_NAME_FULL_SERIAL_X86) $(OBJS_SERIAL_X86) -lc -framework JavaVM

$(LIB_NAME_FULL_SERIAL_X86_64): $(OBJS_SERIAL_X86_64)
	mkdir -p $(INSTALL_DIR_X86_64)
	$(CC) -dynamiclib  $(ARCH_FLAG_X86_64) -o $(LIB_NAME_FULL_SERIAL_X86_64) $(OBJS_SERIAL_X86_64) -lc -framework JavaVM

serial_$(ARCH_X86).o: serial.c
	$(CC) $(CFLAGS) $(ARCH_FLAG_X86) $(CPPFLAGS) -c -o $@ serial.c

serial_$(ARCH_X86_64).o: serial.c
	$(CC) $(CFLAGS) $(ARCH_FLAG_X86_64) $(CPPFLAGS) -c -o $@ serial.c

clean :
	$(RM) $(OBJS_X86)
	$(RM) $(OBJS_X86_64)

Back to the top