forked from martinmarinov/TempestSDR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
98 lines (80 loc) · 2.83 KB
/
Copy pathmakefile
File metadata and controls
98 lines (80 loc) · 2.83 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
94
95
96
97
98
# USER CONFIGURATION STARTS HERE
# Define the plugins that you like to compile with the library. They need to be in a folder
# in the parent directory with the exact same name as the plugin names. The library files
# produced need to have the name of the plugin folder and need to be in the bin directory.
# The default plugin file will make sure this is compatible.
PLUGINS=TSDRPlugin_RawFile
# USER CONFIGURATION ENDS HERE
# Define a recursive wildcard function
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
# Discover all the java sources
JAVAFILES:=$(call rwildcard,src/,*.java)
# Create the class dependencies
CLASSFILES:=$(patsubst %,bin/%,$(addsuffix .class,$(basename $(foreach jfile,$(JAVAFILES), $(subst src/,,$(jfile)) ))))
# Detect shared library extension based 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)
# Build the file names of the plugin files
PLUGINS_FILES=$(addsuffix $(EXT),$(PLUGINS))
# Build the directory names of the plugins
PLUGINS_DIRS=$(addprefix ../,$(addsuffix /,$(PLUGINS)))
# When compiling from command line with all
# make sure we compile both jni and java files
all : jnilib jar
# Package compiled files into a runnable jar
jar : java
jar cvfe JTempestSDR.jar martin.tempest.Main lib -C bin .
# The compilation of the java classes from command line
# depends on the class files (we want to produce them)
java : $(CLASSFILES)
# For each class file, invoke javac with the source file which is constructed
# from the name of the class file
%.class : $(JAVAFILES)
mkdir -p bin # Create the bin directory if it doesn't exist (if you downloaded it from github)
javac $(patsubst %,src/%, $(subst bin/,,$(@:.class=.java))) -d bin/ -cp src/
# Invoke the makefile for the jni stuff
jnilib : plugins
@$(MAKE) -C jni/ all JAVA_HOME=$(JAVA_HOME)
# Recompile each plugin and copy its shared library over to the java directory
plugins :
mkdir -p $(OUTPUTFOLDER)
$(foreach pdir, $(PLUGINS_DIRS), $(MAKE) -C $(pdir) all; cp -f $(pdir)/bin/$(OSNAME)/$(ARCHNAME)/*$(EXT) $(OUTPUTFOLDER)/;)
# Clean the jni stuff
cleanjni: cleanplugins
@$(MAKE) -C jni/ clean
# Clean the plugin libraries
cleanplugins:
$(foreach pfile, $(PLUGINS_FILES), rm -rf $(pfile);)
# Clean the java classes as well
clean : cleanjni
rm -rf bin/ JTempestSDR.jar