summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-04-08 17:41:52 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-04-08 17:41:52 -0400
commit6b5037e8c094c99bb5d6b07edb830a93bdddd110 (patch)
tree72ead50879da1bddad69fd20e91f82670f56be44
parent0b68f18e4416d04926ed1c6d9e55ddc6f59a8522 (diff)
tidy the Makefile
-rw-r--r--Makefile37
1 files changed, 24 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 5b2f684..b17dec3 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# The source is C99 written for GNU
+# The source is C99 written for GNU libc
CFLAGS += -std=c99
CPPFLAGS += -std=c99
CPPFLAGS += -D_GNU_SOURCE
@@ -33,6 +33,7 @@ CFLAGS += -fstack-protector
CFLAGS += -O2
CPPFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
+# The main Makefile segment
all: build
.PHONY: all
@@ -44,6 +45,14 @@ units = freenect-server-http.service freenect-server-http.socket freenect-server
build: $(addprefix src/,$(progs)) $(addprefix systemd/,$(units))
.PHONY: build
+install: $(addprefix $(DESTDIR)$(bindir)/,$(progs)) $(addprefix $(DESTDIR)$(systemddir)/,$(units))
+.PHONY: install
+
+# Automatically figure out C header dependencies
+CPPFLAGS += -MD -MF $(@D)/$(@F:%.o=.%.mk) -MP
+-include src/.*.mk
+
+# Dependencies that don't get figured out automatically
src/freenect-server: src/util.o -lfreenect -lusb-1.0 -ljpeg
src/multipart-replace-http-server: src/util.o src/wg.o src/multipart-replace.o -lpthread
systemd/freenect-server-http.service: .var.user .var.group .var.bindir
@@ -51,29 +60,31 @@ systemd/freenect-server-http.socket: .var.httpstream
systemd/freenect-server.service: .var.user .var.group .var.bindir
systemd/freenect-server@.socket: .var.user .var.group
+# Rules to make things
+COPYING.GPL3:
+ wget http://www.gnu.org/licenses/gpl-3.0.txt -O $@
+
systemd/%: systemd/%.in
sed $(foreach v,$(patsubst .var.%,%,$(filter .var.%,$^)), -e 's|@$v@|$($v)|' ) < $< > $@
-
-.var.%: FORCE
- @printf '%s' '$($*)' | ./write-ifchanged $@
-
-install: $(addprefix $(DESTDIR)$(bindir)/,$(progs)) $(addprefix $(DESTDIR)$(systemddir)/,$(units))
-
$(DESTDIR)$(bindir)/%: src/%
install -Dm755 $< $@
-
$(DESTDIR)$(systemddir)/%: systemd/%
install -Dm644 $< $@
+.var.%: FORCE
+ @printf '%s' '$($*)' | ./write-ifchanged $@
+# Undo
clean:
rm -f -- src/*.o src/.*.mk
- rm -f -- src/freenect-server src/multipart-replace-http-server
- rm -f -- systemd/*.socket systemd/*.service
+ rm -f -- $(addprefix src/,$(progs)) $(addprefix systemd/,$(units))
.PHONY: clean
+uninstall:
+ rm -f -- $(addprefix $(DESTDIR)$(bindir)/,$(progs)) $(addprefix $(DESTDIR)$(systemddir)/,$(units))
+ rmdir -p -- $(dir $(addprefix $(DESTDIR)$(bindir)/,$(progs)) $(addprefix $(DESTDIR)$(systemddir)/,$(units))) 2>/dev/null || true
+.PHONY: uninstall
+
+# Noise that I put in every Makefile
.PHONY: FORCE
.DELETE_ON_ERROR:
.SECONDARY:
-
-CPPFLAGS += -MD -MF $(@D)/$(@F:%.o=.%.mk) -MP
--include src/.*.mk