2019-01-04 20:25:15 +00:00
|
|
|
# Copyright (C) 2017-2019 Fredrik Öhrström
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
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
|
|
|
|
|
2019-03-12 19:05:05 +00:00
|
|
|
VERSION=0.9.2
|
2019-02-23 17:30:16 +00:00
|
|
|
|
2017-08-09 10:00:11 +00:00
|
|
|
ifeq "$(HOST)" "arm"
|
|
|
|
CXX=arm-linux-gnueabihf-g++
|
|
|
|
STRIP=arm-linux-gnueabihf-strip
|
|
|
|
BUILD=build_arm
|
2019-01-04 20:25:15 +00:00
|
|
|
DEBARCH=armhf
|
2017-08-09 10:00:11 +00:00
|
|
|
else
|
2017-09-02 09:15:47 +00:00
|
|
|
CXX=g++
|
2019-02-23 20:36:40 +00:00
|
|
|
STRIP=strip
|
|
|
|
#--strip-unneeded --remove-section=.comment --remove-section=.note
|
2017-08-09 10:00:11 +00:00
|
|
|
BUILD=build
|
2019-01-04 20:25:15 +00:00
|
|
|
DEBARCH=amd64
|
2017-08-09 10:00:11 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq "$(DEBUG)" "true"
|
2018-12-28 17:35:32 +00:00
|
|
|
DEBUG_FLAGS=-O0 -ggdb -fsanitize=address -fno-omit-frame-pointer
|
2017-08-09 10:00:11 +00:00
|
|
|
STRIP_BINARY=
|
|
|
|
BUILD:=$(BUILD)_debug
|
2018-12-28 17:35:32 +00:00
|
|
|
DEBUG_LDFLAGS=-lasan
|
2017-08-09 10:00:11 +00:00
|
|
|
else
|
|
|
|
DEBUG_FLAGS=-Os
|
|
|
|
STRIP_BINARY=$(STRIP) $(BUILD)/wmbusmeters
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(shell mkdir -p $(BUILD))
|
|
|
|
|
2019-02-23 20:21:17 +00:00
|
|
|
#EXTRAS=-Wno-maybe-uninitialized
|
|
|
|
|
|
|
|
CXXFLAGS := $(DEBUG_FLAGS) -fPIC -fmessage-length=0 -std=c++11 -Wall -Wno-unused-function "-DWMBUSMETERS_VERSION=\"$(VERSION)\""
|
2017-08-09 10:00:11 +00:00
|
|
|
|
2019-02-23 12:53:52 +00:00
|
|
|
$(BUILD)/%.o: src/%.cc $(wildcard src/%.h)
|
2017-08-09 10:00:11 +00:00
|
|
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
|
|
|
|
|
|
METERS_OBJS:=\
|
|
|
|
$(BUILD)/aes.o \
|
2017-08-31 08:58:39 +00:00
|
|
|
$(BUILD)/cmdline.o \
|
2019-02-23 12:41:17 +00:00
|
|
|
$(BUILD)/config.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 \
|
2019-02-17 20:47:23 +00:00
|
|
|
$(BUILD)/meter_qcaloric.o \
|
2019-03-15 12:05:54 +00:00
|
|
|
$(BUILD)/meter_apator162.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 \
|
2019-02-25 21:03:20 +00:00
|
|
|
$(BUILD)/wmbus_rtlwmbus.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
|
2019-01-04 20:25:15 +00:00
|
|
|
@$(STRIP_BINARY)
|
2019-03-12 19:57:13 +00:00
|
|
|
@cp $(BUILD)/wmbusmeters $(BUILD)/wmbusmetersd
|
2019-01-04 20:25:15 +00:00
|
|
|
|
2019-02-23 17:30:16 +00:00
|
|
|
dist: wmbusmeters_$(VERSION)_$(DEBARCH).deb
|
|
|
|
|
|
|
|
install: $(BUILD)/wmbusmeters
|
2019-02-23 18:49:30 +00:00
|
|
|
@./install.sh $(BUILD)/wmbusmeters /
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
@./uninstall.sh /
|
2019-01-04 20:25:15 +00:00
|
|
|
|
2019-02-23 17:30:16 +00:00
|
|
|
wmbusmeters_$(VERSION)_$(DEBARCH).deb:
|
|
|
|
@rm -rf $(BUILD)/debian/wmbusmeters
|
2019-01-04 20:25:15 +00:00
|
|
|
@mkdir -p $(BUILD)/debian/wmbusmeters/DEBIAN
|
2019-02-23 18:49:30 +00:00
|
|
|
@./install.sh --no-adduser $(BUILD)/wmbusmeters $(BUILD)/debian/wmbusmeters
|
2019-01-04 20:25:15 +00:00
|
|
|
@rm -f $(BUILD)/debian/wmbusmeters/DEBIAN/control
|
|
|
|
@echo "Package: wmbusmeters" >> $(BUILD)/debian/wmbusmeters/DEBIAN/control
|
2019-02-23 17:30:16 +00:00
|
|
|
@echo "Version: $(VERSION)" >> $(BUILD)/debian/wmbusmeters/DEBIAN/control
|
2019-01-04 20:25:15 +00:00
|
|
|
@echo "Maintainer: Fredrik Öhrström" >> $(BUILD)/debian/wmbusmeters/DEBIAN/control
|
|
|
|
@echo "Architecture: $(DEBARCH)" >> $(BUILD)/debian/wmbusmeters/DEBIAN/control
|
|
|
|
@echo "Description: A tool to read wireless mbus telegrams from utility meters." >> $(BUILD)/debian/wmbusmeters/DEBIAN/control
|
|
|
|
@(cd $(BUILD)/debian; dpkg-deb --build wmbusmeters .)
|
2019-02-23 17:30:16 +00:00
|
|
|
@mv $(BUILD)/debian/wmbusmeters_$(VERSION)_$(DEBARCH).deb .
|
2019-01-04 20:25:15 +00:00
|
|
|
@echo Built package $@
|
2017-08-09 10:00:11 +00:00
|
|
|
|
2018-04-20 09:42:46 +00:00
|
|
|
$(BUILD)/wmbusmeters: $(METERS_OBJS) $(BUILD)/main.o
|
2018-12-28 17:35:32 +00:00
|
|
|
$(CXX) -o $(BUILD)/wmbusmeters $(METERS_OBJS) $(BUILD)/main.o $(DEBUG_LDFLAGS) -lpthread
|
|
|
|
|
2018-04-20 09:42:46 +00:00
|
|
|
|
|
|
|
$(BUILD)/testinternals: $(METERS_OBJS) $(BUILD)/testinternals.o
|
2018-12-28 17:35:32 +00:00
|
|
|
$(CXX) -o $(BUILD)/testinternals $(METERS_OBJS) $(BUILD)/testinternals.o $(DEBUG_LDFLAGS) -lpthread
|
2017-08-09 10:00:11 +00:00
|
|
|
|
|
|
|
clean:
|
2019-01-04 21:27:51 +00:00
|
|
|
rm -rf 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
|
|
|
|
2019-03-05 17:38:54 +00:00
|
|
|
testd:
|
|
|
|
./build_debug/testinternals
|
|
|
|
./test.sh build_debug/wmbusmeters
|
|
|
|
|
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
|
2019-02-17 20:47:23 +00:00
|
|
|
echo 'X(|QDS|QUNDIS GmbH)\' >> tmpfile
|
2019-03-15 12:05:54 +00:00
|
|
|
echo 'X(|APA|Apator Powogaz S.A)\' >> tmpfile
|
2017-09-02 21:26:57 +00:00
|
|
|
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
|
2019-03-15 12:05:54 +00:00
|
|
|
mv m.h src/manufacturers.h
|