Skip to content

Commit 74ce715

Browse files
committed
Working makefiles! Wohoo!
1 parent f5050ae commit 74ce715

10 files changed

Lines changed: 163 additions & 56 deletions

File tree

JavaGUI/jni/TSDRLibraryNDK.h

Lines changed: 0 additions & 21 deletions
This file was deleted.

JavaGUI/jni/include/TSDRLibrary.h

Lines changed: 0 additions & 6 deletions
This file was deleted.

JavaGUI/jni/makefile

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
# TODO! Make this platform independent!
2-
INC = "C:\PROGRA~2\Java\jdk1.7.0_45\include" "C:\PROGRA~2\Java\jdk1.7.0_45\include\win32"
1+
# JAVA_HOME should be initialized to something like C:\PROGRA~2\Java\jdk1.7.0_45
2+
ifndef JAVA_HOME
3+
$(warning JAVA_HOME should be set so it points to your jdk installation dir)
4+
endif
5+
6+
# Headers
7+
INC = "$(JAVA_HOME)/include" "$(JAVA_HOME)/include/win32"
38

9+
# Detect library extension depending on OS
410
ifeq ($(OS),Windows_NT)
511
EXT = .dll
612
else
@@ -10,31 +16,38 @@ else
1016
endif
1117
endif
1218

19+
# We want to build the library
1320
all : ../TSDRLibraryNDK$(EXT)
1421

15-
# $@ matches the target, $< matches the firs8t dependancy
22+
# Linking
1623
../TSDRLibraryNDK$(EXT) : TSDRLibraryNDK.o rebuildtempestsdr
1724
gcc -L../../TempestSDR/bin/ -lTSDRLibrary -Wl,--add-stdcall-alias -shared -o $@ $<
1825

26+
# Rebuild the main library so that we have the most up-to-date version
27+
# The main library is assumed to be two levels below this jni folder
1928
rebuildtempestsdr :
2029
@$(MAKE) -C ../../TempestSDR bin/TSDRLibrary$(EXT)
2130
@cp -f ../../TempestSDR/bin/TSDRLibrary$(EXT) ../TSDRLibrary$(EXT)
2231

23-
# $@ matches the target, $< matches the first dependancy
32+
# Compile the sources to obj files
2433
TSDRLibraryNDK.o : TSDRLibraryNDK.c TSDRLibraryNDK.h include/TSDRLibrary.h
2534
gcc $(foreach d, $(INC), -I$d) -c $< -o $@
26-
35+
36+
# Copy over a fresh set of library headers
2737
include/TSDRLibrary.h : ../../TempestSDR/src/include/TSDRLibrary.h
2838
mkdir -p include
2939
@cp -f $< $@
3040

41+
# Generate the java header based on the class
3142
TSDRLibraryNDK.h : ../bin/martin/tempest/core/TSDRLibrary.class
3243
javah -classpath ../bin -o TSDRLibraryNDK.h -jni martin.tempest.core.TSDRLibrary
33-
44+
45+
# If the class is not compiled, do it
3446
../bin/martin/tempest/core/TSDRLibrary.class : ../src/martin/tempest/core/TSDRLibrary.java
3547
mkdir -p include ../bin/martin/tempest/core/
36-
javac $< -d ../bin/
48+
javac $< -d ../bin/ -cp ../src/
3749

