2017-08-09 10:00:11 +00:00
|
|
|
|
|
|
|
# To compile for Raspberry PI ARM:
|
|
|
|
# make HOST=arm
|
|
|
|
#
|
|
|
|
# To build with debug information:
|
|
|
|
# make DEBUG=true
|
|
|
|
# make DEBUG=true HOST=arm
|
|
|
|
|
|
|
|
ifeq "$(HOST)" "arm"
|
|
|
|
CXX=arm-linux-gnueabihf-g++
|
|
|
|
STRIP=arm-linux-gnueabihf-strip
|
|
|
|
BUILD=build_arm
|
|
|
|
else
|
2017-09-02 09:15:47 +00:00
|
|
|
CXX=g++
|
2017-08-09 10:00:11 +00:00
|
|
|
STRIP=strip
|
|
|
|
BUILD=build
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq "$(DEBUG)" "true"
|
|
|
|
DEBUG_FLAGS=-O0 -g
|
|
|
|
STRIP_BINARY=
|
|
|
|
BUILD:=$(BUILD)_debug
|
|
|
|
else
|
|
|
|
DEBUG_FLAGS=-Os
|
|
|
|
STRIP_BINARY=$(STRIP) $(BUILD)/wmbusmeters
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(shell mkdir -p $(BUILD))
|
|
|
|
|
2018-11-23 08:04:31 +00:00
|
|
|
CXXFLAGS := $(DEBUG_FLAGS) -fPIC -fmessage-length=0 -std=c++11 -Wall -Wno-maybe-uninitialized -Wno-unused-function "-DWMBUSMETERS_VERSION=\"0.7\""
|
2017-08-09 10:00:11 +00:00
|
|
|
|
|
|
|
$(BUILD)/%.o: %.cc $(wildcard %.h)
|
|
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
|
|
|
|
METERS_OBJS:=\
|
|
|
|
$(BUILD)/aes.o \
|
2017-08-31 08:58:39 +00:00
|
|
|
$(BUILD)/cmdline.o \
|
2018-04-01 06:53:37 +00:00
|
|
|
$(BUILD)/dvparser.o \
|
2017-08-31 08:58:39 +00:00
|
|
|
$(BUILD)/meters.o \
|
|
|
|
$(BUILD)/meter_multical21.o \
|
2018-03-05 10:29:25 +00:00
|
|
|
$(BUILD)/meter_multical302.o \
|
2018-03-16 10:48:04 +00:00
|
|
|
$(BUILD)/meter_omnipower.o \
|
2018-11-01 16:17:23 +00:00
|
|
|
$(BUILD)/meter_supercom587.o \
|
2018-11-23 08:04:31 +00:00
|
|
|
$(BUILD)/meter_iperl.o \
|
2017-09-02 21:26:57 +00:00
|
|
|
$(BUILD)/printer.o \
|
2017-08-09 10:00:11 +00:00
|
|
|
$(BUILD)/serial.o \
|
2018-11-02 12:50:12 +00:00
|
|
|
$(BUILD)/shell.o \
|
2017-08-31 08:58:39 +00:00
|
|
|
$(BUILD)/util.o \
|
2017-08-09 10:00:11 +00:00
|
|
|
$(BUILD)/wmbus.o \
|
2018-02-28 21:14:16 +00:00
|
|
|
$(BUILD)/wmbus_amb8465.o \
|
2017-08-09 10:00:11 +00:00
|
|
|
$(BUILD)/wmbus_im871a.o \
|
2018-03-05 10:29:25 +00:00
|
|
|
$(BUILD)/wmbus_simulator.o \
|
|
|
|
$(BUILD)/wmbus_utils.o
|
2017-08-09 10:00:11 +00:00
|
|
|
|
2018-04-20 09:42:46 +00:00
|
|
|
all: $(BUILD)/wmbusmeters $(BUILD)/testinternals
|
2017-08-09 10:00:11 +00:00
|
|
|
$(STRIP_BINARY)
|
|
|
|
|
2018-04-20 09:42:46 +00:00
|
|
|
$(BUILD)/wmbusmeters: $(METERS_OBJS) $(BUILD)/main.o
|
|
|
|
$(CXX) -o $(BUILD)/wmbusmeters $(METERS_OBJS) $(BUILD)/main.o -lpthread
|
|
|
|
|
|
|
|
$(BUILD)/testinternals: $(METERS_OBJS) $(BUILD)/testinternals.o
|
|
|
|
$(CXX) -o $(BUILD)/testinternals $(METERS_OBJS) $(BUILD)/testinternals.o -lpthread
|
2017-08-09 10:00:11 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f build/* build_arm/* build_debug/* build_arm_debug/* *~
|
2017-09-02 21:26:57 +00:00
|
|
|
|
2018-01-05 16:46:10 +00:00
|
|
|
test:
|
2018-04-20 09:42:46 +00:00
|
|
|
./build/testinternals
|
2018-03-05 10:29:25 +00:00
|
|
|
./test.sh build/wmbusmeters
|
2018-01-05 16:46:10 +00:00
|
|
|
|
2017-09-02 21:26:57 +00:00
|
|
|
update_manufacturers:
|
|
|
|
wget http://www.m-bus.de/man.html
|
|
|
|
echo '// Data downloaded from http://www.m-bus.de/man.html' > m.h
|
|
|
|
echo -n '// ' >> m.h
|
|
|
|
date --rfc-3339=date >> m.h
|
|
|
|
echo >> m.h
|
2018-01-05 16:46:10 +00:00
|
|
|
echo '#ifndef MANUFACTURERS_H' >> m.h
|
|
|
|
echo '#define MANUFACTURERS_H' >> m.h
|
2017-09-02 21:26:57 +00:00
|
|
|
echo '#define MANFCODE(a,b,c) ((a-64)*1024+(b-64)*32+(c-64))' >> m.h
|
|
|
|
echo '#define LIST_OF_MANUFACTURERS \' >> m.h
|
|
|
|
cat man.html | tr -d '\r\n' | sed \
|
|
|
|
-e 's/.*<table>//' \
|
|
|
|
-e 's/<\/table>.*//' \
|
|
|
|
-e 's/<tr>/X(/g' \
|
|
|
|
-e 's/<script[^<]*<\/script>//g' \
|
|
|
|
-e 's/<a href=[^>]*>//g' \
|
|
|
|
-e 's/<\/a>//g' \
|
|
|
|
-e 's/<a name[^>]*>//g' \
|
|
|
|
-e 's/<td>/\t/g' \
|
|
|
|
-e 's/<\/td>//g' \
|
|
|
|
-e 's/ä/ä/g' \
|
|
|
|
-e 's/ü/ü/g' \
|
|
|
|
-e 's/ö/ö/g' \
|
|
|
|
-e 's/,/ /g' \
|
|
|
|
-e 's/<\/tr>/)\\\n/g' | \
|
|
|
|
grep -v '<caption>' | tr -s ' ' | tr -s '\t' | tr '\t' '|' > tmpfile
|
|
|
|
cat tmpfile | sed -e "s/X(|\(.\)\(.\)\(.\)/X(\1\2\3|MANFCODE('\1','\2','\3')|/g" | \
|
|
|
|
tr -s '|' ',' >> m.h
|
|
|
|
echo >> m.h
|
|
|
|
cat tmpfile | sed -e "s/X(|\(.\)\(.\)\(.\).*/#define MANUFACTURER_\1\2\3 MANFCODE('\1','\2','\3')/g" \
|
|
|
|
>> m.h
|
|
|
|
echo >> m.h
|
|
|
|
echo '#endif' >> m.h
|
|
|
|
rm tmpfile
|
|
|
|
mv m.h manufacturers.h
|