1 # This Makefile is for Dropbear SSH Server and Client
5 # make PROGRAMS="dropbear dbclient scp" MULTI=1 STATIC=1 SCPPROGRESS=1
7 # to make a multiple-program statically linked binary "staticdropbearmulti".
8 # This example will include dropbear, scp, dropbearkey, dropbearconvert, and
9 # dbclient functionality, and includes the progress-bar functionality in scp.
10 # Hopefully that seems intuitive.
13 PROGRAMS
=dropbear dbclient dropbearkey dropbearconvert
16 STATIC_LTC
=libtomcrypt
/libtomcrypt.a
17 STATIC_LTM
=libtommath
/libtommath.a
19 LIBTOM_LIBS
=@LIBTOM_LIBS@
21 ifeq (@BUNDLED_LIBTOM@
, 1)
22 LIBTOM_DEPS
=$(STATIC_LTC
) $(STATIC_LTM
)
23 CFLAGS
+=-I
$(srcdir)/libtomcrypt
/src
/headers
/
24 LIBTOM_LIBS
=$(STATIC_LTC
) $(STATIC_LTM
)
27 COMMONOBJS
=dbutil.o buffer.o \
29 signkey.o rsa.o dbrandom.o \
31 atomicio.o compat.o fake-rfc2553.o \
32 ltc_prng.o ecc.o ecdsa.o crypto_desc.o \
33 gensignkey.o gendss.o genrsa.o
35 SVROBJS
=svr-kex.o svr-auth.o sshpty.o \
36 svr-authpasswd.o svr-authpubkey.o svr-authpubkeyoptions.o svr-session.o svr-service.o \
37 svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o\
38 svr-tcpfwd.o svr-authpam.o
40 CLIOBJS
=cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
41 cli-session.o cli-runopts.o cli-chansession.o \
42 cli-authpubkey.o cli-tcpfwd.o cli-channel.o cli-authinteract.o \
45 CLISVROBJS
=common-session.o packet.o common-algo.o common-kex.o \
46 common-channel.o common-chansession.o termcodes.o loginrec.o \
47 tcp-accept.o listener.o process-packet.o \
48 common-runopts.o circbuffer.o curve25519-donna.o
52 CONVERTOBJS
=dropbearconvert.o keyimport.o
54 SCPOBJS
=scp.o progressmeter.o atomicio.o scpmisc.o compat.o
56 HEADERS
=options.h dbutil.h session.h packet.h algo.h ssh.h buffer.h kex.h \
57 dss.h bignum.h signkey.h rsa.h dbrandom.h service.h auth.h \
58 debug.h channel.h chansession.h config.h queue.h sshpty.h \
59 termcodes.h gendss.h genrsa.h runopts.h includes.h \
60 loginrec.h atomicio.h x11fwd.h agentfwd.h tcpfwd.h compat.h \
61 listener.h fake-rfc2553.h ecc.h ecdsa.h
63 dropbearobjs
=$(COMMONOBJS
) $(CLISVROBJS
) $(SVROBJS
)
64 dbclientobjs
=$(COMMONOBJS
) $(CLISVROBJS
) $(CLIOBJS
)
65 dropbearkeyobjs
=$(COMMONOBJS
) $(KEYOBJS
)
66 dropbearconvertobjs
=$(COMMONOBJS
) $(CONVERTOBJS
)
73 exec_prefix=@
exec_prefix@
74 datarootdir
= @datarootdir@
85 CFLAGS
+=-I.
-I
$(srcdir) $(CPPFLAGS
) @CFLAGS@
91 # whether we're building client, server, or both for the common objects.
92 # evilness so we detect 'dropbear' by itself as a word
93 space
:= $(empty
) $(empty
)
94 ifneq (,$(strip $(foreach prog
, $(PROGRAMS
), $(findstring ZdropbearZ
, Z
$(prog
)Z
))))
95 CFLAGS
+= -DDROPBEAR_SERVER
97 ifneq (,$(strip $(foreach prog
, $(PROGRAMS
), $(findstring ZdbclientZ
, Z
$(prog
)Z
))))
98 CFLAGS
+= -DDROPBEAR_CLIENT
102 # these are exported so that libtomcrypt's makefile will use them
105 export RANLIB AR STRIP
112 TARGETS
=dropbearmulti
117 # for the scp progress meter. The -D doesn't affect anything else.
118 ifeq ($(SCPPROGRESS
), 1)
119 CFLAGS
+=-DPROGRESS_METER
125 $(STRIP
) $(addsuffix $(EXEEXT
), $(TARGETS
))
127 install: $(addprefix inst_
, $(TARGETS
))
129 insmultidropbear
: dropbearmulti
130 $(INSTALL
) -d
$(DESTDIR
)$(sbindir
)
131 -rm -f
$(DESTDIR
)$(sbindir
)/dropbear
$(EXEEXT
)
132 -ln
-s
$(bindir)/dropbearmulti
$(EXEEXT
) $(DESTDIR
)$(sbindir
)/dropbear
$(EXEEXT
)
133 $(INSTALL
) -d
$(DESTDIR
)$(mandir)/man8
134 $(INSTALL
) -m
644 $(srcdir)/dropbear
.8 $(DESTDIR
)$(mandir)/man8
/dropbear
.8
136 insmulti
%: dropbearmulti
137 $(INSTALL
) -d
$(DESTDIR
)$(bindir)
138 -rm -f
$(DESTDIR
)$(bindir)/$*$(EXEEXT
)
139 -ln
-s
$(bindir)/dropbearmulti
$(EXEEXT
) $(DESTDIR
)$(bindir)/$*$(EXEEXT
)
140 $(INSTALL
) -d
$(DESTDIR
)$(mandir)/man1
141 if
test -e
$*.1; then
$(INSTALL
) -m
644 $*.1 $(DESTDIR
)$(mandir)/man1
/$*.1; fi
143 # dropbear should go in sbin, so it needs a seperate rule
144 inst_dropbear
: dropbear
145 $(INSTALL
) -d
$(DESTDIR
)$(sbindir
)
146 $(INSTALL
) dropbear
$(EXEEXT
) $(DESTDIR
)$(sbindir
)
147 $(INSTALL
) -d
$(DESTDIR
)$(mandir)/man8
148 $(INSTALL
) -m
644 $(srcdir)/dropbear
.8 $(DESTDIR
)$(mandir)/man8
/dropbear
.8
151 $(INSTALL
) -d
$(DESTDIR
)$(bindir)
152 $(INSTALL
) $*$(EXEEXT
) $(DESTDIR
)$(bindir)
153 $(INSTALL
) -d
$(DESTDIR
)$(mandir)/man1
154 if
test -e
$*.1; then
$(INSTALL
) -m
644 $*.1 $(DESTDIR
)$(mandir)/man1
/$*.1; fi
156 inst_dropbearmulti
: $(addprefix insmulti
, $(PROGRAMS
))
159 # for some reason the rule further down doesn't like $($@objs) as a prereq.
160 dropbear
: $(dropbearobjs
)
161 dbclient
: $(dbclientobjs
)
162 dropbearkey
: $(dropbearkeyobjs
)
163 dropbearconvert
: $(dropbearconvertobjs
)
165 dropbear
: $(HEADERS
) $(LIBTOM_DEPS
) Makefile
166 $(CC
) $(LDFLAGS
) -o
$@
$(EXEEXT
) $($@objs
) $(LIBTOM_LIBS
) $(LIBS
) @CRYPTLIB@
168 dbclient
: $(HEADERS
) $(LIBTOM_DEPS
) Makefile
169 $(CC
) $(LDFLAGS
) -o
$@
$(EXEEXT
) $($@objs
) $(LIBTOM_LIBS
) $(LIBS
)
171 dropbearkey dropbearconvert
: $(HEADERS
) $(LIBTOM_DEPS
) Makefile
172 $(CC
) $(LDFLAGS
) -o
$@
$(EXEEXT
) $($@objs
) $(LIBTOM_LIBS
)
174 # scp doesn't use the libs so is special.
175 scp
: $(SCPOBJS
) $(HEADERS
) Makefile
176 $(CC
) $(LDFLAGS
) -o
$@
$(EXEEXT
) $(SCPOBJS
)
179 # multi-binary compilation.
182 MULTIOBJS
=dbmulti.o
$(sort $(foreach prog
, $(PROGRAMS
), $($(prog
)objs
)))
183 CFLAGS
+=$(addprefix -DDBMULTI_
, $(PROGRAMS
)) -DDROPBEAR_MULTI
186 dropbearmulti
$(EXEEXT
): $(HEADERS
) $(MULTIOBJS
) $(LIBTOM_DEPS
) Makefile
187 $(CC
) $(LDFLAGS
) -o
$@
$(MULTIOBJS
) $(LIBTOM_LIBS
) $(LIBS
) @CRYPTLIB@
189 multibinary
: dropbearmulti
$(EXEEXT
)
191 multilink
: multibinary
$(addprefix link
, $(PROGRAMS
))
195 -ln
-s dropbearmulti
$(EXEEXT
) $*$(EXEEXT
)
197 $(STATIC_LTC
): options.h
198 cd libtomcrypt
&& $(MAKE
)
200 $(STATIC_LTM
): options.h
201 cd libtommath
&& $(MAKE
)
203 .PHONY
: clean sizes thisclean
distclean tidy ltc-clean ltm-clean
206 cd libtomcrypt
&& $(MAKE
) clean
209 cd libtommath
&& $(MAKE
) clean
212 objdump
-t dropbear|grep
".text"|cut
-d
"." -f
2|
sort -rn
214 clean: ltc-clean ltm-clean thisclean
217 -rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \
218 dropbearmulti
*.o
*.da
*.bb
*.bbg
*.prof
220 distclean: clean tidy
225 -rm -f
*~
*.gcov
*/*~