build: Build locally and install in the usual way.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 16 Feb 2022 10:06:48 +0000 (10:06 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 16 Feb 2022 10:06:48 +0000 (10:06 +0000)
Accessing these programs over NFS is more annoying than useful, so do
things the old-fashioned way instead.

.gitignore
Makefile
dvdrip

index ee38724..3314751 100644 (file)
@@ -1 +1,4 @@
-obj.*/
+*.dep
+*.o
+
+/dvd-sector-copy
index 784770d..e412278 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,16 +2,21 @@
 
 all:
 clean::
+.PHONY: all clean
+
+CLEANFILES             += $(TARGETS)
 
 .SECONDEXPANSION: # sorry
 
-bindir                  = ../bin
+prefix                  = $(HOME)
+exec_prefix             = $(prefix)
+bindir                  = $(exec_prefix)/bin
 
 V                       = 0
 V_AT                    = $(V_AT_$V)
 V_AT_0                  = @
 v-tag                   = $(call v-tag_$V,$1)
-v-tag_0                         = @printf "  %-12s %s\n" "$1" "$@";
+v-tag_0                         = @printf "  %-8s %s\n" "$1" "$@";
 
 CC                      = gcc
 CFLAGS                  = -O2 -g -pedantic -Wall -Werror
@@ -19,12 +24,6 @@ CFLAGS                        = -O2 -g -pedantic -Wall -Werror
 LD                      = gcc
 LDFLAGS                         =
 
-ARCH                   += i686
-CFLAGS_i386             = -m32
-
-ARCH                   += x86_64
-CFLAGS_amd64            = -m64
-
 PROGS                  += dvd-sector-copy
 dvd-sector-copy_SRCS    = dvd-sector-copy.c
 dvd-sector-copy_LIBS    = -ldvdread -lm
@@ -32,40 +31,27 @@ dvd-sector-copy_LIBS         = -ldvdread -lm
 SCRIPTS                        += dvdrip
 SCRIPTS                        += dvdrip-upload
 
-define setup-arch
-obj.$1/%.o: %.c
-       $$(V_AT)mkdir -p $$(dir $$@)
-       $$(call v-tag,CC [$1])$$(CC) -c $$(CFLAGS) $$(CFLAGS_$1) -o$$@ -MD -MF obj.$1/$$*.dep $$<
-clean::; rm -rf obj.$1
-endef
-$(foreach a,$(ARCH), $(eval $(call setup-arch,$a)))
+%.o: %.c
+       $(call v-tag,CC)$(CC) -c $(CFLAGS) -o$@ -MD -MF $*.dep $<
+CLEANFILES             += *.o *.dep
 
 objects                         = $(addsuffix $(or $2,.o),$(basename $(filter %.c %.s %.S,$1)))
 
-ALL_PROGS              += $(foreach a,$(ARCH), \
-                               $(foreach p,$(PROGS), $(bindir)/$p.$a))
-TARGETS                        += $(ALL_PROGS)
-program-name            = $(basename $1)
-program-arch            = $(patsubst .%,%,$(suffix $1))
-program-sources                 = $($(call program-name,$1)_SRCS) \
-                               $($(call program-name,$1)_SRCS_$(call program-arch,$1))
-program-objects                 = $(addprefix obj.$(call program-arch,$1)/, \
-                               $(call objects,$(call program-sources,$1),$2))
-$(ALL_PROGS): $(bindir)/%: $$(call program-objects,$$*) $$($$(call program-name,$$*)_DEPS)
-       $(call v-tag,LD [$(call program-arch,$*)])$(LD) \
-               $(LDFLAGS) $(LDFLAGS_$(call program-arch,$*)) -o$@ \
-               $(call program-objects,$*) \
-               $($(call program-name,$*)_LIBS) \
-               $($(call program-name,$*)_LIBS_$(call program-arch,$*))
-
-ALL_SCRIPTS             = $(addprefix $(bindir)/, $(SCRIPTS))
-TARGETS                        += $(ALL_SCRIPTS)
-$(ALL_SCRIPTS): $(bindir)/%: %
-       $(call v-tag,SCRIPT)install $* $@
+TARGETS                        += $(PROGS)
+program-objects                 = $(call objects,$($1_SRCS),$2)
+$(PROGS): %: $$(call program-objects,$$*) $$($$*_DEPS)
+       $(call v-tag,LD)$(LD) $(LDFLAGS) -o$@ \
+               $(call program-objects,$*) $($*_LIBS)
+
+INSTALL_bin             = $(addprefix inst/,$(PROGS) $(SCRIPTS))
+install: $(INSTALL_bin)
+$(INSTALL_bin): inst/%: %
+       $(V_AT)mkdir -p $(bindir)
+       $(call v-tag,INST)install -m755 $* $(bindir)/
 
 p:; : $p
 
 all: $(TARGETS)
-clean::; rm -f $(TARGETS)
+clean::; rm -f $(CLEANFILES)
 
--include $(foreach p,$(notdir $(ALL_PROGS)), $(call program-objects,$p,.dep))
+-include $(foreach p,$(PROGS), $(call program-objects,$p,.dep))
diff --git a/dvdrip b/dvdrip
index b09abe8..ac37076 100755 (executable)
--- a/dvdrip
+++ b/dvdrip
@@ -4,9 +4,8 @@ prog=${0##*/}
 dev=${DVDRIP_DEVICE-/dev/dvd}
 tmp=${DVDRIP_TMPDIR-${HOME?}/tmp/dvdrip}
 archive=${DVDRIP_ARCHIVE-jem.distorted.org.uk:/mnt/dvd/archive}
-here=$(realpath "$0"); here=${here%/*}
-: ${DVD_SECTOR_COPY=$here/dvd-sector-copy.$(uname -m)}
-: ${DVDRIP_UPLOAD=$here/dvdrip-upload}
+: ${DVD_SECTOR_COPY=dvd-sector-copy}
+: ${DVDRIP_UPLOAD=dvdrip-upload}
 backup=nil eject=nil force=nil verbose=nil bogus=nil; unset dir sub n label
 usage () {
   cat <<EOF