50+
# Remove any compiled artifacts
3851
clean :
3952
rm -f TSDRLibraryNDK.h *.o ../TSDRLibraryNDK$(EXT) ../TSDRLibrary$(EXT) include/*.h
4053
rm -rf include/

JavaGUI/makefile

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,68 @@
1+
# USER CONFIGURATION STARTS HERE
2+
3+
# Define the plugins that you like to compile with the library. They need to be in a folder
4+
# in the parent directory with the exact same name as the plugin names. The library files
5+
# produced need to have the name of the plugin folder and need to be in the bin directory.
6+
# The default plugin file will make sure this is compatible.
7+
PLUGINS=TSDRPlugin_RawFile
8+
9+
# USER CONFIGURATION ENDS HERE
10+
11+
# Define a recursive wildcard function
12+
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
13+
14+
# Discover all the java sources
15+
JAVAFILES:=$(call rwildcard,src/,*.java)
16+
17+
# Create the class dependencies
18+
CLASSFILES:=$(patsubst %,bin/%,$(addsuffix .class,$(basename $(foreach jfile,$(JAVAFILES), $(subst src/,,$(jfile)) ))))
19+
20+
# Detect shared library extension based on OS
21+
ifeq ($(OS),Windows_NT)
22+
EXT = .dll
23+
else
24+
UNAME_S := $(shell uname -s)
25+
ifeq ($(UNAME_S),Linux)
26+
EXT = .so
27+
endif
28+
endif
29+
30+
# Build the file names of the plugin files
31+
PLUGINS_FILES=$(addsuffix $(EXT),$(PLUGINS))
32+
33+
# Build the directory names of the plugins
34+
PLUGINS_DIRS=$(addprefix ../,$(addsuffix /,$(PLUGINS)))
35+
36+
# When compiling from command line with all
37+
# make sure we compile both jni and java files
138
all : jnilib java
239

3-
java :
4-
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
5-
javafiles=$(call rwildcard,/src/,*.java)
6-
7-
jnilib :
8-
@$(MAKE) -C jni/ all
40+
# The compilation of the java classes from command line
41+
# depends on the class files (we want to produce them)
42+
java : $(CLASSFILES)
43+
44+
# For each class file, invoke javac with the source file which is constructed
45+
# from the name of the class file
46+
%.class : $(JAVAFILES)
47+
mkdir -p bin # Create the bin directory if it doesn't exist (if you downloaded it from github)
48+
javac $(patsubst %,src/%, $(subst bin/,,$(@:.class=.java))) -d bin/ -cp src/
49+
50+
# Invoke the makefile for the jni stuff
51+
jnilib : plugins
52+
@$(MAKE) -C jni/ all JAVA_HOME=$(JAVA_HOME)
953

10-
cleanjni:
54+
# Recompile each plugin and copy its shared library over to the java directory
55+
plugins :
56+
$(foreach pdir, $(PLUGINS_DIRS), $(MAKE) -C $(pdir) all; cp -f $(pdir)/bin/*$(EXT) .;)
57+
58+
# Clean the jni stuff
59+
cleanjni: cleanplugins
1160
@$(MAKE) -C jni/ clean
12-
61+
62+
# Clean the plugin libraries
63+
cleanplugins:
64+
$(foreach pfile, $(PLUGINS_FILES), rm -rf $(pfile);)
65+
66+
# Clean the java classes as well
1367
clean : cleanjni
1468
rm -rf bin/

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,46 @@ Folder Structure
88

99
The different folders contain the different subprojects. The TempestSDR folder contains the main C library. The project aims to be crossplatform with plugin support for SDR frontends in different folders.
1010

11-
Compiling
11+
Requirements for Building
1212
------------
1313

14-
The project is built with Eclipse with the CDT plugin. Currently it supports Windows and Linux. Some frontend plugins might not be crossplatform.
14+
The project is built with Eclipse with the CDT plugin (but this is not required). Currently it supports Windows and Linux. Some frontend plugins might not be crossplatform. You also need a Java Development Kit (JDK) installed.
1515

1616
### Windows
1717

1818
You need to have MinGW installed and gcc and make commands need to be in your path. Also javac and javah also need to be in your path.
1919

2020
### Linux
2121

22-
To be announced soon.
22+
To be announced soon.
23+
24+
Building
25+
------------
26+
27+
All project could be built both with Eclipse and make as well.
28+
29+
### TempestSDR library
30+
31+
Enter the folder and type
32+
33+
make all
34+
35+
This will produce the library which could be found in the bin subdir. The headers you need to interface with it are located in src/include.
36+
37+
### Plugins
38+
39+
Go into a plugin directory and type
40+
41+
make all
42+
43+
This should work unless there is something specific for the plugin itself. Look for a README in this case.
44+
45+
### JavaGUI
46+
47+
This is the Java wrapper and GUI. It builds all projects and supported plugins including the Java GUI itself. Go into the JavaGUI folder and type in
48+
49+
make all JAVA_HOME=path_to_jdk_installation
50+
51+
On Windows 8 this could look like
52+
53+
make all JAVA_HOME=C:/PROGRA~2/Java/jdk1.7.0_45

TSDRPlugin_RawFile/makefile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
# This makefile should work for all plugins that reside in the root directory of the repository.
22
# The header file is copied over from the source
33
PLUGNAME=TSDRPlugin_RawFile
4+
5+
# Dependencies
6+
OBJS=$(PLUGNAME).o
7+
DEPS=TSDRPlugin.h
8+
9+
# END OF CONFIGURATION IF STANDARD DIR STRUCTURE IS USED
10+
11+
# Where the TSDRPlugin.h of the TempestSDR library resides (so it will be copied over)
412
HEADLOCATION=../TempestSDR/src/include/
513

14+
# If you need a different directory structure. Don't change that unless you really want to.
615
SOURCEFOLDER=src
716
OUTPUTFOLDER=bin
817
OBJFOLDER=bin/obj
918

10-
OBJS=$(PLUGNAME).o
11-
DEPS=TSDRPlugin.h
12-
19+
# Calculate the path to dependencies
1320
_OBJS = $(patsubst %,$(OBJFOLDER)/%,$(OBJS))
1421
_DEPS = $(patsubst %,$(SOURCEFOLDER)/%,$(DEPS))
1522

23+
# Discover the library extension for each OS
1624
ifeq ($(OS),Windows_NT)
1725
EXT = .dll
1826
else
@@ -22,20 +30,25 @@ else
2230
endif
2331
endif
2432

33+
# Generate the library
2534
all : $(OUTPUTFOLDER)/$(PLUGNAME)$(EXT)
2635

36+
# Copy over a fresh version of the TSDRPlugin.h
2737
copyoverheaderfile:
2838
@cp -f $(HEADLOCATION)/TSDRPlugin.h $(SOURCEFOLDER)/TSDRPlugin.h
2939

30-
$(OUTPUTFOLDER)/$(PLUGNAME)$(EXT): $(_OBJS)
40+
# Link
41+
$(OUTPUTFOLDER)/$(PLUGNAME)$(EXT): copyoverheaderfile $(_OBJS)
3142
gcc -Wl,--add-stdcall-alias -shared -o $@ $(_OBJS)
3243

44+
# Make dirs and compile
3345
$(OBJFOLDER)/%.o : $(SOURCEFOLDER)/%.c $(_DEPS)
3446
mkdir -p $(OUTPUTFOLDER)
3547
mkdir -p $(OBJFOLDER)
3648
gcc $(foreach d, $(INC), -I$d) -c $< -o $@
3749

3850
.PHONY: clean
3951

52+
# Clean artifacts
4053
clean :
41-
rm -f $(OBJFOLDER)/*.o $(OUTPUTFOLDER)/$(PLUGNAME)$(EXT) $(SOURCEFOLDER)/TSDRPlugin.h
54+
rm -f $(OBJFOLDER)/*.o $(OUTPUTFOLDER)/$(PLUGNAME)$(EXT)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef _TSDRPluginHeader
2+
#define _TSDRPluginHeader
3+
4+
void tsdrplugin_getName(char *);
5+
6+
#endif

TSDRPlugin_RawFile/src/TSDRPlugin_RawFile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
14
#include "TSDRPlugin.h"
25

36
void tsdrplugin_getName(char * name) {

TempestSDR/makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
# Define all of the C files here
12
OBJS = TSDRLibrary.o TSDRPluginLoader.o
3+
4+
# Define all of the dependencies here
25
DEPS = include/TSDRLibrary.h TSDRPluginLoader.h
36

7+
# USER CONFIGURATION ENDS HERE
8+
9+
# The obj files reside in the bin/obj directory
410
_OBJS = $(patsubst %,bin/obj/%,$(OBJS))
11+
12+
# The header files are relative to the source directory
513
_DEPS = $(patsubst %,src/%,$(DEPS))
614

15+
# Detect library extension based on OS
716
ifeq ($(OS),Windows_NT)
817
EXT = .dll
918
else
@@ -13,19 +22,21 @@ else
1322
endif
1423
endif
1524

25+
# Build library
1626
all : bin/TSDRLibrary$(EXT)
1727

18-
# $@ matches the target, $< matches the first dependancy
28+
# Link
1929
bin/TSDRLibrary$(EXT) : $(_OBJS)
2030
gcc -Wl,--add-stdcall-alias -shared -o $@ $(_OBJS)
2131

22-
# $@ matches the target, $< matches the first dependancy
32+
# Create folders if needed and compile
2333
bin/obj/%.o : src/%.c $(_DEPS)
2434
mkdir -p bin
2535
mkdir -p bin/obj
2636
gcc $(foreach d, $(INC), -I$d) -c $< -o $@
2737

2838
.PHONY: clean
2939

40+
# Clean artifacts
3041
clean :
3142
rm -f bin/obj/*.o bin/TSDRLibrary$(EXT)

TempestSDR/src/TSDRLibrary.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
void test(void) {
1515
pluginsource_t plugin;
1616

17-
if (tsdrplug_load(&plugin, "abc.dll"))
18-
printf(plugin.tsdrplugin_getName());
19-
else
20-
printf("Error!");
17+
char name[40] = "Not working :( ";
18+
19+
if (tsdrplug_load(&plugin, "TSDRPlugin_RawFile.dll")) {
20+
plugin.tsdrplugin_getName(name);
21+
printf("%s\n",name);
22+
} else
23+
printf("Error!\n");
2124

2225
tsdrplug_close(&plugin);
2326
}

0 commit comments

Comments
 (0)