-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
executable file
·92 lines (73 loc) · 2.67 KB
/
makefile
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
# makefile for libsalt C# library
# created by: Michael Mendoza
# -----------------------------------------------------------------------------
# MAKE CONFIGURATION
CC = g++
# complier flags
# -dynamiclab turns on generating a dylib for mac
# -g adds debugging information to the executable file
# -Wall turns on most, but not all, compiler warnings
CFLAGS = -dynamiclib -Wall
TARGET = LibSalt
INCLUDE = -I/usr/local/include/sodium -lsodium -I/libsalt
TESTS = LibSaltTest
CXXTEST = -I/usr/local/include/cxxtest
# -----------------------------------------------------------------------------
# LIBRARY FILES
# creates LibSalt dylib binary file (LibSalt.dylib) and C# dll (LibSalt.dll)
build:
mkdir -p dist
cp libsalt/$(TARGET).cs dist/$(TARGET).cs
$(CC) $(CFLAGS) -o dist/$(TARGET).dylib libsalt/$(TARGET).cpp $(INCLUDE)
mcs -t:library dist/$(TARGET).cs
# -----------------------------------------------------------------------------
# EXAMPLES
# complies and builds c# bindings examples
example:
mcs examples/$(TARGET)Example.cs dist/$(TARGET).cs
mono examples/$(TARGET)Example.exe
# complies and builds cpp bindings examples
example_cpp:
$(CC) -o examples/$(TARGET)Example.out examples/$(TARGET)Example.cpp libsalt/$(TARGET).cpp $(INCLUDE)
./examples/$(TARGET)Example.out
make clean_examples
# -----------------------------------------------------------------------------
# TESTS
# runs C# unit tests
tests:
mcs test/$(TESTS).cs dist/$(TARGET).cs
mono test/$(TARGET)Test.exe
make clean_tests
# runs cxxtest (make sure to install cxxtest with `brew install cxxtest`)
tests_cpp:
cxxtestgen --error-printer -o runner.cpp test/$(TARGET)TestSuite.h
g++ -o runner runner.cpp libsalt/$(TARGET).cpp $(CXXTEST) $(INCLUDE)
./runner
make clean_tests
# compiles and builds executable for C# tests with LabSalt.cs
build_tests:
mcs test/$(TESTS).cs dist/$(TARGET).cs
# compiles and builds executable for C# tests with LabSalt.dll
build_tests_dll:
mcs test/$(TESTS).cs -r:dist/$(TARGET).dll
# -----------------------------------------------------------------------------
# CLEAN
# clean and removes complied files
clean:
rm -f dist/$(TARGET).dylib dist/$(TARGET).dll
rm -fr dist/$(TARGET).dylib.dSYM
rm -f dist/$(TARGET).cs
rm -f examples/*.out examples/*.exe
rm -f test/*.out test/*.exe
rm -f runner runner.cpp
# clean and removes complied files for examples
clean_examples:
rm -f examples/*.out
# clean and removes complied files for test runner
clean_tests:
rm -f test/*.exe
rm -f runner runner.cpp
# Building Wrapper
#g++ -dynamiclib -o libsodium_wrapper.dylib LibSodiumWrapper.cpp -lsodium
#Building Test
#g++ LibSodiumTest.cpp -lsodium LibSodiumWrapper.cpp