Makefile.in 5.98 KB
Newer Older
Matt Johnston's avatar
Matt Johnston committed
1
# This Makefile is for Dropbear SSH Server and Client
Matt Johnston's avatar
Matt Johnston committed
2
# @[email protected]
Matt Johnston's avatar
Matt Johnston committed
3
4
5
6

# invocation:
# make PROGRAMS="dropbear dbclient scp" MULTI=1 STATIC=1 SCPPROGRESS=1
#
7
8
9
10
# to make a multiple-program statically linked binary "staticdropbearmulti".
# This example will include dropbear, scp, dropbearkey, dropbearconvert, and
# dbclient functionality, and includes the progress-bar functionality in scp.
# Hopefully that seems intuitive.
Matt Johnston's avatar
Matt Johnston committed
11
12

ifndef PROGRAMS
13
	PROGRAMS=dropbear dbclient dropbearkey dropbearconvert
Matt Johnston's avatar
Matt Johnston committed
14
15
endif

16
17
18
LTC=libtomcrypt/libtomcrypt.a
LTM=libtommath/libtommath.a

19
ifeq (@[email protected], 1)
20
LIBTOM_DEPS=$(LTC) $(LTM) 
21
CFLAGS+=-I$(srcdir)/libtomcrypt/src/headers/
22
LIBS+=$(LTC) $(LTM) 
23
24
endif

25
26
27
28
COMMONOBJS=dbutil.o buffer.o \
		dss.o bignum.o \
		signkey.o rsa.o random.o \
		queue.o \
Matt Johnston's avatar
Matt Johnston committed
29
30
		atomicio.o compat.o fake-rfc2553.o \
		ltc_prng.o ecc.o ecdsa.o crypto_desc.o
31

32
SVROBJS=svr-kex.o svr-auth.o sshpty.o \
33
		svr-authpasswd.o svr-authpubkey.o svr-authpubkeyoptions.o svr-session.o svr-service.o \
Matt Johnston's avatar
Matt Johnston committed
34
		svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o\
35
		svr-tcpfwd.o svr-authpam.o
36

37
CLIOBJS=cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
38
		cli-session.o cli-runopts.o cli-chansession.o \
39
		cli-authpubkey.o cli-tcpfwd.o cli-channel.o cli-authinteract.o \
40
		cli-agentfwd.o list.o
41

42
43
CLISVROBJS=common-session.o packet.o common-algo.o common-kex.o \
			common-channel.o common-chansession.o termcodes.o loginrec.o \
44
			tcp-accept.o listener.o process-packet.o \
Matt Johnston's avatar
Nasty.    
Matt Johnston committed
45
			common-runopts.o circbuffer.o
46

47
KEYOBJS=dropbearkey.o gendss.o genrsa.o
48
49
50

CONVERTOBJS=dropbearconvert.o keyimport.o

51
SCPOBJS=scp.o progressmeter.o atomicio.o scpmisc.o compat.o
52
53

HEADERS=options.h dbutil.h session.h packet.h algo.h ssh.h buffer.h kex.h \
Matt Johnston's avatar
Matt Johnston committed
54
		dss.h bignum.h signkey.h rsa.h random.h service.h auth.h \
Matt Johnston's avatar
Matt Johnston committed
55
		debug.h channel.h chansession.h config.h queue.h sshpty.h \
Matt Johnston's avatar
Matt Johnston committed
56
		termcodes.h gendss.h genrsa.h runopts.h includes.h \
Matt Johnston's avatar
Matt Johnston committed
57
		loginrec.h atomicio.h x11fwd.h agentfwd.h tcpfwd.h compat.h \
Matt Johnston's avatar
Matt Johnston committed
58
		listener.h fake-rfc2553.h ecc.h ecdsa.h
59

