Makefile.in 6.15 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
LIBTOM_LIBS+=$(LTC) $(LTM) 
23
24
endif

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

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

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

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

48
KEYOBJS=dropbearkey.o
49
50
51

CONVERTOBJS=dropbearconvert.o keyimport.o

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

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

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

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

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

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

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


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

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

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

120
all: $(TARGETS)
121

122
strip: $(TARGETS)
123
	$(STRIP) $(addsuffix $(EXEEXT), $(TARGETS))
124

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

insmultidropbear: dropbearmulti
128
	$(INSTALL) -d $(DESTDIR)$(sbindir)
129
	-rm -f $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
130
	-ln -s $(bindir)/dropbearmulti$(EXEEXT) $(DESTDIR)$(sbindir)/dropbear$(EXEEXT) 
131
132
	$(INSTALL) -d $(DESTDIR)$(mandir)/man8
	$(INSTALL) -m 644 dropbear.8  $(DESTDIR)$(mandir)/man8/dropbear.8
133
134

insmulti%: dropbearmulti
135
	$(INSTALL) -d $(DESTDIR)$(bindir)
136
	-rm -f $(DESTDIR)$(bindir)/$*$(EXEEXT) 
137
	-ln -s $(bindir)/dropbearmulti$(EXEEXT) $(DESTDIR)$(bindir)/$*$(EXEEXT) 
138
	$(INSTALL) -d $(DESTDIR)$(mandir)/man1
139
	if test -e $*.1; then $(INSTALL) -m 644 $*.1 $(DESTDIR)$(mandir)/man1/$*.1; fi
140

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

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

inst_dropbearmulti: $(addprefix insmulti, $(PROGRAMS)) 
155
156


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

163
164
165
166
167
dropbear dbclient: $(HEADERS) $(LIBTOM_DEPS) Makefile
	$(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)
168

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


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

181
dropbearmulti$(EXEEXT): $(HEADERS) $(MULTIOBJS) $(LIBTOM_DEPS) Makefile
182
	$(CC) $(LDFLAGS) -o [email protected] $(MULTIOBJS) $(LIBTOM_LIBS) $(LIBS)$
183

184
multibinary: dropbearmulti$(EXEEXT)
185
186
187
188

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

link%:
189
190
	-rm -f $*$(EXEEXT)
	-ln -s dropbearmulti$(EXEEXT) $*$(EXEEXT)
191

Matt Johnston's avatar
Matt Johnston committed
192
$(LTC): options.h
193
	cd libtomcrypt && $(MAKE)
194

Matt Johnston's avatar
Matt Johnston committed
195
$(LTM): options.h
196
197
	cd libtommath && $(MAKE)

198
199
.PHONY : clean sizes thisclean distclean tidy ltc-clean ltm-clean

200
201
202
203
204
205
206
207
208
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
209
210
211
clean: ltc-clean ltm-clean thisclean

thisclean:
212
213
	-rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \
			dropbearmulti *.o *.da *.bb *.bbg *.prof 
214
215

distclean: clean tidy
Matt Johnston's avatar
Matt Johnston committed
216
217
	-rm -f config.h
	-rm -f Makefile
218
219
220

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