forked from crankyoldgit/IRremoteESP8266
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
124 lines (91 loc) · 4.07 KB
/
Copy pathMakefile
File metadata and controls
124 lines (91 loc) · 4.07 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# SYNOPSIS:
#
# make [all] - makes everything.
# make TARGET - makes the given target.
# make run_tests - makes everything and runs all test
# make run-% - run specific test file (exclude .py)
# replace % with given test file
# make clean - removes all files generated by make.
# Please tweak the following variable definitions as needed by your
# project, except GTEST_HEADERS, which you can use in your own targets
# but shouldn't modify.
ifeq (,$(wildcard ./.dockerenv))
SWIGTYPE = local
else
SWIGTYPE = global
endif
# Where to find user code.
SRC_DIR = ../src
# Where to find test code.
TEST_DIR = ../test
INCLUDES = -I$(SRC_DIR) -I$(TEST_DIR)
DEFFLAGS = -DUNIT_TEST -DSWIGLIB
# Flags passed to the preprocessor.
# Set Google Test's header directory as a system directory, such that
# the compiler doesn't generate warnings in Google Test headers.
CPPFLAGS += -D_IR_LOCALE_=en-AU -fPIC $(DEFFLAGS)
# Flags passed to the C++ compiler.
CXXFLAGS += -g -Wall -Wextra -pthread -std=gnu++11
PYTHONINCL = $(shell python3-config --includes)
objects = $(patsubst %.cpp,%,$(wildcard *.cpp))
all : _irhvac.so
library : $(objects)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -Wl,-soname,lib_irhvac.so -o _irhvac.so $(COMMON_OBJ)
swig : libirhvac_wrap.cxx
ifneq (,$(wildcard /.dockerenv))
SWIG_LIB=$(shell realpath -qe swig-4.2.0/Lib) ./swig-4.2.0/swig $(INCLUDES) $(DEFFLAGS) -c++ -python libirhvac.i
else
swig $(INCLUDES) $(DEFFLAGS) -c++ -python libirhvac.i
endif
clean :
rm -f *.o *.pyc *.cxx *.cpp
rm -rf swig-4.2.0
distclean :
rm -f *.o *.pyc libirhvac_wrap.cxx irhvac.py _irhvac.so
rm -rf swig-4.2.0
test : _irhvac.so
python test_lib.py
docker : swig-4.2.0/swig _irhvac.so
testdocker : swig-4.2.0/swig _irhvac.so
python test_lib.py
# Keep all intermediate files.
.SECONDARY:
# All the IR protocol object files.
PROTOCOL_OBJS = $(patsubst %.cpp,%.o,$(wildcard $(SRC_DIR)/ir_*.cpp))
PROTOCOLS = $(patsubst $(SRC_DIR)/%,%,$(PROTOCOL_OBJS))
# Common object files
COMMON_OBJ = libirhvac_wrap.o IRutils.o IRtimer.o IRsend.o IRrecv.o IRtext.o IRac.o $(PROTOCOLS)
# Common dependencies
COMMON_DEPS = $(SRC_DIR)/IRrecv.h $(SRC_DIR)/IRsend.h $(SRC_DIR)/IRtimer.h \
$(SRC_DIR)/IRutils.h $(SRC_DIR)/IRremoteESP8266.h \
$(SRC_DIR)/IRtext.h $(SRC_DIR)/i18n.h
# Common test dependencies
COMMON_TEST_DEPS = $(COMMON_DEPS) $(TEST_DIR)/IRsend_test.h
IRtext.o : $(SRC_DIR)/IRtext.cpp $(SRC_DIR)/IRtext.h $(SRC_DIR)/IRremoteESP8266.h $(SRC_DIR)/i18n.h $(SRC_DIR)/locale/*.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) -c $(SRC_DIR)/IRtext.cpp
IRutils.o : $(SRC_DIR)/IRutils.cpp $(SRC_DIR)/IRutils.h $(SRC_DIR)/IRremoteESP8266.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SRC_DIR)/IRutils.cpp
IRsend.o : $(SRC_DIR)/IRsend.cpp $(SRC_DIR)/IRsend.h $(SRC_DIR)/IRremoteESP8266.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SRC_DIR)/IRsend.cpp
IRrecv.o : $(SRC_DIR)/IRrecv.cpp $(SRC_DIR)/IRrecv.h $(SRC_DIR)/IRremoteESP8266.h $(GTEST_HEADERS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SRC_DIR)/IRrecv.cpp
libirhvac_wrap.o : libirhvac_wrap.cxx
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) $(PYTHONINCL) -c libirhvac_wrap.cxx
libirhvac_wrap.cxx :
swig $(INCLUDES) $(DEFFLAGS) -c++ -python libirhvac.i
_irhvac.so : $(COMMON_OBJ)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -Wl,-soname,lib_irhvac.so -o _irhvac.so $(COMMON_OBJ)
swig-4.2.0/swig :
curl -s -L -o - http://downloads.sourceforge.net/project/swig/swig/swig-4.2.0/swig-4.2.0.tar.gz | tar xfz -
( cd swig-4.2.0; ./configure ; make )
# new specific targets goes above this line
$(objects) : %: $(COMMON_OBJ)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@
ir_%.o : $(SRC_DIR)/ir_%.h $(SRC_DIR)/ir_%.cpp $(COMMON_DEPS) $(GTEST_HEADERS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) -c $(SRC_DIR)/ir_$*.cpp
ir_%.o : $(SRC_DIR)/ir_%.cpp $(GTEST_HEADERS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) -c $(SRC_DIR)/ir_$*.cpp
%.o : %.cpp $(COMMON_DEPS) $(GTEST_HEADERS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) -c $*.cpp
%.o : $(SRC_DIR)/%.cpp $(SRC_DIR)/%.h $(COMMON_DEPS) $(GTEST_HEADERS)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) -c $(SRC_DIR)/$*.cpp