Makefile.in 6.33 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
19
STATIC_LTC=libtomcrypt/libtomcrypt.a
STATIC_LTM=libtommath/libtommath.a

LIBTOM_LIBS=@[email protected]
20

21
ifeq (@[email protected], 1)
22
LIBTOM_DEPS=$(STATIC_LTC) $(STATIC_LTM) 
23
CFLAGS+=-I$(srcdir)/libtomcrypt/src/headers/
24
LIBTOM_LIBS=$(STATIC_LTC) $(STATIC_LTM) 
25
26
endif

27
28
COMMONOBJS=dbutil.o buffer.o \
		dss.o bignum.o \
29
		signkey.o rsa.o dbrandom.o \
30
		queue.o \
Matt Johnston's avatar
Matt Johnston committed
31
		atomicio.o compat.o fake-rfc2553.o \
32
33
		ltc_prng.o ecc.o ecdsa.o crypto_desc.o \
		gensignkey.o gendss.o genrsa.o
34

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 \
Matt Johnston's avatar
Matt Johnston committed
37
		svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o\
38
		svr-tcpfwd.o svr-authpam.o
39

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 \
43
		cli-agentfwd.o list.o
44

45
46
CLISVROBJS=common-session.o packet.o common-algo.o common-kex.o \
			common-channel.o common-chansession.o termcodes.o loginrec.o \
47
			tcp-accept.o listener.o process-packet.o \
Matt Johnston's avatar
Matt Johnston committed
48
			common-runopts.o circbuffer.o curve25519-donna.o
49

50
KEYOBJS=dropbearkey.o
51
52
53

CONVERTOBJS=dropbearconvert.o keyimport.o

54
SCPOBJS=scp.o progressmeter.o atomicio.o scpmisc.o compat.o
55
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 \
Matt Johnston's avatar
Matt Johnston committed
58
		debug.h channel.h chansession.h config.h queue.h sshpty.h \
Matt Johnston's avatar
Matt Johnston committed
59
		termcodes.h gendss.h genrsa.h runopts.h includes.h \
Matt Johnston's avatar
Matt Johnston committed
60
		loginrec.h atomicio.h x11fwd.h agentfwd.h tcpfwd.h compat.h \
Matt Johnston's avatar
Matt Johnston committed
61
		listener.h fake-rfc2553.h ecc.h ecdsa.h
62

63
dropbearobjs=$(COMMONOBJS) $(CLISVROBJS) $(SVROBJS)
64
dbclientobjs=$(COMMONOBJS) $(CLISVROBJS) $(CLIOBJS)
Matt Johnston's avatar
Matt Johnston committed
65
66
67
dropbearkeyobjs=$(COMMONOBJS) $(KEYOBJS)
dropbearconvertobjs=$(COMMONOBJS) $(CONVERTOBJS)
scpobjs=$(SCPOBJS)
68

Matt Johnston's avatar
Matt Johnston committed
69
70
71
VPATH=@[email protected]
srcdir=@[email protected]

72
prefix=@[email protected]
73
exec_prefix=@[email protected]
74
75
76
77
datarootdir = @[email protected]
bindir=@[email protected]
sbindir=@[email protected]
mandir=@[email protected]
78
79
80
81
82
83

CC=@[email protected]
AR=@[email protected]
RANLIB=@[email protected]
STRIP=@[email protected]
INSTALL=@[email protected]
Matt Johnston's avatar
Matt Johnston committed
84
CPPFLAGS=@[email protected]
85
CFLAGS+=-I. -I$(srcdir) $(CPPFLAGS) @[email protected]
86
LIBS+=@[email protected]
87
88
LDFLAGS=@[email protected]

Matt Johnston's avatar
Matt Johnston committed
89
90
91
92
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
93
94
95
space:= $(empty) $(empty)
ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdropbearZ, Z$(prog)Z))))
	CFLAGS+= -DDROPBEAR_SERVER
Matt Johnston's avatar
Matt Johnston committed
96
endif
97
98
ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdbclientZ, Z$(prog)Z))))
	CFLAGS+= -DDROPBEAR_CLIENT
Matt Johnston's avatar
Matt Johnston committed
99
100
101
endif


102
103
104
105
106
# 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
107
108
109
ifeq ($(STATIC), 1)
	LDFLAGS+=-static
endif
110

Matt Johnston's avatar
Matt Johnston committed
111
112
113
114
115
ifeq ($(MULTI), 1)
	TARGETS=dropbearmulti
else
	TARGETS=$(PROGRAMS)
endif
116

