Commit 8b6ddcb0 authored by Matt Johnston's avatar Matt Johnston
Browse files

Switching to the magical new Makefile, and new dbmulti style

--HG--
extra : convert_revision : 3f8efcdd56aab197d30a1ea81527c37dfee2f928
parent 58baa046
......@@ -10,18 +10,17 @@
# This makefile is quite evil.
ifndef PROGRAMS
PROGRAMS="dropbear dbclient dropbearkey dropbearmulti"
PROGRAMS=dropbear dbclient dropbearkey dropbearmulti
endif
LTC=libtomcrypt/libtomcrypt.a
LTM=libtommath/libtommath.a
COMMONOBJS=dbutil.o common-session.o packet.o common-algo.o buffer.o \
common-kex.o dss.o bignum.o \
signkey.o rsa.o random.o common-channel.o \
common-chansession.o queue.o termcodes.o \
loginrec.o atomicio.o tcpfwd-direct.o compat.o \
tcpfwd-remote.o listener.o process-packet.o common-runopts.o
COMMONOBJS=dbutil.o buffer.o \
dss.o bignum.o \
signkey.o rsa.o random.o \
queue.o \
atomicio.o compat.o
SVROBJS=svr-kex.o svr-algo.o svr-auth.o sshpty.o \
svr-authpasswd.o svr-authpubkey.o svr-session.o svr-service.o \
......@@ -30,9 +29,12 @@ SVROBJS=svr-kex.o svr-algo.o svr-auth.o sshpty.o \
CLIOBJS=cli-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
cli-session.o cli-service.o
DROPBEAROBJS=
CLISVROBJS=common-session.o packet.o common-algo.o common-kex.o \
common-channel.o common-chansession.o termcodes.o loginrec.o \
tcpfwd-direct.o tcpfwd-remote.o listener.o process-packet.o \
common-runopts.o
DROPBEARKEYOBJS=dropbearkey.o gendss.o genrsa.o
KEYOBJS=dropbearkey.o gendss.o genrsa.o
CONVERTOBJS=dropbearconvert.o keyimport.o
......@@ -45,8 +47,8 @@ HEADERS=options.h dbutil.h session.h packet.h algo.h ssh.h buffer.h kex.h \
loginrec.h atomicio.h x11fwd.h agentfwd.h tcpfwd-direct.h compat.h \
tcpfwd-remote.h listener.h
dropbearobjs=$(COMMONOBJS) $(SVROBJS)
dbclientobjs=$(COMMONOBJS) $(CLIOBJS)
dropbearobjs=$(COMMONOBJS) $(CLISVROBJS) $(SVROBJS)
dbclientobjs=$(COMMONOBJS) $(CLISVROBJS) $(CLIOBJS)
dropbearkeyobjs=$(COMMONOBJS) $(KEYOBJS)
dropbearconvertobjs=$(COMMONOBJS) $(CONVERTOBJS)
scpobjs=$(SCPOBJS)
......@@ -57,7 +59,7 @@ bindir=${exec_prefix}/bin
sbindir=${exec_prefix}/sbin
CC=@[email protected]
LD=@CC@
LD=@LD@
AR=@[email protected]
RANLIB=@[email protected]
STRIP=@[email protected]
......@@ -69,17 +71,15 @@ [email protected]@
EXEEXT=@[email protected]
# whether we're building client, server, or both for the common objects.
space:= $(empty) $(empty)
CLISVRFLAGS=
# evilness so we detect 'dropbear' by itself as a word
ifneq (,$(findstring $(space)dropbear$(space), $(space)$(PROGRAMS)$(space)))
CLISVRFLAGS+= -DDROPBEAR_SERVER
space:= $(empty) $(empty)
ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdropbearZ, Z$(prog)Z))))
CFLAGS+= -DDROPBEAR_SERVER
endif
ifneq (,$(findstring $(space)dbclient$(space), $(space)$(PROGRAMS)$(space)))
CLISVRFLAGS+= -DDROPBEAR_CLIENT
ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdbclientZ, Z$(prog)Z))))
CFLAGS+= -DDROPBEAR_CLIENT
endif
CFLAGS+=$(CLISVRFLAGS)
# these are exported so that libtomcrypt's makefile will use them
export CC
......@@ -108,12 +108,15 @@ endif
#%: $(HEADERS) Makefile
# TODO
all: $(TARGETS)
strip: $(TARGETS)
$(STRIP) $(foreach prog, $(TARGETS), $(SPREFIX)$(prog)$(EXEEXT))
test:
@echo Z$(sort $(foreach prog, $(PROGRAMS), $($(prog)objs)))Z
strip: $(TARGETS)
$(STRIP) $(addsuffix $(EXEEXT), $(addprefix $(SPREFIX), $(TARGETS)))
install: $(foreach prog, $(TARGETS), install$prog)
install: $(addprefix install, $(TARGETS))
# dropbear should go in sbin, so it needs a seperate rule
installdropbear: dropbear
......@@ -128,33 +131,39 @@ install%: $*
-chown root $(DESTDIR)$(sbindir)/$(SPREFIX)$*$(EXEEXT)
-chgrp 0 $(DESTDIR)$(sbindir)/$(SPREFIX)$*$(EXEEXT)
ifeq ($(MULTI), 1)
@echo
@echo "You must manually create links for $*"
endif
# The actual binaries
# for some reason the rule further down doesn't like $([email protected]) as a prereq.
dropbear: $(dropbearobjs)
dbclient: $(dbclientobjs)
dropbearkey: $(dropbearkeyobjs)
dropbearconvert: $(dropbearconvertobjs)
dropbear dbclient dropbearkey dropbearconvert: $($([email protected])) $(HEADERS) \
$(LTC) $(LTM)
@echo $(CLISVRFLAGS)
dropbear dbclient dropbearkey dropbearconvert: $(HEADERS) $(LTC) $(LTM)
$(LD) $(LDFLAGS) -o $(SPREFIX)[email protected]$(EXEEXT) $([email protected]objs) $(LIBS)
# scp doesn't use the libs so is special.
scp: $(SCPOBJS) $(HEADERS)
$(LD) $(LDFLAGS) -o $(SPREFIX)[email protected]$(EXEEXT) $(SCPOBJS)
MULTIOBJS=dbmulti.o
# multi-binary compilation.
MULTIOBJS=
ifeq ($(MULTI),1)
deftarget=multi
MULTIOBJS=$(foreach prog, $(PROGRAMS), $($(prog)objs))
MULTIOBJS=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs)))
CFLAGS+=$(addprefix -DDBMULTI_, $(PROGRAMS)) -DDROPBEAR_MULTI
endif
testfoo:
echo $(MULTIOBJS)
dropbearmulti: $(HEADERS) $(MULTIOBJS) $(LTC) $(LTM)
$(LD) $(LDFLAGS) -o $(SPREFIX)[email protected]$(EXEEXT) $(MULTIOBJS) $(LIBS)
@echo
@echo "You should now create symlinks to the programs you have included"
@echo "ie 'ln -s dropbearmulti dropbear'"
......
......@@ -4,6 +4,7 @@
int dropbear_main(int argc, char ** argv);
int dropbearkey_main(int argc, char ** argv);
int dropbearconvert_main(int argc, char ** argv);
int scp_main(int argc, char ** argv);
int main(int argc, char ** argv) {
......@@ -13,33 +14,41 @@ int main(int argc, char ** argv) {
/* figure which form we're being called as */
progname = basename(argv[0]);
#ifdef DBMULTI_DROPBEAR
#ifdef DBMULTI_dropbear
if (strcmp(progname, "dropbear") == 0) {
return dropbear_main(argc, argv);
}
#endif
#ifdef DBMULTI_KEY
#ifdef DBMULTI_dropbearkey
if (strcmp(progname, "dropbearkey") == 0) {
return dropbearkey_main(argc, argv);
}
#endif
#ifdef DBMULTI_CONVERT
#ifdef DBMULTI_dropbearconvert
if (strcmp(progname, "dropbearconvert") == 0) {
return dropbearconvert_main(argc, argv);
}
#endif
#ifdef DBMULTI_scp
if (strcmp(progname, "scp") == 0) {
return scp_main(argc, argv);
}
#endif
}
fprintf(stderr, "Dropbear multi-purpose version %s\n"
"Make a symlink pointing at this binary with one of the following names:\n"
#ifdef DBMULTI_DROPBEAR
#ifdef DBMULTI_dropbear
"'dropbear' - the Dropbear server\n"
#endif
#ifdef DBMULTI_KEY
#ifdef DBMULTI_dropbearkey
"'dropbearkey' - the key generator\n"
#endif
#ifdef DBMULTI_CONVERT
#ifdef DBMULTI_dropbearconvert
"'dropbearconvert' - the key converter\n"
#endif
#ifdef DBMULTI_scp
"'scp' - secure copy\n"
#endif
,
DROPBEAR_VERSION);
......
......@@ -53,8 +53,8 @@ static void printhelp(char * progname) {
"standard input or standard output.\n", progname);
}
#if defined(DBMULTI_CONVERT) || !defined(DROPBEAR_MULTI)
#if defined(DBMULTI_CONVERT) && defined(DROPBEAR_MULTI)
#if defined(DBMULTI_dropbearconvert) || !defined(DROPBEAR_MULTI)
#if defined(DBMULTI_dropbearconvert) && defined(DROPBEAR_MULTI)
int dropbearconvert_main(int argc, char ** argv) {
#else
int main(int argc, char ** argv) {
......
......@@ -80,8 +80,8 @@ static void printhelp(char * progname) {
progname);
}
#if defined(DBMULTI_KEY) || !defined(DROPBEAR_MULTI)
#if defined(DBMULTI_KEY) && defined(DROPBEAR_MULTI)
#if defined(DBMULTI_dropbearkey) || !defined(DROPBEAR_MULTI)
#if defined(DBMULTI_dropbearkey) && defined(DROPBEAR_MULTI)
int dropbearkey_main(int argc, char ** argv) {
#else
int main(int argc, char ** argv) {
......
......@@ -36,8 +36,8 @@ static void sigintterm_handler(int fish);
static int childpipes[MAX_UNAUTH_CLIENTS];
#if defined(DBMULTI_DROPBEAR) || !defined(DROPBEAR_MULTI)
#if defined(DBMULTI_DROPBEAR) && defined(DROPBEAR_MULTI)
#if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI)
#if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI)
int dropbear_main(int argc, char ** argv)
#else
int main(int argc, char ** argv)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment