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
=@CRYPTLIB@ svr-kex.o svr-algo.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-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
37 cli-session.o cli-service.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
)
60 dbclientobjs
=$(COMMONOBJS
) $(CLISVROBJS
) $(CLIOBJS
)
61 dropbearkeyobjs
=$(COMMONOBJS
) $(KEYOBJS
)
62 dropbearconvertobjs
=$(COMMONOBJS
) $(CONVERTOBJS
)
70 bindir=${exec_prefix}/bin
71 sbindir
=${exec_prefix}/sbin
79 CFLAGS
+=-I.
-I
$(srcdir) $(CPPFLAGS
) @CFLAGS@
85 # whether we're building client, server, or both for the common objects.
86 # evilness so we detect 'dropbear' by itself as a word
87 space
:= $(empty
) $(empty
)
88 ifneq (,$(strip $(foreach prog
, $(PROGRAMS
), $(findstring ZdropbearZ
, Z
$(prog
)Z
))))
89 CFLAGS
+= -DDROPBEAR_SERVER
91 ifneq (,$(strip $(foreach prog
, $(PROGRAMS
), $(findstring ZdbclientZ
, Z
$(prog
)Z
))))
92 CFLAGS
+= -DDROPBEAR_CLIENT
96 # these are exported so that libtomcrypt's makefile will use them
99 export RANLIB AR STRIP
106 TARGETS
=dropbearmulti
111 # for the scp progress meter. The -D doesn't affect anything else.
112 ifeq ($(SCPPROGRESS
), 1)
113 CFLAGS
+=-DPROGRESS_METER
119 $(STRIP
) $(addsuffix $(EXEEXT
), $(TARGETS
))
121 install: $(addprefix inst_
, $(TARGETS
))
123 installdropbearmulti
: insdbmulti
$(addprefix insmulti
, $(PROGRAMS
))
125 insdbmulti
: dropbearmulti
126 $(INSTALL
) -d
-m
755 $(DESTDIR
)$(bindir)
127 $(INSTALL
) -m
755 dropbearmulti
$(EXEEXT
) $(DESTDIR
)$(bindir)
128 -chown root
$(DESTDIR
)$(bindir)/dropbearmulti
$(EXEEXT
)
129 -chgrp
0 $(DESTDIR
)$(bindir)/dropbearmulti
$(EXEEXT
)
131 insmultidropbear
: dropbearmulti
132 -rm -f
$(DESTDIR
)$(sbindir
)/dropbear
$(EXEEXT
)
133 -ln
-s
$(DESTDIR
)$(bindir)/dropbearmulti
$(EXEEXT
) $(DESTDIR
)$(sbindir
)/dropbear
$(EXEEXT
)
135 insmulti
%: dropbearmulti
136 -rm -f
$(DESTDIR
)$(bindir)/$*$(EXEEXT
)
137 -ln
-s
$(DESTDIR
)$(bindir)/dropbearmulti
$(EXEEXT
) $(DESTDIR
)$(bindir)/$*$(EXEEXT
)
139 # dropbear should go in sbin, so it needs a seperate rule
140 inst_dropbear
: dropbear
141 $(INSTALL
) -d
-m
755 $(DESTDIR
)$(sbindir
)
142 $(INSTALL
) -m
755 dropbear
$(EXEEXT
) $(DESTDIR
)$(sbindir
)
143 -chown root
$(DESTDIR
)$(sbindir
)/dropbear
$(EXEEXT
)
144 -chgrp
0 $(DESTDIR
)$(sbindir
)/dropbear
$(EXEEXT
)
147 $(INSTALL
) -d
-m
755 $(DESTDIR
)$(bindir)
148 $(INSTALL
) -m
755 $*$(EXEEXT
) $(DESTDIR
)$(bindir)
149 -chown root
$(DESTDIR
)$(bindir)/$*$(EXEEXT
)
150 -chgrp
0 $(DESTDIR
)$(bindir)/$*$(EXEEXT
)
153 # for some reason the rule further down doesn't like $($@objs) as a prereq.
154 dropbear
: $(dropbearobjs
)
155 dbclient
: $(dbclientobjs
)
156 dropbearkey
: $(dropbearkeyobjs
)
157 dropbearconvert
: $(dropbearconvertobjs
)
159 dropbear dbclient dropbearkey dropbearconvert
: $(HEADERS
) $(LIBTOM_DEPS
) Makefile
160 $(CC
) $(LDFLAGS
) -o
$@
$(EXEEXT
) $($@objs
) $(LIBS
)
162 # scp doesn't use the libs so is special.
163 scp
: $(SCPOBJS
) $(HEADERS
) Makefile
164 $(CC
) $(LDFLAGS
) -o
$@
$(EXEEXT
) $(SCPOBJS
)
167 # multi-binary compilation.
170 MULTIOBJS
=dbmulti.o
$(sort $(foreach prog
, $(PROGRAMS
), $($(prog
)objs
)))
171 CFLAGS
+=$(addprefix -DDBMULTI_
, $(PROGRAMS
)) -DDROPBEAR_MULTI
174 dropbearmulti
: multilink
176 multibinary
: $(HEADERS
) $(MULTIOBJS
) $(LIBTOM_DEPS
) Makefile
177 $(CC
) $(LDFLAGS
) -o dropbearmulti
$(EXEEXT
) $(MULTIOBJS
) $(LIBS
)
179 multilink
: multibinary
$(addprefix link
, $(PROGRAMS
))
183 -ln
-s dropbearmulti
$(EXEEXT
) $*$(EXEEXT
)
186 cd libtomcrypt
&& $(MAKE
) clean && $(MAKE
)
189 cd libtommath
&& $(MAKE
)
191 .PHONY
: clean sizes thisclean
distclean tidy ltc-clean ltm-clean
194 cd libtomcrypt
&& $(MAKE
) clean
197 cd libtommath
&& $(MAKE
) clean
200 objdump
-t dropbear|grep
".text"|cut
-d
"." -f
2|
sort -rn
202 clean: ltc-clean ltm-clean thisclean
205 -rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \
206 dropbearmulti
*.o
*.da
*.bb
*.bbg
*.prof
208 distclean: clean tidy
213 -rm -f
*~
*.gcov
*/*~