Matt Johnston's avatar
Matt Johnston committed
117
118
119
120
# for the scp progress meter. The -D doesn't affect anything else.
ifeq ($(SCPPROGRESS), 1)
	CFLAGS+=-DPROGRESS_METER
endif
121

122
all: $(TARGETS)
123

124
strip: $(TARGETS)
125
	$(STRIP) $(addsuffix $(EXEEXT), $(TARGETS))
126

127
install: $(addprefix inst_, $(TARGETS))
128
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
134
	$(INSTALL) -d $(DESTDIR)$(mandir)/man8
	$(INSTALL) -m 644 dropbear.8  $(DESTDIR)$(mandir)/man8/dropbear.8
135
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
142

Matt Johnston's avatar
Matt Johnston committed
143
# dropbear should go in sbin, so it needs a seperate rule
144
inst_dropbear: dropbear
145
146
147
	$(INSTALL) -d $(DESTDIR)$(sbindir)
	$(INSTALL) dropbear$(EXEEXT) $(DESTDIR)$(sbindir)
	$(INSTALL) -d $(DESTDIR)$(mandir)/man8
148
	$(INSTALL) -m 644 dropbear.8 $(DESTDIR)$(mandir)/man8/dropbear.8
149

150
inst_%: %
151
152
153
	$(INSTALL) -d $(DESTDIR)$(bindir)
	$(INSTALL) $*$(EXEEXT) $(DESTDIR)$(bindir)
	$(INSTALL) -d $(DESTDIR)$(mandir)/man1
154
155
156
	if test -e $*.1; then $(INSTALL) -m 644 $*.1 $(DESTDIR)$(mandir)/man1/$*.1; fi

inst_dropbearmulti: $(addprefix insmulti, $(PROGRAMS)) 
157
158


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

165
166
167
168
dropbear: $(HEADERS) $(LIBTOM_DEPS) Makefile
	$(CC) $(LDFLAGS) -o [email protected]$(EXEEXT) $([email protected]objs) $(LIBTOM_LIBS) $(LIBS) @[email protected]

dbclient: $(HEADERS) $(LIBTOM_DEPS) Makefile
169
170
171
172
	$(CC) $(LDFLAGS) -o [email protected]$(EXEEXT) $([email protected]objs) $(LIBTOM_LIBS) $(LIBS)

dropbearkey dropbearconvert: $(HEADERS) $(LIBTOM_DEPS) Makefile
	$(CC) $(LDFLAGS) -o [email protected]$(EXEEXT) $([email protected]objs) $(LIBTOM_LIBS)
173

Matt Johnston's avatar
Matt Johnston committed
174
# scp doesn't use the libs so is special.
Matt Johnston's avatar
Matt Johnston committed
175
scp: $(SCPOBJS)  $(HEADERS) Makefile
176
	$(CC) $(LDFLAGS) -o [email protected]$(EXEEXT) $(SCPOBJS)
177
178


179
180
# multi-binary compilation.
MULTIOBJS=
Matt Johnston's avatar
Matt Johnston committed
181
ifeq ($(MULTI),1)
182
	MULTIOBJS=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs)))
183
	CFLAGS+=$(addprefix -DDBMULTI_, $(PROGRAMS)) -DDROPBEAR_MULTI
Matt Johnston's avatar
Matt Johnston committed
184
endif
185

186
dropbearmulti$(EXEEXT): $(HEADERS) $(MULTIOBJS) $(LIBTOM_DEPS) Makefile
187
	$(CC) $(LDFLAGS) -o [email protected] $(MULTIOBJS) $(LIBTOM_LIBS) $(LIBS) @[email protected]
188

189
multibinary: dropbearmulti$(EXEEXT)
190
191
192
193

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

link%:
194
195
	-rm -f $*$(EXEEXT)
	-ln -s dropbearmulti$(EXEEXT) $*$(EXEEXT)
196

197
$(STATIC_LTC): options.h
198
	cd libtomcrypt && $(MAKE)
199

200
$(STATIC_LTM): options.h
201
202
	cd libtommath && $(MAKE)

203
204
.PHONY : clean sizes thisclean distclean tidy ltc-clean ltm-clean

205
206
207
208
209
210
211
212
213
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
214
215
216
clean: ltc-clean ltm-clean thisclean

thisclean:
217
218
	-rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \
			dropbearmulti *.o *.da *.bb *.bbg *.prof 
219
220

distclean: clean tidy
Matt Johnston's avatar
Matt Johnston committed
221
222
	-rm -f config.h
	-rm -f Makefile
223
224
225

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