forked from martinmarinov/TempestSDR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
93 lines (78 loc) · 2.57 KB
/
Copy pathmakefile
File metadata and controls
93 lines (78 loc) · 2.57 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# JAVA_HOME should be initialized to something like C:\PROGRA~2\Java\jdk1.7.0_45
ifndef JAVA_HOME
$(warning JAVA_HOME should be set so it points to your jdk installation dir)
endif
# Flags
CPPFLAGS=-O3
# Define all of the C files here
OBJS = TSDRLibraryNDK.o
# Define all of the dependencies here
DEPS = TSDRLibraryNDK.h include/TSDRLibrary.h include/TSDRCodes.h
# Headers
INC = "$(JAVA_HOME)/include" "$(JAVA_HOME)/include/win32"
# Detect library extension depending on OS
ifeq ($(OS),Windows_NT)
EXT=.dll
OSNAME = WINDOWS
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
ARCHNAME = X64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
ARCHNAME = X86
endif
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
EXT=.so
OSNAME = LINUX
endif
ifeq ($(UNAME_S),Darwin)
EXT=.a
OSNAME = OSX
endif
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
ARCHNAME = X64
endif
ifneq ($(filter %86,$(UNAME_P)),)
ARCHNAME = X86
endif
ifneq ($(filter arm%,$(UNAME_P)),)
ARCHNAME = ARM
endif
endif
# The folder that will contain the libraries
OUTPUTFOLDER=../lib/$(OSNAME)/$(ARCHNAME)
# The folder that will contain the object files
OBJFOLDER=obj
# The obj files reside in the bin/obj directory
_OBJS = $(patsubst %,$(OBJFOLDER)/%,$(OBJS))
# We want to build the library
all : rebuildtempestsdr library
# Linking
library : $(_OBJS)
gcc -L../../TempestSDR/bin/$(OSNAME)/$(ARCHNAME)/ -lTSDRLibrary -Wl,--add-stdcall-alias -shared -o $(OUTPUTFOLDER)/TSDRLibraryNDK$(EXT) $<
# Rebuild the main library so that we have the most up-to-date version
# The main library is assumed to be two levels below this jni folder
rebuildtempestsdr :
@$(MAKE) -C ../../TempestSDR all
@cp -f ../../TempestSDR/bin/$(OSNAME)/$(ARCHNAME)/TSDRLibrary$(EXT) $(OUTPUTFOLDER)/TSDRLibrary$(EXT)
mkdir -p include
@cp -f ../../TempestSDR/src/include/TSDRCodes.h include/
@cp -f ../../TempestSDR/src/include/TSDRLibrary.h include/
mkdir -p $(OUTPUTFOLDER)
mkdir -p $(OBJFOLDER)
# Compile the sources to obj files
$(OBJFOLDER)/%.o : %.c $(DEPS)
gcc $(foreach d, $(INC), -I$d) $(CFLAGS) -c $< -o $@
# Generate the java header based on the class
TSDRLibraryNDK.h : ../bin/martin/tempest/core/TSDRLibrary.class
javah -classpath ../bin -o TSDRLibraryNDK.h -jni martin.tempest.core.TSDRLibrary
# If the class is not compiled, do it
../bin/martin/tempest/core/TSDRLibrary.class : ../src/martin/tempest/core/TSDRLibrary.java
mkdir -p include ../bin/martin/tempest/core/
javac $< -d ../bin/ -cp ../src/
# Remove any compiled artifacts
clean :
rm -f TSDRLibraryNDK.h ../TSDRLibraryNDK$(EXT) ../TSDRLibrary$(EXT)
rm -rf $(OBJFOLDER)/