# Makefile for building Raspbery Pi LPC1114 I/O Processor Expansion Board # support software package # Copyright (C)2013-2023, Philip Munts dba Munts Technologies # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # Override the following macros to build out of tree: ARMSRC ?= $(HOME)/arm-mcu RASPBERRYPI_LPC1114_SRC ?= $(HOME)/rpi-mcu/expansion/LPC1114/src OSNAME ?= UNKNOWN PYTHONDST := $(shell ./packagedir.py) ifeq ($(CLIENTONLY), yes) PKGNAME := munts-expansion-lpc1114-client else PKGNAME := munts-expansion-lpc1114 endif PKGVERSION := $(shell date +%Y.%j) PKGARCH := $(shell dpkg --print-architecture) PKGDIR := $(PKGNAME)-$(PKGVERSION)-$(OSNAME)-$(PKGARCH) PKGFILE := $(PKGDIR).deb default: package.deb # Stage software components in staging directory tree $(PKGDIR): ifeq ($(CLIENTONLY), yes) mkdir -p $(PKGDIR)/DEBIAN install -cm 0644 control.client $(PKGDIR)/DEBIAN/control sed -i s/@@ARCH@@/$(PKGARCH)/g $(PKGDIR)/DEBIAN/control sed -i s/@@NAME@@/$(PKGNAME)/g $(PKGDIR)/DEBIAN/control sed -i s/@@VERSION@@/$(PKGVERSION)/g $(PKGDIR)/DEBIAN/control install -cm 0755 postinst.client $(PKGDIR)/DEBIAN/postinst install -cm 0755 $(RASPBERRYPI_LPC1114_SRC)/scripts/update_services $(PKGDIR)/DEBIAN mkdir -p $(PKGDIR)/usr/local/bin mkdir -p $(PKGDIR)/usr/local/lib mkdir -p $(PKGDIR)$(PYTHONDST) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib libspiagent.so RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) OSNAME=$(OSNAME) TRANSPORTS=http,oncrpc,xmlrpc $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib/clients/c RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) HOST_LDFLAGS="-L$(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib -lspiagent" install -csm 0755 $(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib/clients/c/spi_agent_test $(PKGDIR)/usr/local/bin install -cm 0755 $(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib/libspiagent.so $(PKGDIR)/usr/local/lib install -cm 0644 $(RASPBERRYPI_LPC1114_SRC)/python/spiagent*.py $(PKGDIR)$(PYTHONDST) else $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent firmware ARMSRC=$(ARMSRC) RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib libspiagent.so RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) OSNAME=$(OSNAME) TRANSPORTS=http,ioctl,oncrpc,xmlrpc $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib/clients/c RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) HOST_LDFLAGS="-L$(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib -lspiagent" $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-http RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-linx RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-oncrpc RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-remoteio RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) LDFLAGS="-L$(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib" $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-xmlrpc RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-zeromq RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/utils/isp $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/utils/reset mkdir -p $(PKGDIR)/DEBIAN install -cm 0644 control $(PKGDIR)/DEBIAN install -cm 0755 postinst $(PKGDIR)/DEBIAN install -cm 0755 prerm $(PKGDIR)/DEBIAN install -cm 0755 $(RASPBERRYPI_LPC1114_SRC)/scripts/update_services $(PKGDIR)/DEBIAN sed -i s/@@ARCH@@/$(PKGARCH)/g $(PKGDIR)/DEBIAN/control sed -i s/@@NAME@@/$(PKGNAME)/g $(PKGDIR)/DEBIAN/control sed -i s/@@VERSION@@/$(PKGVERSION)/g $(PKGDIR)/DEBIAN/control mkdir -p $(PKGDIR)/usr/local/bin mkdir -p $(PKGDIR)/usr/local/etc mkdir -p $(PKGDIR)/usr/local/lib/firmware mkdir -p $(PKGDIR)$(PYTHONDST) mkdir -p $(PKGDIR)/usr/local/libexec install -csm 0755 $(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib/clients/c/spi_agent_test $(PKGDIR)/usr/local/bin install -cm 0644 $(RASPBERRYPI_LPC1114_SRC)/scripts/expansion_lpc1114.config $(PKGDIR)/usr/local/etc install -cm 0755 $(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib/libspiagent.so $(PKGDIR)/usr/local/lib install -cm 0644 $(RASPBERRYPI_LPC1114_SRC)/spi-agent/LPC1114-spi-agent.hex $(PKGDIR)/usr/local/lib/firmware install -cm 0644 $(RASPBERRYPI_LPC1114_SRC)/python/spiagent*.py $(PKGDIR)$(PYTHONDST) install -cm 0755 $(RASPBERRYPI_LPC1114_SRC)/scripts/expansion_lpc1114_flash $(PKGDIR)/usr/local/libexec install -cm 0755 $(RASPBERRYPI_LPC1114_SRC)/scripts/expansion_lpc1114_startup $(PKGDIR)/usr/local/libexec install -cm 0755 $(RASPBERRYPI_LPC1114_SRC)/scripts/expansion_lpc1114.service $(PKGDIR)/usr/local/libexec install -csm 0755 $(RASPBERRYPI_LPC1114_SRC)/spi-agent-http/spi_agent_http_server $(PKGDIR)/usr/local/libexec install -csm 0755 $(RASPBERRYPI_LPC1114_SRC)/spi-agent-linx/spi_agent_linx_server $(PKGDIR)/usr/local/libexec install -csm 0755 $(RASPBERRYPI_LPC1114_SRC)/spi-agent-oncrpc/spi_agent_oncrpc_server $(PKGDIR)/usr/local/libexec install -csm 0755 $(RASPBERRYPI_LPC1114_SRC)/spi-agent-remoteio/spi_agent_remoteio_server $(PKGDIR)/usr/local/libexec install -csm 0755 $(RASPBERRYPI_LPC1114_SRC)/spi-agent-xmlrpc/spi_agent_xmlrpc_server $(PKGDIR)/usr/local/libexec install -csm 0755 $(RASPBERRYPI_LPC1114_SRC)/spi-agent-zeromq/spi_agent_zeromq_server $(PKGDIR)/usr/local/libexec install -csm 0755 $(RASPBERRYPI_LPC1114_SRC)/utils/isp/expansion_lpc1114_isp $(PKGDIR)/usr/local/libexec install -csm 0755 $(RASPBERRYPI_LPC1114_SRC)/utils/reset/expansion_lpc1114_reset $(PKGDIR)/usr/local/libexec endif touch $@ # Build Debian package file $(PKGFILE): $(PKGDIR) chmod -R ugo-w $(PKGDIR)/DEBIAN/* $(PKGDIR)/usr fakeroot dpkg-deb --build $(PKGDIR) chmod -R u+w $(PKGDIR) package.deb: $(PKGFILE) # Remove working files clean: -rm -rf $(PKGDIR) $(PKGFILE) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent clean RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib clean RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) TRANSPORTS=http,ioctl,oncrpc,xmlrpc $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-lib/clients/c clean RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-http clean RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-linx clean RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-oncrpc clean RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-remoteio clean RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-xmlrpc clean RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/spi-agent-zeromq clean RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/utils/isp distclean RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) $(MAKE) -C $(RASPBERRYPI_LPC1114_SRC)/utils/reset distclean RASPBERRYPI_LPC1114_SRC=$(RASPBERRYPI_LPC1114_SRC) reallyclean: clean distclean: reallyclean