Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i did some work to compile gnupg-for-java under Macos 10.6 #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
dist
.DS_Store
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

app.name=javagnupg
app.type=@APP-TYPE@
app.version=0.1.5-ascii-armor-linux-i386-ia64
app.version=0.1.5-ascii-armor-${os.name}-${os.version}-${os.arch}
app.customer=LGPL
app.vendor=freiheit.com technologies gmbh
app.year=2008
Expand Down
4 changes: 1 addition & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
</classpath>
</javac>
</target>

<target name="test" depends="gen-jni-header, compile-tests, full-jar" description="Test the library functions...">
<property name="TestEnv" value="textui"/>
<property name="TestEnv" value="textui"/>
<!-- "textui" for text-environment
"swingui" for swing-environment
"awtui" for awt-environment -->

<java classname="junit.${TestEnv}.TestRunner" fork ="yes">
<classpath>
<pathelement location ="${basedir}/${dist}/${app.name}-${app.version}.jar"/>
Expand Down
13 changes: 11 additions & 2 deletions src/c/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ JAVA_HOME := /www/home/tcadm/local/jdk-amd64
#JAVA_HOME := /usr/local/jdk1.4.2
endif

UNAME=`which uname`
# set this from the command line to enforce a particular OS-bitness
BITS := $(shell /bin/uname -m | grep ".*_[0-9]\+" | sed "s/.*_\([0-9]\+\)/\1/")
BITS := $(shell $(UNAME) -m | grep ".*_[0-9]\+" | sed "s/.*_\([0-9]\+\)/\1/")

JAVAGNUPG_LIB := libjavagnupg
JNISRC := $(wildcard GnuPG*.c)
Expand All @@ -31,7 +32,15 @@ BITS := 32
endif
DEBUG := -g
CFLAGS := $(MARCH) -Werror -Wall -Wno-deprecated-declarations -fPIC $(shell gpgme-config --cflags)
CPPFLAGS := -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1 -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
CPPFLAGS := -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1 -I$(JAVA_HOME)/include

ifeq ($(shell $(UNAME)), Linux)
CPPFLAGS := -I$(JAVA_HOME)/include/linux
endif

ifeq ($(shell $(UNAME)), Darwin)
CPPFLAGS := -I$(JAVA_HOME)/../Headers
endif

C_IMPL := ./src/c
JAVA_BUILD := ../../build
Expand Down
File renamed without changes.
File renamed without changes.
Binary file added src/c/Mac_OS_X/libjavagnupg.32.so
Binary file not shown.
39 changes: 11 additions & 28 deletions src/java/com/freiheit/gnupg/GnuPGContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -576,42 +576,22 @@ public void delete(GnuPGKey key, boolean allowSecret){
}
}



/**
* Determines the native library name for the system this is running on.
* If running on unix, we also try to guess the architecture's bit-ness
* which has an impact on the library's name
* @return the name
*/
private static String getNativeLibraryName() {

// if all fails we assume windblows
String libName = "/c/javagnupg";

try {
ProcessBuilder pb = new ProcessBuilder(new String[] { "/bin/uname", "-m" });
pb.redirectErrorStream(true);
Process p = pb.start();
InputStreamReader isr = new InputStreamReader(p.getInputStream());
BufferedReader br = new BufferedReader(isr);

StringBuilder sb = new StringBuilder();
String line = null;

while ((line = br.readLine()) != null) {
//System.out.println(line);
sb.append(line + "\n");
}

String uName = sb.toString().trim();
libName = uName.endsWith("_64") ? "/c/libjavagnupg.64" : "/c/libjavagnupg.32";
} catch (Exception e) {
System.err.println("Cannot execute 'uname'. Probably running on a non unix environment.");
/* nothing here, may add some debug output */
e.printStackTrace();
}

String libName = "/c/";
libName += System.getProperty("os.name").replace(" ", "_");
if(System.getProperty("os.arch") == "amd64"){
libName += "/libjavagnupg.64";
}else{
libName += "/libjavagnupg.32";
}

return libName + "." + getNativeLibraryExtension();
}

Expand All @@ -634,6 +614,9 @@ private static String getNativeLibraryExtension() {
if (file.startsWith("lib") && file.endsWith(".so")) {
return "so";
}
if (file.startsWith("lib") && file.endsWith(".dylib")) {
return "dylib";
}
}
}
}
Expand Down