Matt Johnston's avatar
Matt Johnston committed
60
dropbearobjs=$(COMMONOBJS) $(CLISVROBJS) $(SVROBJS) @[email protected] 
61
dbclientobjs=$(COMMONOBJS) $(CLISVROBJS) $(CLIOBJS)
Matt Johnston's avatar
Matt Johnston committed
62
63
64
dropbearkeyobjs=$(COMMONOBJS) $(KEYOBJS)
dropbearconvertobjs=$(COMMONOBJS) $(CONVERTOBJS)
scpobjs=$(SCPOBJS)
65

Matt Johnston's avatar
Matt Johnston committed
66
67
68
VPATH=@[email protected]
srcdir=@[email protected]

69
70
71
72
73
74
75
76
77
78
prefix=@[email protected]
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
sbindir=${exec_prefix}/sbin

CC=@[email protected]
AR=@[email protected]
RANLIB=@[email protected]
STRIP=@[email protected]
INSTALL=@[email protected]
Matt Johnston's avatar
Matt Johnston committed
79
CPPFLAGS=@[email protected]
80
CFLAGS+=-I. -I$(srcdir) $(CPPFLAGS) @[email protected]
81
LIBS+=@[email protected]
82
83
LDFLAGS=@[email protected]

Matt Johnston's avatar
Matt Johnston committed
84
85
86
87
EXEEXT=@[email protected]

# whether we're building client, server, or both for the common objects.
# evilness so we detect 'dropbear' by itself as a word
88
89
90
space:= $(empty) $(empty)
ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdropbearZ, Z$(prog)Z))))
	CFLAGS+= -DDROPBEAR_SERVER
Matt Johnston's avatar
Matt Johnston committed
91
endif
92
93
ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdbclientZ, Z$(prog)Z))))
	CFLAGS+= -DDROPBEAR_CLIENT
Matt Johnston's avatar
Matt Johnston committed
94
95
96
endif


97
98
99
100
101
# these are exported so that libtomcrypt's makefile will use them
export CC
export CFLAGS
export RANLIB AR STRIP

Matt Johnston's avatar
Matt Johnston committed
102
103
104
ifeq ($(STATIC), 1)
	LDFLAGS+=-static
endif
105

Matt Johnston's avatar
Matt Johnston committed
106
107
108
109
110
ifeq ($(MULTI), 1)
	TARGETS=dropbearmulti
else
	TARGETS=$(PROGRAMS)
endif
111

Matt Johnston's avatar
Matt Johnston committed
112
113
114
115
# for the scp progress meter. The -D doesn't affect anything else.
ifeq ($(SCPPROGRESS), 1)
	CFLAGS+=-DPROGRESS_METER
endif
116

117
all: $(TARGETS)
118

119
strip: $(TARGETS)
120
	$(STRIP) $(addsuffix $(EXEEXT), $(TARGETS))
121

122
install: $(addprefix inst_, $(TARGETS))
123
124
125
126
127

installdropbearmulti: insdbmulti $(addprefix insmulti, $(PROGRAMS)) 

insdbmulti: dropbearmulti
	$(INSTALL) -d -m 755 $(DESTDIR)$(bindir)
128
129
130
	$(INSTALL) -m 755 dropbearmulti$(EXEEXT) $(DESTDIR)$(bindir)
	-chown root $(DESTDIR)$(bindir)/dropbearmulti$(EXEEXT)
	-chgrp 0 $(DESTDIR)$(bindir)/dropbearmulti$(EXEEXT)
131
132

insmultidropbear: dropbearmulti
133
	$(INSTALL) -d -m 755 $(DESTDIR)$(sbindir)
134
	-rm -f $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
135
	-ln -s $(bindir)/dropbearmulti$(EXEEXT) $(DESTDIR)$(sbindir)/dropbear$(EXEEXT) 
136
137

insmulti%: dropbearmulti
138
	$(INSTALL) -d -m 755 $(DESTDIR)$(bindir)
139
	-rm -f $(DESTDIR)$(bindir)/$*$(EXEEXT) 
140
	-ln -s $(bindir)/dropbearmulti$(EXEEXT) $(DESTDIR)$(bindir)/$*$(EXEEXT) 
141

