-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
78 lines (56 loc) · 1.75 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
cBuildDir=./cbuild
cLib=./clib
pLib=./lib
pPackage=OLED
systemCDir=/usr/lib
systemConfigBaseDir=/etc
programName=emb-rtttl
cLibName=us2066
gccWiringPiDeps=-lwiringPiDev -lwiringPi -lcrypt
debianPackages=perl swig
debianPackagedPerlModules=libtest-simple-perl libmodern-perl-perl libmodule-build-perl
#Macro to check the exit code of a make expression and possibly not fail on warnings
RC := test $$? -lt 100
build: compile
restart:
install: installPackages build perlDeploy link configure
installPackages:
sudo apt-get install -y $(debianPackages)
sudo apt-get install -y $(debianPackagedPerlModules)
perlDeploy:
./Build installdeps
./Build install
compile:
##BUILD Perl XS madness using handy dandy swig <3
mkdir -p $(cBuildDir)
cp -r $(cLib)/* $(cBuildDir)/
cd $(cBuildDir); \
\
swig -perl5 $(cLibName).i; \
\
gcc -c `perl -MConfig -e 'print join(" ", @Config{qw(ccflags optimize cccdlflags)}, \
"-I$$Config{archlib}/CORE")'` $(cLibName).c $(cLibName)_wrap.c $(gccWiringPiDeps); \
\
gcc -shared `perl -MConfig -e 'print $$Config{lddlflags}'` $(cLibName).o $(cLibName)_wrap.o -o $(cLibName).so $(gccWiringPiDeps); \
gcc -Wall -o test test.c $(gccWiringPiDeps);
mkdir -p $(pLib)/$(pPackage)
cp $(cBuildDir)/$(cLibName).pm $(pLib)/$(pPackage)/
cp $(cBuildDir)/$(cLibName).so $(pLib)/$(pPackage)/
cp $(cBuildDir)/test $(cLib)/test
rm -r $(cBuildDir)
#Build Perl modules
perl Build.PL
./Build
test:
#$(cLib)/test #c-tests are on an endless loop.
prove -Ilib -I. t/*.t
configure:
unconfigure:
link: compile
cp $(pLib)/$(pPackage)/$(cLibName).so $(systemCDir)/$(cLibName).so
unlink:
rm $(systemCDir)/$(cLibName).so || $(RC)
clean:
rm $(pLib)/$(pPackage)/$(cLibName).so || $(RC)
./Build realclean
uninstall: unlink unconfigure clean