[PATCH 1/3] Clean up: Makefile.in: Handle program targets correctly

Michael Witten mfwitten at gmail.com
Wed Jul 12 04:15:55 AWST 2017


Due to the fact that platforms disagree about which file-name
extension an executable should have, subtle problems have accrued;
notably, it became the case that build targets were no longer
explicitly being treated as actual, real files, but sometimes as
implicitly phony targets (that is, a target which should have been
referring to a file actually wasn't, because it was expressed
without the executable extension).

This commit fixes these problems by establishing that the final
targets must indeed by the names of real files, and then keeping
track of the extensionless file names for other, meta uses.

Along the way, a few minor adjustments have also been made.
---
 Makefile.in | 58 +++++++++++++++++++++++++---------------------------------
 1 file changed, 25 insertions(+), 33 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 5c4e106..b7a4183 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -54,8 +54,6 @@ KEYOBJS=dropbearkey.o
 
 CONVERTOBJS=dropbearconvert.o keyimport.o
 
-SCPOBJS=scp.o progressmeter.o atomicio.o scpmisc.o compat.o
-
 HEADERS=options.h dbutil.h session.h packet.h algo.h ssh.h buffer.h kex.h \
 		dss.h bignum.h signkey.h rsa.h dbrandom.h service.h auth.h \
 		debug.h channel.h chansession.h config.h queue.h sshpty.h \
@@ -67,7 +65,7 @@ dropbearobjs=$(COMMONOBJS) $(CLISVROBJS) $(SVROBJS)
 dbclientobjs=$(COMMONOBJS) $(CLISVROBJS) $(CLIOBJS)
 dropbearkeyobjs=$(COMMONOBJS) $(KEYOBJS)
 dropbearconvertobjs=$(COMMONOBJS) $(CONVERTOBJS)
-scpobjs=$(SCPOBJS)
+scpobjs=scp.o progressmeter.o atomicio.o scpmisc.o compat.o
 
 VPATH=@srcdir@
 srcdir=@srcdir@
@@ -116,11 +114,15 @@ ifeq ($(STATIC), 1)
 endif
 
 ifeq ($(MULTI), 1)
-	TARGETS=dropbearmulti$(EXEEXT)
+	dropbearmultiobjs=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs)))
+	CFLAGS+=$(addprefix -DDBMULTI_, $(PROGRAMS)) -DDROPBEAR_MULTI
+	TARGETS_NAMES=dropbearmulti
 else
-	TARGETS=$(PROGRAMS)
+	TARGETS_NAMES=$(PROGRAMS)
 endif
 
+TARGETS=$(addsuffix $(EXEEXT), $(TARGETS_NAMES))
+
 # for the scp progress meter. The -D doesn't affect anything else.
 ifeq ($(SCPPROGRESS), 1)
 	CFLAGS+=-DPROGRESS_METER
@@ -129,9 +131,11 @@ endif
 all: $(TARGETS)
 
 strip: $(TARGETS)
-	$(STRIP) $(addsuffix $(EXEEXT), $(TARGETS))
+	$(STRIP) $^
+
+TARGETS_inst_=$(addprefix inst_, $(TARGETS_NAMES))
 
-install: $(addprefix inst_, $(TARGETS))
+install: $(TARGETS_inst_)
 
 insmultidropbear: dropbearmulti$(EXEEXT)
 	$(INSTALL) -d $(DESTDIR)$(sbindir)
@@ -148,13 +152,13 @@ insmulti%: dropbearmulti$(EXEEXT)
 	if test -e $*.1; then $(INSTALL) -m 644 $*.1 $(DESTDIR)$(mandir)/man1/$*.1; fi
 
 # dropbear should go in sbin, so it needs a separate rule
-inst_dropbear: dropbear
+inst_dropbear: dropbear$(EXEEXT)
 	$(INSTALL) -d $(DESTDIR)$(sbindir)
 	$(INSTALL) dropbear$(EXEEXT) $(DESTDIR)$(sbindir)
 	$(INSTALL) -d $(DESTDIR)$(mandir)/man8
 	$(INSTALL) -m 644 $(srcdir)/dropbear.8 $(DESTDIR)$(mandir)/man8/dropbear.8
 
