• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# This Makefile is for Dropbear SSH Server and Client
2# @configure_input@
3
4# invocation:
5# make PROGRAMS="dropbear dbclient scp" MULTI=1 STATIC=1 SCPPROGRESS=1
6#
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.
11
12ifndef PROGRAMS
13	PROGRAMS=dropbear dbclient dropbearkey dropbearconvert
14endif
15
16LTC=libtomcrypt/libtomcrypt.a
17LTM=libtommath/libtommath.a
18
19COMMONOBJS=dbutil.o buffer.o \
20		dss.o bignum.o \
21		signkey.o rsa.o random.o \
22		queue.o \
23		atomicio.o compat.o  fake-rfc2553.o
24
25SVROBJS=svr-kex.o svr-algo.o svr-auth.o sshpty.o \
26		svr-authpasswd.o svr-authpubkey.o svr-session.o svr-service.o \
27		svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o\
28		svr-tcpfwd.o svr-authpam.o
29
30CLIOBJS=cli-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
31		cli-session.o cli-service.o cli-runopts.o cli-chansession.o \
32		cli-authpubkey.o cli-tcpfwd.o cli-channel.o cli-authinteract.o
33
34CLISVROBJS=common-session.o packet.o common-algo.o common-kex.o \
35			common-channel.o common-chansession.o termcodes.o loginrec.o \
36			tcp-accept.o listener.o process-packet.o \
37			common-runopts.o circbuffer.o
38
39KEYOBJS=dropbearkey.o gendss.o genrsa.o
40
41CONVERTOBJS=dropbearconvert.o keyimport.o
42
43SCPOBJS=scp.o progressmeter.o atomicio.o scpmisc.o
44
45HEADERS=options.h dbutil.h session.h packet.h algo.h ssh.h buffer.h kex.h \
46		dss.h bignum.h signkey.h rsa.h random.h service.h auth.h \
47		debug.h channel.h chansession.h config.h queue.h sshpty.h \
48		termcodes.h gendss.h genrsa.h runopts.h includes.h \
49		loginrec.h atomicio.h x11fwd.h agentfwd.h tcpfwd.h compat.h \
50		listener.h fake-rfc2553.h
51
52dropbearobjs=$(COMMONOBJS) $(CLISVROBJS) $(SVROBJS)
53dbclientobjs=$(COMMONOBJS) $(CLISVROBJS) $(CLIOBJS)
54dropbearkeyobjs=$(COMMONOBJS) $(KEYOBJS)
55dropbearconvertobjs=$(COMMONOBJS) $(CONVERTOBJS)
56scpobjs=$(SCPOBJS)
57
58VPATH=@srcdir@
59srcdir=@srcdir@
60
61prefix=@prefix@
62exec_prefix=${prefix}
63bindir=${exec_prefix}/bin
64sbindir=${exec_prefix}/sbin
65
66CC=@CC@
67AR=@AR@
68RANLIB=@RANLIB@
69STRIP=@STRIP@
70INSTALL=@INSTALL@
71CPPFLAGS=@CPPFLAGS@
72CFLAGS=-I. -I$(srcdir) -I$(srcdir)/libtomcrypt/src/headers/ $(CPPFLAGS) @CFLAGS@
73LIBS=$(LTC) $(LTM) @LIBS@
74LDFLAGS=@LDFLAGS@
75
76EXEEXT=@EXEEXT@
77
78# whether we're building client, server, or both for the common objects.
79# evilness so we detect 'dropbear' by itself as a word
80space:= $(empty) $(empty)
81ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdropbearZ, Z$(prog)Z))))
82	CFLAGS+= -DDROPBEAR_SERVER
83endif
84ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdbclientZ, Z$(prog)Z))))
85	CFLAGS+= -DDROPBEAR_CLIENT
86endif
87
88
89# these are exported so that libtomcrypt's makefile will use them
90export CC
91export CFLAGS
92export RANLIB AR STRIP
93
94ifeq ($(STATIC), 1)
95	LDFLAGS+=-static
96endif
97
98ifeq ($(MULTI), 1)
99	TARGETS=dropbearmulti
100else
101	TARGETS=$(PROGRAMS)
102endif
103
104# for the scp progress meter. The -D doesn't affect anything else.
105ifeq ($(SCPPROGRESS), 1)
106	CFLAGS+=-DPROGRESS_METER
107endif
108
109#%: $(HEADERS)
110#%: $(HEADERS) Makefile
111# TODO
112
113all: $(TARGETS)
114
115strip: $(TARGETS)
116	$(STRIP) $(addsuffix $(EXEEXT), $(TARGETS))
117
118install: $(addprefix inst_, $(TARGETS))
119
120installdropbearmulti: insdbmulti $(addprefix insmulti, $(PROGRAMS))
121
122insdbmulti: dropbearmulti
123	$(INSTALL) -d -m 755 $(DESTDIR)$(bindir)
124	$(INSTALL) -m 755 dropbearmulti$(EXEEXT) $(DESTDIR)$(bindir)
125	-chown root $(DESTDIR)$(bindir)/dropbearmulti$(EXEEXT)
126	-chgrp 0 $(DESTDIR)$(bindir)/dropbearmulti$(EXEEXT)
127
128insmultidropbear: dropbearmulti
129	-rm -f $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
130	-ln -s $(DESTDIR)$(bindir)/dropbearmulti$(EXEEXT) $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
131
132insmulti%: dropbearmulti
133	-rm -f $(DESTDIR)$(bindir)/$*$(EXEEXT)
134	-ln -s $(DESTDIR)$(bindir)/dropbearmulti$(EXEEXT) $(DESTDIR)$(bindir)/$*$(EXEEXT)
135
136# dropbear should go in sbin, so it needs a seperate rule
137inst_dropbear: dropbear
138	$(INSTALL) -d -m 755 $(DESTDIR)$(sbindir)
139	$(INSTALL) -m 755 dropbear$(EXEEXT) $(DESTDIR)$(sbindir)
140	-chown root $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
141	-chgrp 0 $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
142
143inst_%: $*
144	$(INSTALL) -d -m 755 $(DESTDIR)$(bindir)
145	$(INSTALL) -m 755 $*$(EXEEXT) $(DESTDIR)$(bindir)
146	-chown root $(DESTDIR)$(bindir)/$*$(EXEEXT)
147	-chgrp 0 $(DESTDIR)$(bindir)/$*$(EXEEXT)
148
149
150# for some reason the rule further down doesn't like $($@objs) as a prereq.
151dropbear: $(dropbearobjs)
152dbclient: $(dbclientobjs)
153dropbearkey: $(dropbearkeyobjs)
154dropbearconvert: $(dropbearconvertobjs)
155
156dropbear dbclient dropbearkey dropbearconvert: $(HEADERS)  $(LTC) $(LTM) \
157													Makefile
158	$(CC) $(LDFLAGS) -o $@$(EXEEXT) $($@objs) $(LIBS)
159
160# scp doesn't use the libs so is special.
161scp: $(SCPOBJS)  $(HEADERS) Makefile
162	$(CC) $(LDFLAGS) -o $@$(EXEEXT) $(SCPOBJS)
163
164
165# multi-binary compilation.
166MULTIOBJS=
167ifeq ($(MULTI),1)
168	MULTIOBJS=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs)))
169	CFLAGS+=$(addprefix -DDBMULTI_, $(PROGRAMS)) -DDROPBEAR_MULTI
170endif
171
172dropbearmulti: multilink
173
174multibinary: $(HEADERS) $(MULTIOBJS) $(LTC) $(LTM) Makefile
175	$(CC) $(LDFLAGS) -o dropbearmulti$(EXEEXT) $(MULTIOBJS) $(LIBS)
176
177multilink: multibinary $(addprefix link, $(PROGRAMS))
178
179link%:
180	-rm -f $*$(EXEEXT)
181	-ln -s dropbearmulti$(EXEEXT) $*$(EXEEXT)
182
183$(LTC): options.h
184	cd libtomcrypt && $(MAKE) clean && $(MAKE)
185
186$(LTM): options.h
187	cd libtommath && $(MAKE)
188
189.PHONY : clean sizes thisclean distclean tidy ltc-clean ltm-clean
190
191ltc-clean:
192	cd libtomcrypt && $(MAKE) clean
193
194ltm-clean:
195	cd libtommath && $(MAKE) clean
196
197sizes: dropbear
198	objdump -t dropbear|grep ".text"|cut -d "." -f 2|sort -rn
199
200clean: ltc-clean ltm-clean thisclean
201
202thisclean:
203	-rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \
204			dropbearmulti *.o *.da *.bb *.bbg *.prof
205
206distclean: clean tidy
207	-rm -f config.h
208	-rm -f Makefile
209
210tidy:
211	-rm -f *~ *.gcov */*~
212