Matt Johnston's avatar
Matt Johnston committed
142
# dropbear should go in sbin, so it needs a seperate rule
143
inst_dropbear: dropbear
Matt Johnston's avatar
Matt Johnston committed
144
	$(INSTALL) -d -m 755 $(DESTDIR)$(sbindir)
145
146
147
	$(INSTALL) -m 755 dropbear$(EXEEXT) $(DESTDIR)$(sbindir)
	-chown root $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
	-chgrp 0 $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
148

149
inst_%: $*
Matt Johnston's avatar
Matt Johnston committed
150
	$(INSTALL) -d -m 755 $(DESTDIR)$(bindir)
151
152
153
	$(INSTALL) -m 755 $*$(EXEEXT) $(DESTDIR)$(bindir)
	-chown root $(DESTDIR)$(bindir)/$*$(EXEEXT)
	-chgrp 0 $(DESTDIR)$(bindir)/$*$(EXEEXT)
154
155


156
# for some reason the rule further down doesn't like $([email protected]) as a prereq.
Matt Johnston's avatar
Matt Johnston committed
157
dropbear: $(dropbearobjs)
158
159
160
dbclient: $(dbclientobjs)
dropbearkey: $(dropbearkeyobjs)
dropbearconvert: $(dropbearconvertobjs)
161

162
dropbear dbclient dropbearkey dropbearconvert: $(HEADERS) $(LIBTOM_DEPS) Makefile
163
	$(CC) $(LDFLAGS) -o [email protected]$(EXEEXT) $([email protected]objs) $(LIBS)
164

Matt Johnston's avatar
Matt Johnston committed
165
# scp doesn't use the libs so is special.
Matt Johnston's avatar
Matt Johnston committed
166
scp: $(SCPOBJS)  $(HEADERS) Makefile
167
	$(CC) $(LDFLAGS) -o [email protected]$(EXEEXT) $(SCPOBJS)
168
169


170
171
# multi-binary compilation.
MULTIOBJS=
Matt Johnston's avatar
Matt Johnston committed
172
ifeq ($(MULTI),1)
Matt Johnston's avatar
Matt Johnston committed
173
	MULTIOBJS=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs))) @[email protected] 
174
	CFLAGS+=$(addprefix -DDBMULTI_, $(PROGRAMS)) -DDROPBEAR_MULTI
Matt Johnston's avatar
Matt Johnston committed
175
endif
176

177
178
dropbearmulti: multilink 

179
multibinary: $(HEADERS) $(MULTIOBJS) $(LIBTOM_DEPS) Makefile
180
	$(CC) $(LDFLAGS) -o dropbearmulti$(EXEEXT) $(MULTIOBJS) $(LIBS)
181
182
183
184

multilink: multibinary $(addprefix link, $(PROGRAMS))

link%:
185
186
	-rm -f $*$(EXEEXT)
	-ln -s dropbearmulti$(EXEEXT) $*$(EXEEXT)
187

Matt Johnston's avatar
Matt Johnston committed
188
$(LTC): options.h
189
	cd libtomcrypt && $(MAKE)
190

Matt Johnston's avatar
Matt Johnston committed
191
$(LTM): options.h
192
193
	cd libtommath && $(MAKE)

194
195
.PHONY : clean sizes thisclean distclean tidy ltc-clean ltm-clean

196
197
198
199
200
201
202
203
204
ltc-clean:
	cd libtomcrypt && $(MAKE) clean

ltm-clean:
	cd libtommath && $(MAKE) clean

sizes: dropbear
	objdump -t dropbear|grep ".text"|cut -d "." -f 2|sort -rn

Matt Johnston's avatar
Matt Johnston committed
205
206
207
clean: ltc-clean ltm-clean thisclean

thisclean:
208
209
	-rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \
			dropbearmulti *.o *.da *.bb *.bbg *.prof 
210
211

distclean: clean tidy
Matt Johnston's avatar
Matt Johnston committed
212
213
	-rm -f config.h
	-rm -f Makefile
214
215
216

tidy:
	-rm -f *~ *.gcov */*~