forked from kit-cel/simulink-hackrf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.m
81 lines (65 loc) · 2.41 KB
/
make.m
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
%
% Copyright 2015 Communications Engineering Lab, KIT
%
% This is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 3, or (at your option)
% any later version.
%
% This software is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this software; see the file COPYING. If not, write to
% the Free Software Foundation, Inc., 51 Franklin Street,
% Boston, MA 02110-1301, USA.
function make(varargin)
% make script for Simulink-HackRF
% use "make -v" to get a verbose output
BIN_DIR = fullfile(pwd, 'build');
VERSION = '1.0.0';
%% Configuration
if ispc
% this should point to the directory of hackrf.h
HACKRF_INC_DIR = fullfile(pwd, 'deps', 'include', 'libhackrf');
% this should point to the directory of libhackrf.a
HACKRF_LIB_DIR = fullfile(pwd, 'deps', 'bin');
options = { ...
['-I' pwd]; ['-I' HACKRF_INC_DIR]; ...
['-L' HACKRF_LIB_DIR]; '-lhackrf' ...
};
elseif isunix
% this should point to the directory of hackrf.h
HACKRF_INC_DIR = '/usr/include/libhackrf';
options = { ...
['-I' HACKRF_INC_DIR]; ['-l' 'hackrf'] ...
};
else
error('Platform not supported');
end
%% Prep
if (~exist(BIN_DIR, 'dir')); mkdir(BIN_DIR); end
% create bin order if not exist
options = [options; varargin'; { ...
'-largeArrayDims'; ...
['-DSIMULINK_HACKRF_VERSION=' VERSION]; ...
'-outdir'; BIN_DIR; ...
}];
%% Compile
if isunix && ~any(ismember(varargin, '-v'))
warning('off', 'MATLAB:mex:GccVersion_link');
end
fprintf('\nBuilding target ''%s'':\n', 'hackrf_find_devices.c');
mex(options{:}, 'src/hackrf_find_devices.c')
fprintf('\nBuilding target ''%s'':\n', 'hackrf_source.c');
mex(options{:}, 'src/hackrf_source.c', 'src/common.c')
fprintf('\nBuilding target ''%s'':\n', 'hackrf_sink.c');
mex(options{:}, 'src/hackrf_sink.c', 'src/common.c')
warning('on', 'MATLAB:mex:GccVersion_link');
%% Post
copyfile('src/hackrf_find_devices.m', BIN_DIR)
copyfile('blockset/hackrf_library.slx', BIN_DIR)
copyfile('blockset/slblocks.m', BIN_DIR)
fprintf('\n--> Add "%s" to your MATLAB Path.\n', BIN_DIR);