-inst_%: %
+inst_%: %$(EXEEXT)
 	$(INSTALL) -d $(DESTDIR)$(bindir)
 	$(INSTALL) $*$(EXEEXT) $(DESTDIR)$(bindir)
 	$(INSTALL) -d $(DESTDIR)$(mandir)/man1
@@ -162,35 +166,23 @@ inst_%: %
 
 inst_dropbearmulti: $(addprefix insmulti, $(PROGRAMS)) 
 
-# for some reason the rule further down doesn't like $($@objs) as a prereq.
-dropbear: $(dropbearobjs)
-dbclient: $(dbclientobjs)
-dropbearkey: $(dropbearkeyobjs)
-dropbearconvert: $(dropbearconvertobjs)
+dropbear$(EXEEXT): $(HEADERS) $(dropbearobjs) $(LIBTOM_DEPS)
+	$(CC) $(LDFLAGS) -o $@ $(dropbearobjs) $(LIBTOM_LIBS) $(LIBS) @CRYPTLIB@
 
-dropbear: $(HEADERS) $(LIBTOM_DEPS) Makefile
-	$(CC) $(LDFLAGS) -o $@$(EXEEXT) $($@objs) $(LIBTOM_LIBS) $(LIBS) @CRYPTLIB@
+dbclient$(EXEEXT): $(HEADERS) $(dbclientobjs) $(LIBTOM_DEPS)
+	$(CC) $(LDFLAGS) -o $@ $(dbclientobjs) $(LIBTOM_LIBS) $(LIBS)
 
-dbclient: $(HEADERS) $(LIBTOM_DEPS) Makefile
-	$(CC) $(LDFLAGS) -o $@$(EXEEXT) $($@objs) $(LIBTOM_LIBS) $(LIBS)
+dropbearkey$(EXEEXT): $(HEADERS) $(dropbearkeyobjs) $(LIBTOM_DEPS)
+	$(CC) $(LDFLAGS) -o $@ $(dropbearkeyobjs) $(LIBTOM_LIBS) $(LIBS)
 
-dropbearkey dropbearconvert: $(HEADERS) $(LIBTOM_DEPS) Makefile
-	$(CC) $(LDFLAGS) -o $@$(EXEEXT) $($@objs) $(LIBTOM_LIBS)
+dropbearconvert$(EXEEXT): $(HEADERS) $(dropbearconvertobjs) $(LIBTOM_DEPS)
+	$(CC) $(LDFLAGS) -o $@ $(dropbearconvertobjs) $(LIBTOM_LIBS)
 
-# scp doesn't use the libs so is special.
-scp: $(SCPOBJS)  $(HEADERS) Makefile
-	$(CC) $(LDFLAGS) -o $@$(EXEEXT) $(SCPOBJS)
+scp$(EXEEXT): $(HEADERS) $(scpobjs)
+	$(CC) $(LDFLAGS) -o $@ $(scpobjs)
-
-
-# multi-binary compilation.
-MULTIOBJS=
-ifeq ($(MULTI),1)
-	MULTIOBJS=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs)))
-	CFLAGS+=$(addprefix -DDBMULTI_, $(PROGRAMS)) -DDROPBEAR_MULTI
-endif
 
-dropbearmulti$(EXEEXT): $(HEADERS) $(MULTIOBJS) $(LIBTOM_DEPS) Makefile
-	$(CC) $(LDFLAGS) -o $@ $(MULTIOBJS) $(LIBTOM_LIBS) $(LIBS) @CRYPTLIB@
+dropbearmulti$(EXEEXT): $(HEADERS) $(dropbearmultiobjs) $(LIBTOM_DEPS)
+	$(CC) $(LDFLAGS) -o $@ $(dropbearmultiobjs) $(LIBTOM_LIBS) $(LIBS) @CRYPTLIB@
 
 multibinary: dropbearmulti$(EXEEXT)
 
-- 
2.10.0



More information about the Dropbear mailing list