Source

sqlite-jdbc / script / Makefile.common

ifndef JAVA_HOME
$(error Set JAVA_HOME environment variable)
endif

ifeq ($(os),)
	ifeq ($(shell uname),Darwin)
		os := Darwin
	endif
	ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
		os := Win
	endif
	ifeq ($(findstring MINGW,$(shell uname)),MINGW)
		os := Win
	endif
endif
ifeq ($(os),)
	os := Default
endif

# Windows uses different path separators, because they hate me
ifeq ($(os),Win)
	sep := ;
else
	sep := :
endif

ifeq ($(arch),)
arch := $(shell uname -m)
endif


sqlite_version := 3.5.9

sqlite := sqlite-$(sqlite_version)

sqlitejdbc := sqlitejdbc-v$(shell cat VERSION)

jni_md := $(shell find -L "$(JAVA_HOME)" -name jni_md.h)
ifneq ($(jni_md),)
jni_include := $(shell dirname "$(jni_md)")
endif

libjdbc  := $(wildcard lib/jdbc-*.jar)
libjunit := $(wildcard lib/junit-*.jar)

JAVA  := "$$JAVA_HOME/bin/java"
JAVAC := "$$JAVA_HOME/bin/javac" -Xbootclasspath/p:$(libjdbc)
JAVAH := "$$JAVA_HOME/bin/javah"

java_sources = $(wildcard src/org/sqlite/*.java)
java_classes = $(java_sources:src/%.java=build/%.class)
native_classes = $(filter-out %NestedDB.class,$(java_classes))
java_classlist = $(subst $$,\$$,$(patsubst build/%, %, $(wildcard $(java_classes:%.class=%*))))
test_sources = $(wildcard src/test/*.java)
test_classes = $(test_sources:src/%.java=build/%.class)
tests        = $(subst /,.,$(patsubst build/%.class,%,$(test_classes)))

target     := $(os)-$(arch)

# os=Default is meant to be generic unix/linux
Default_CC        := gcc
Default_STRIP     := strip
Default_CFLAGS    := -I$(JAVA_HOME)/include -Os -fPIC
Default_LINKFLAGS := -shared
Default_LIBNAME   := libsqlitejdbc.so

Support10_4 := -isysroot /Developer/SDKs/MacOSX10.4u.sdk
#Darwin_CC        := gcc -arch $(arch) -mmacosx-version-min=10.4 $(Support10_4)
Darwin_CC        := gcc -arch $(arch) 
Darwin_STRIP     := strip -x
Darwin_CFLAGS    := -I$(JAVA_HOME)/include -Os -fPIC
Darwin_LINKFLAGS := -dynamiclib $(Support10_4)
Darwin_LIBNAME   := libsqlitejdbc.jnilib

#Win_CC           := $(arch)-mingw32msvc-gcc
#Win_STRIP        := $(arch)-mingw32msvc-strip
Win_CC           := mingw32-gcc
Win_STRIP        := strip
Win_CFLAGS       := -D_JNI_IMPLEMENTATION_ -Ilib/inc_win -O
Win_LINKFLAGS    := -Wl,--kill-at -shared
Win_LIBNAME      := sqlitejdbc.dll

CC        := $($(os)_CC)
STRIP     := $($(os)_STRIP)
CFLAGS    := $($(os)_CFLAGS)
LINKFLAGS := $($(os)_LINKFLAGS)
LIBNAME   := $($(os)_LIBNAME)

CFLAGS := $(CFLAGS) -Ibuild/$(sqlite)-$(target) -Ibuild
ifneq ($(jni_include),)
CFLAGS := $(CFLAGS) -I"$(jni_include)"
endif