Skip to content

Commit

Permalink
A DSF Makefile
Browse files Browse the repository at this point in the history
It was a rainy weekend. :)

Running 'make help' will get you all the details.

* It does everything the script based build does.
* It's easier to use.
* It's easier to customize and set defaults.
* It does NOT disturb the current script based deb build.
  • Loading branch information
gtjoseph committed May 25, 2020
1 parent 1ceccc3 commit a735b96
Show file tree
Hide file tree
Showing 20 changed files with 548 additions and 71 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,5 @@ src/Documentation/log.txt
src/Documentation/api
!src/Documentation/api/index.md
!src/Documentation/api/toc.yml
src/Documentation/obj
src/Documentation/obj
Makefile.local
416 changes: 416 additions & 0 deletions Makefile

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions Makefile.components
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@


# Passing V=1 on the make command line turns on verbose mode
ifeq ($(V),1)
ECHO_PREFIX=@
CMD_PREFIX=
DOTNET_VERB=minimal
DOTNET_RETRY=
else
ECHO_PREFIX=@
CMD_PREFIX=@>/dev/null
DOTNET_VERB=quiet
# In quiet mode, if a dotnet command fails, it'll be re-run in verbose mode
# so you can see the errors.
DOTNET_RETRY= || { echo " dotnet $(DOTNET_ARGS)" ; dotnet $(DOTNET_ARGS) ; }
endif

.PHONY: $(TARGET) build publish clean info

ARCH = armhf
CONFIG = Debug

TARGET_TITLE = printf " [%-9s] %-21s %-7s %-7s %-7s\n"

-include ../../Makefile.local

TARGET ?= $(shell basename `pwd`)
RUNTIME := $(shell dotnet --version | sed -n -r -e "s/^([0-9]+[.][0-9]+).*/\1/gp")
# The ARCH passed in is the package architecure so we translate it to
# a dotnet runtime.
DOTNET_ARCH = $(shell ../../pkg/common/get_dotnet_arch $(ARCH))
SOURCES := $(shell find -name "*.cs")
BIN = bin/$(CONFIG)/netcoreapp$(RUNTIME)/$(DOTNET_ARCH)/$(TARGET)
DESTDIR = bin/$(CONFIG)/netcoreapp$(RUNTIME)/$(DOTNET_ARCH)/publish/

build: $(BIN)

$(BIN): DOTNET_ARGS = build --nologo -r $(DOTNET_ARCH) -c $(CONFIG) -o bin/$(CONFIG)/netcoreapp$(RUNTIME)/$(DOTNET_ARCH)/
$(BIN): *.csproj $(SOURCES)
$(ECHO_PREFIX)$(TARGET_TITLE) build $(TARGET) "" $(CONFIG) $(DOTNET_ARCH)
$(CMD_PREFIX) dotnet $(DOTNET_ARGS) -v $(DOTNET_VERB) $(DOTNET_RETRY)


$(DESTDIR)/$(TARGET): DOTNET_ARGS = publish --nologo -r $(DOTNET_ARCH) -c $(CONFIG) -o $(DESTDIR)
$(DESTDIR)/$(TARGET): $(BIN)
$(ECHO_PREFIX)$(TARGET_TITLE) publish $(TARGET) "" $(CONFIG) $(DOTNET_ARCH)
$(CMD_PREFIX) dotnet $(DOTNET_ARGS) -v $(DOTNET_VERB) $(DOTNET_RETRY)

publish: $(DESTDIR)/$(TARGET)

clean:
$(ECHO_PREFIX)$(TARGET_TITLE) CLEAN $(TARGET) "" ""
$(CMD_PREFIX) rm -rf bin obj

info:
@echo "ARCH: $(ARCH)"
@echo "TARGET: $(TARGET)"
@echo "RUNTIME: $(RUNTIME)"
@echo "CONFIG: $(CONFIG)"
@echo "BIN: $(BIN)"
@echo "DESTDIR: $(DESTDIR)"
19 changes: 19 additions & 0 deletions pkg/common/get_dotnet_arch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

if [ -z "$1" ] ; then
echo "Usage: $0 <package_architecture>"
echo " Returns the equivalent dotnet runtime architecture"
exit 1
fi

DOTNET_ARCH=

case $1 in
armhf|armhfp|armv7h|armv7hl) DOTNET_ARCH=linux-arm ;;
arm64|aarch64) DOTNET_ARCH=linux-arm64 ;;
amd64|x86_64) DOTNET_ARCH=linux-x64 ;;
i386|i686|x86_32) DOTNET_ARCH=linux-x86 ;;
*) echo "Unknown package architecture: $1" ; exit 1 ;;
esac

echo $DOTNET_ARCH
14 changes: 3 additions & 11 deletions pkg/rpm/duetcontrolserver.spec
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,21 @@

Name: duetcontrolserver
Version: %{_tversion}
Release: 901
Release: %{_release}
Summary: DSF Control Server
Group: 3D Printing
Source0: duetcontrolserver_%{_tversion}
License: GPLv3
URL: https://github.com/chrishamm/DuetSoftwareFramework
URL: https://github.com/Duet3D/DuetSoftwareFramework
BuildRequires: rpm >= 4.7.2-2
Requires: duetruntime
Requires: duetruntime = %{_tversion}
%systemd_requires

AutoReq: 0

%description
DSF Control Server

%prep
%setup -q -T -c -n %{name}-%{version}

%build

%install
rsync -vaH %{S:0}/. %{buildroot}/

%pre
if [ $1 -gt 1 ] && systemctl -q is-active %{name}.service ; then
# upgrade
Expand Down
12 changes: 3 additions & 9 deletions pkg/rpm/duetruntime.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Name: duetruntime
Version: %{_tversion}
Release: 901
Release: %{_release}
Summary: DSF Common Runtime Components
Group: 3D Printing
Source0: duetruntime_%{_tversion}
Expand All @@ -20,17 +20,11 @@ BuildRequires: rpm >= 4.7.2-2

