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 LTC
=libtomcrypt
/libtomcrypt.a
17 LTM
=libtommath
/libtommath.a
19 ifeq (@BUNDLED_LIBTOM@
, 1)
20 LIBTOM_DEPS
=$(LTC
) $(LTM
)
21 CFLAGS
+=-I
$(srcdir)/libtomcrypt
/src
/headers
/
25 COMMONOBJS
=dbutil.o buffer.o \
27 signkey.o rsa.o random.o \
29 atomicio.o compat.o fake-rfc2553.o
31 SVROBJS
=svr-kex.o svr-auth.o sshpty.o \
32 svr-authpasswd.o svr-authpubkey.o svr-authpubkeyoptions.o svr-session.o svr-service.o \
33 svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o\
34 svr-tcpfwd.o svr-authpam.o
36 CLIOBJS
=cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
37 cli-session.o cli-runopts.o cli-chansession.o \
38 cli-authpubkey.o cli-tcpfwd.o cli-channel.o cli-authinteract.o \
41 CLISVROBJS
=common-session.o packet.o common-algo.o common-kex.o \
42 common-channel.o common-chansession.o termcodes.o loginrec.o \
43 tcp-accept.o listener.o process-packet.o \
44 common-runopts.o circbuffer.o
46 KEYOBJS
=dropbearkey.o gendss.o genrsa.o
48 CONVERTOBJS
=dropbearconvert.o keyimport.o
50 SCPOBJS
=scp.o progressmeter.o atomicio.o scpmisc.o compat.o
52 HEADERS
=options.h dbutil.h session.h packet.h algo.h ssh.h buffer.h kex.h \
53 dss.h bignum.h signkey.h rsa.h random.h service.h auth.h \
54 debug.h channel.h chansession.h config.h queue.h sshpty.h \
55 termcodes.h gendss.h genrsa.h runopts.h includes.h \
56 loginrec.h atomicio.h x11fwd.h agentfwd.h tcpfwd.h compat.h \
57 listener.h fake-rfc2553.h
59 dropbearobjs
=$(COMMONOBJS
) $(CLISVROBJS
) $(SVROBJS
) @CRYPTLIB@
60 dbclientobjs
=$(COMMONOBJS
) $(CLISVROBJS
) $(CLIOBJS
)
61 dropbearkeyobjs
=$(COMMONOBJS
) $(KEYOBJS
)
62 dropbearconvertobjs
=$(COMMONOBJS
) $(CONVERTOBJS
)
69 exec_prefix=@
exec_prefix@
70 datarootdir
= @datarootdir@
81 CFLAGS
+=-I.
-I
$(srcdir) $(CPPFLAGS
) @CFLAGS@
87 # whether we're building client, server, or both for the common objects.
88 # evilness so we detect 'dropbear' by itself as a word
89 space
:= $(empty
) $(empty
)
90 ifneq (,$(strip $(foreach prog
, $(PROGRAMS
), $(findstring ZdropbearZ
, Z
$(prog
)Z
))))
91 CFLAGS
+= -DDROPBEAR_SERVER
93 ifneq (,$(strip $(foreach prog
, $(PROGRAMS
), $(findstring ZdbclientZ
, Z
$(prog
)Z
))))
94 CFLAGS
+= -DDROPBEAR_CLIENT
98 # these are exported so that libtomcrypt's makefile will use them
101 export RANLIB AR STRIP
108 TARGETS
=dropbearmulti
113 # for the scp progress meter. The -D doesn't affect anything else.
114 ifeq ($(SCPPROGRESS
), 1)
115 CFLAGS
+=-DPROGRESS_METER
121 $(STRIP
) $(addsuffix $(EXEEXT
), $(TARGETS
))
123 install: $(addprefix inst_
, $(TARGETS
))
125 installdropbearmulti
: insdbmulti
$(addprefix insmulti
, $(PROGRAMS
))
127 insdbmulti
: dropbearmulti
128 $(INSTALL
) -d
-m
755 $(DESTDIR
)$(bindir)
129 $(INSTALL
) -m
755 dropbearmulti
$(EXEEXT
) $(DESTDIR
)$(bindir)
130 -chown root
$(DESTDIR
)$(bindir)/dropbearmulti
$(EXEEXT
)
131 -chgrp
0 $(DESTDIR
)$(bindir)/dropbearmulti
$(EXEEXT
)
133 insmultidropbear
: dropbearmulti
134 $(INSTALL
) -d
-m
755 $(DESTDIR
)$(sbindir
)
135 -rm -f
$(DESTDIR
)$(sbindir
)/dropbear
$(EXEEXT
)
136 -ln
-s
$(bindir)/dropbearmulti
$(EXEEXT
) $(DESTDIR
)$(sbindir
)/dropbear
$(EXEEXT
)
138 insmulti
%: dropbearmulti
139 $(INSTALL
) -d
-m
755 $(DESTDIR
)$(bindir)
140 -rm -f
$(DESTDIR
)$(bindir)/$*$(EXEEXT
)
141 -ln
-s
$(bindir)/dropbearmulti
$(EXEEXT
) $(DESTDIR
)$(bindir)/$*$(EXEEXT
)
143 # dropbear should go in sbin, so it needs a seperate rule
144 inst_dropbear
: dropbear
145 $(INSTALL
) -d
-m
755 $(DESTDIR
)$(sbindir
)
146 $(INSTALL
) -m
755 dropbear
$(EXEEXT
) $(DESTDIR
)$(sbindir
)
147 -chown root
$(DESTDIR
)$(sbindir
)/dropbear
$(EXEEXT
)
148 -chgrp
0 $(DESTDIR
)$(sbindir
)/dropbear
$(EXEEXT
)
151 $(INSTALL
) -d
-m
755 $(DESTDIR
)$(bindir)
152 $(INSTALL
) -m
755 $*$(EXEEXT
) $(DESTDIR
)$(bindir)
153 -chown root
$(DESTDIR
)$(bindir)/$*$(EXEEXT
)
154 -chgrp
0 $(DESTDIR
)$(bindir)/$*$(EXEEXT
)
157 # for some reason the rule further down doesn't like $($@objs) as a prereq.
158 dropbear
: $(dropbearobjs
)
159 dbclient
: $(dbclientobjs
)
160 dropbearkey
: $(dropbearkeyobjs
)
161 dropbearconvert
: $(dropbearconvertobjs
)
163 dropbear dbclient dropbearkey dropbearconvert
: $(HEADERS
) $(LIBTOM_DEPS
) Makefile
164 $(CC
) $(LDFLAGS
) -o
$@
$(EXEEXT
) $($@objs
) $(LIBS
)
166 # scp doesn't use the libs so is special.
167 scp
: $(SCPOBJS
) $(HEADERS
) Makefile
168 $(CC
) $(LDFLAGS
) -o
$@
$(EXEEXT
) $(SCPOBJS
)
171 # multi-binary compilation.
174 MULTIOBJS
=dbmulti.o
$(sort $(foreach prog
, $(PROGRAMS
), $($(prog
)objs
))) @CRYPTLIB@
175 CFLAGS
+=$(addprefix -DDBMULTI_
, $(PROGRAMS
)) -DDROPBEAR_MULTI
178 dropbearmulti
: multilink
180 multibinary
: $(HEADERS
) $(MULTIOBJS
) $(LIBTOM_DEPS
) Makefile
181 $(CC
) $(LDFLAGS
) -o dropbearmulti
$(EXEEXT
) $(MULTIOBJS
) $(LIBS
)
183 multilink
: multibinary
$(addprefix link
, $(PROGRAMS
))
187 -ln
-s dropbearmulti
$(EXEEXT
) $*$(EXEEXT
)
190 cd libtomcrypt
&& $(MAKE
) clean && $(MAKE
)
193 cd libtommath
&& $(MAKE
)
195 .PHONY
: clean sizes thisclean
distclean tidy ltc-clean ltm-clean
198 cd libtomcrypt
&& $(MAKE
) clean
201 cd libtommath
&& $(MAKE
) clean
204 objdump
-t dropbear|grep
".text"|cut
-d
"." -f
2|
sort -rn
206 clean: ltc-clean ltm-clean thisclean
209 -rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \
210 dropbearmulti
*.o
*.da
*.bb
*.bbg
*.prof
212 distclean: clean tidy
217 -rm -f
*~
*.gcov
*/*~