@@ -3,27 +3,33 @@ ifndef JAVA_HOME
33$(warning JAVA_HOME should be set so it points to your jdk installation dir)
44endif
55
6- # Flags
7- CFLAGS =-O3
8-
96# Define all of the C files here
107OBJS = TSDRLibraryNDK.o
118
129# Define all of the dependencies here
1310DEPS = TSDRLibraryNDK.h include/TSDRLibrary.h include/TSDRCodes.h
1411
12+ # Flags
13+ CFLAGS+ =-O3
14+
1515# Headers
1616INC = "$(JAVA_HOME ) /include" "$(JAVA_HOME ) /include/win32"
1717
1818# Detect library extension depending on OS
1919ifeq ($(OS ) ,Windows_NT)
20+
2021 EXT=.dll
2122 OSNAME = WINDOWS
22- ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
23- ARCHNAME = X64
24- endif
25- ifeq ($(PROCESSOR_ARCHITECTURE),x86)
26- ARCHNAME = X86
23+
24+ ifndef $(ARCHNAME)
25+
26+ ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
27+ ARCHNAME = X64
28+ endif
29+ ifeq ($(PROCESSOR_ARCHITECTURE),x86)
30+ ARCHNAME = X86
31+ endif
32+
2733 endif
2834else
2935 UNAME_S := $(shell uname -s)
3642 EXT=.a
3743 OSNAME = OSX
3844 endif
39- UNAME_P := $(shell uname -p)
40- ifeq ($(UNAME_P),x86_64)
41- ARCHNAME = X64
42- endif
43- ifneq ($(filter %86,$(UNAME_P)),)
44- ARCHNAME = X86
45- endif
46- ifneq ($(filter arm%,$(UNAME_P)),)
47- ARCHNAME = ARM
45+
46+ ifndef $(ARCHNAME)
47+
48+ UNAME_P := $(shell uname -p)
49+ ifeq ($(UNAME_P),x86_64)
50+ ARCHNAME = X64
51+ endif
52+ ifneq ($(filter %86,$(UNAME_P)),)
53+ ARCHNAME = X86
54+ endif
55+ ifneq ($(filter arm%,$(UNAME_P)),)
56+ ARCHNAME = ARM
57+ endif
58+
4859 endif
4960endif
5061
62+ ifeq ($(ARCHNAME ) ,X86)
63+ COMPILATION_TYPE=-m32
64+ else ifeq ($(ARCHNAME),X64)
65+ COMPILATION_TYPE=-m64
66+ endif
67+
68+ # OS specific flags
69+ ifeq ($(OSNAME ) ,LINUX)
70+ CFLAGS+=-fPIC
71+ else ifeq ($(OSNAME),WINDOWS)
72+ LDFLAGS+=-Wl,--add-stdcall-alias
73+ endif
74+
5175# The folder that will contain the libraries
5276OUTPUTFOLDER =../lib/$(OSNAME ) /$(ARCHNAME )
5377
@@ -62,7 +86,7 @@ all : rebuildtempestsdr library
6286
6387# Linking
6488library : $(_OBJS )
65- gcc -L../../TempestSDR/bin/$(OSNAME ) /$(ARCHNAME ) / -lTSDRLibrary -Wl - shared -o $(OUTPUTFOLDER ) /$(LIBPREFIX ) TSDRLibraryNDK$(EXT ) $< -fPIC
89+ gcc -L../../TempestSDR/bin/$(OSNAME ) /$(ARCHNAME ) / -lTSDRLibrary -shared $( LDFLAGS ) $( COMPILATION_TYPE ) -o $(OUTPUTFOLDER ) /$(LIBPREFIX ) TSDRLibraryNDK$(EXT ) $<
6690
6791# Rebuild the main library so that we have the most up-to-date version
6892# The main library is assumed to be two levels below this jni folder
@@ -77,7 +101,7 @@ rebuildtempestsdr :
77101
78102# Compile the sources to obj files
79103$(OBJFOLDER ) /% .o : % .c $(DEPS )
80- gcc $(foreach d, $(INC ) , -I$d) $(CFLAGS ) -c $< -o $@ -fPIC
104+ gcc $(foreach d, $(INC ) , -I$d) $(CFLAGS ) $( COMPILATION_TYPE ) -c $< -o $@
81105
82106# Generate the java header based on the class
83107TSDRLibraryNDK.h : ../bin/martin/tempest/core/TSDRLibrary.class
0 commit comments