AutoReq: 0

%global __os_install_post %{nil}

%description
DSF Common Runtime Components

%prep
%setup -q -T -c -n %{name}-%{version}

%build

%install
rsync -vaH %{S:0}/. %{buildroot}/

%files
%defattr(0644,root,root,-)
%{dsfoptdir}/bin/*
Expand Down
11 changes: 1 addition & 10 deletions pkg/rpm/duetsd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Name: duetsd
Version: %{_tversion}
Release: 901
Release: %{_release}
Summary: DSF SD Card
Group: 3D Printing
Source0: duetsd_%{_tversion}
Expand All @@ -23,19 +23,10 @@ AutoReq: 0
%description
DSF SD Card

%prep
%setup -q -T -c -n %{name}-%{version}

%build

%install
rsync -vaH %{S:0}/. %{buildroot}/

%files
%defattr(0664,root,root,0775)
%dir %{dsfoptdir}/sd/sys
%config(noreplace) %{dsfoptdir}/sd/sys/config.g
%{dsfoptdir}/sd/sys/*.bin
%dir %{dsfoptdir}/sd/filaments
%dir %{dsfoptdir}/sd/gcodes
%dir %{dsfoptdir}/sd/macros
9 changes: 1 addition & 8 deletions pkg/rpm/duetsoftwareframework.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Name: duetsoftwareframework
Version: %{_tversion}
Release: 901
Release: %{_release}
Summary: Duet Software Framework
Group: 3D Printing
License: GPLv3
Expand All @@ -28,11 +28,4 @@ Requires: duetwebcontrol
%description
Duet Software Framework

%prep
%setup -q -T -c -n %{name}-%{version}

%build

%install

%files
12 changes: 2 additions & 10 deletions pkg/rpm/duettools.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,20 @@

Name: duettools
Version: %{_tversion}
Release: 901
Release: %{_release}
Summary: DSF Tools
Group: 3D Printing
Source0: duettools_%{_tversion}
License: GPLv3
URL: https://github.com/chrishamm/DuetSoftwareFramework
BuildRequires: rpm >= 4.7.2-2
Requires: duetruntime
Requires: duetcontrolserver = %{_tversion}

AutoReq: 0

%description
DSF Tools

%prep
%setup -q -T -c -n %{name}-%{version}

%build

%install
rsync -vaH %{S:0}/. %{buildroot}/

%files
%defattr(0664,root,root,-)
%attr(0755, root, root) %{dsfoptdir}/bin/CodeLogger
Expand Down
13 changes: 2 additions & 11 deletions pkg/rpm/duetwebcontrol.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,19 @@

Name: duetwebcontrol
Version: %{_tversion}
Release: %{_release}.900
Release: %{_release}
Summary: Official web interface for Duet electronics
Group: 3D Printing
Source0: duetwebcontrol_%{_tversion}-%{_release}
Source0: duetwebcontrol_%{_tversion}
License: GPLv3
URL: https://github.com/chrishamm/DuetWebControl
BuildRequires: rpm >= 4.7.2-2
Requires: duetruntime

AutoReq: 0

%description
Official web interface for Duet electronics

%prep
%setup -q -T -c -n %{name}-%{version}

%build

%install
rsync -vaH %{S:0}/. %{buildroot}/

%files
%defattr(-,root,root,-)
%{dsfoptdir}/dwc2
Expand Down
13 changes: 2 additions & 11 deletions pkg/rpm/duetwebserver.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,21 @@

Name: duetwebserver
Version: %{_tversion}
Release: 901
Release: %{_release}
Summary: DSF Web Server
Group: 3D Printing
Source0: duetwebserver_%{_tversion}
License: GPLv3
URL: https://github.com/chrishamm/DuetSoftwareFramework
BuildRequires: rpm >= 4.7.2-2
Requires: duetcontrolserver
Requires: duetruntime
Requires: duetcontrolserver >= %{_tversion}
%systemd_requires

AutoReq: 0

%description
DSF Web Server

%prep
%setup -q -T -c -n %{name}-%{version}

%build

%install
rsync -vaH %{S:0}/. %{buildroot}/

%pre
if [ $1 -gt 1 ] && systemctl -q is-active %{name}.service ; then
# upgrade
Expand Down
4 changes: 4 additions & 0 deletions src/CodeConsole/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

TARGET=CodeConsole

include ../../Makefile.components
4 changes: 4 additions & 0 deletions src/CodeLogger/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

TARGET=CodeLogger

include ../../Makefile.components
4 changes: 4 additions & 0 deletions src/CustomHttpEndpoint/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

TARGET=CustomHttpEndpoint

include ../../Makefile.components
4 changes: 4 additions & 0 deletions src/DuetAPI/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

TARGET=DuetAPI.dll

include ../../Makefile.components
4 changes: 4 additions & 0 deletions src/DuetAPIClient/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

TARGET=DuetAPIClient.dll

include ../../Makefile.components
4 changes: 4 additions & 0 deletions src/DuetControlServer/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

TARGET=DuetControlServer

include ../../Makefile.components
4 changes: 4 additions & 0 deletions src/DuetWebServer/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

TARGET=DuetWebServer

include ../../Makefile.components
4 changes: 4 additions & 0 deletions src/LinuxDevices/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

TARGET=LinuxDevices.dll

include ../../Makefile.components
4 changes: 4 additions & 0 deletions src/ModelObserver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

TARGET=ModelObserver

include ../../Makefile.components

0 comments on commit a735b96

Please sign in to comment.