Makefile.in 5.94 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
20
21
22
23
24
ifeq (@[email protected], 1)
LIBTOM_DEPS=$(LTC) $(LTM)
CFLAGS+=-I$(srcdir)/libtomcrypt/src/headers/ 
LIBS+=$(LTC) $(LTM)
endif

25
26
27
28
COMMONOBJS=dbutil.o buffer.o \
		dss.o bignum.o \
		signkey.o rsa.o random.o \
		queue.o \
29
		atomicio.o compat.o  fake-rfc2553.o 
30

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

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

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

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

CONVERTOBJS=dropbearconvert.o keyimport.o

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

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

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

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

68
69
70
71
72
73
74
75
76
77
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
78
CPPFLAGS=@[email protected]
79
CFLAGS+=-I. -I$(srcdir) $(CPPFLAGS) @[email protected]
80
LIBS+=@[email protected]
81
82
LDFLAGS=@[email protected]

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


96
97
98
99
100
# 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
101
102
103
ifeq ($(STATIC), 1)
	LDFLAGS+=-static
endif
104

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

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

116
all: $(TARGETS)
117

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

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

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

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

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

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

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

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


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

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

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


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

176
177
dropbearmulti: multilink 

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

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

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

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

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

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

195
196
197
198
199
200
201
202
203
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
204
205
206
clean: ltc-clean ltm-clean thisclean

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

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

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