-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
103 lines (72 loc) · 2.47 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
93
94
95
96
97
98
99
100
101
102
103
# This is the name of the project. We get it from the basename of
# the project folder. It may contain mixed-case, and "-" as word
# separators. CamelCase is discouraged.
#
# The MAJORVER and MINORVER here are place holders; during a
# gitpkgtool build they are substituted in-place
# by patchVersion.sh.
CWD=$(shell pwd)
PROJECT=$(shell basename $(CWD))
MAJORVER=1
MINORVER=0
# The debian package name. It may contain "-" as a word seperator
# but must be all lower case.
PACKAGE=$(shell echo $(PROJECT) | tr A-Z a-z)
# the library name. it may contain mixed case but the "-" should be
# removed.
LIBNAME=libwiringPi
# the libname without the "lib" prefix, used when linking
LNAME=$(shell echo $(LIBNAME)|sed -e 's/^lib//')
# DESTDIR is overridden by debhelper.
PREFIX=$(DESTDIR)/usr
CC=gcc
AR=ar
CFLAGS= -I src/libsrc -O3 -g
LIBS= $(LNAME)
LDOPTS=$(patsubst %, -l%, $(LIBS))
LIBSRCS=$(wildcard src/libwiringPi/*.c)
LIBOBJS=$(patsubst %.c,%.lo, $(LIBSRCS))
#TESTSRCS=$(wildcard src/test/*.cpp)
#TESTOBJS=$(patsubst %.cpp,%.o, $(TESTSRCS))
#EXE=$(patsubst %.o,%,$(TESTOBJS))
LIBFILE=$(LIBNAME).so.$(MAJORVER).$(MINORVER)
# The soname is the MAJORVER. Therefore MAJORVER is
# incremented whenever the ABI changes, and MINROVER is
# incremented when (only) the implementation changes.
SONAME=$(LIBNAME).so.$(MAJORVER)
world: all
%.o:%.c
@echo "\t[CC] $<"
$(CC) $(CFLAGS) -c -o $@ $<
%.lo:%.c
@echo "\t[CC] $<"
$(CC) $(CFLAGS) -fPIC -c -o $@ $<
$(LIBFILE):$(LIBOBJS)
@echo "\tBuilding Shared Lib $@"
$(CC) $(CFLAGS) -shared -Wl,-soname,$(SONAME) -o $@ $(LIBOBJS)
ln -sf $(LIBFILE) $(SONAME)
ln -sf $(LIBFILE) $(LIBNAME).so
#src/test/TestXPlaneBeaconListener: $(TESTOBJS)
# $(CC) -L . -o $@ src/test/TestXPlaneBeaconListener.o $(LIBNAME).so
#src/test/TestXPlaneUDPClient: $(TESTOBJS)
# $(CC) -L . -o $@ src/test/TestXPlaneUDPClient.o $(LIBNAME).so
clean:
@echo "\t[CLEAN]"
@rm -rf $(LIBOBJS) $(LIBFILE) $(SONAME) $(LIBNAME).so \
$(TESTOBJS) $(EXE) \
docs
distclean: clean
doc:
#doxygen
install: $(LIBFILE) $(EXE) doc
install -D $(LIBFILE) $(PREFIX)/lib/$(LIBFILE)
ln -sf $(LIBFILE) $(PREFIX)/lib/$(SONAME)
ln -sf $(LIBFILE) $(PREFIX)/lib/$(LIBNAME).so
#install -D $(EXE) --target-directory=$(PREFIX)/bin
mkdir -p $(PREFIX)/include
install -D src/libwiringPi/*h $(PREFIX)/include/
#install -D src/libsrc/XPlaneUDPClient.h $(PREFIX)/include/XPlaneUDPClient.h
mkdir -p $(PREFIX)/share/doc/$(PACKAGE)
#cp -r docs/* $(PREFIX)/share/doc/$(PACKAGE)
all: $(LIBFILE)
#$(EXE)