Makefile.in 5.88 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
COMMONOBJS=dbutil.o buffer.o \
		dss.o bignum.o \
		signkey.o rsa.o random.o \
		queue.o \
23
		atomicio.o compat.o  fake-rfc2553.o 
24

Matt Johnston's avatar
Matt Johnston committed
25
SVROBJS=svr-kex.o svr-algo.o svr-auth.o sshpty.o \
26
		svr-authpasswd.o svr-authpubkey.o svr-authpubkeyoptions.o svr-session.o svr-service.o \
Matt Johnston's avatar
Matt Johnston committed
27
		svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o\
28
		svr-tcpfwd.o svr-authpam.o @[email protected]
29

Matt Johnston's avatar
Matt Johnston committed
30
CLIOBJS=cli-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
Matt Johnston's avatar
Matt Johnston committed
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
		cli-agentfwd.o list.o
34

35
36
CLISVROBJS=common-session.o packet.o common-algo.o common-kex.o \
			common-channel.o common-chansession.o termcodes.o loginrec.o \
37
			tcp-accept.o listener.o process-packet.o \
Matt Johnston's avatar
Nasty.    
Matt Johnston committed
38
			common-runopts.o circbuffer.o
39

40
KEYOBJS=dropbearkey.o gendss.o genrsa.o
41
42
43
44
45
46

CONVERTOBJS=dropbearconvert.o keyimport.o

SCPOBJS=scp.o progressmeter.o atomicio.o scpmisc.o

HEADERS=options.h dbutil.h session.h packet.h algo.h ssh.h buffer.h kex.h \
Matt Johnston's avatar
Matt Johnston committed
47
		dss.h bignum.h signkey.h rsa.h random.h service.h auth.h \
Matt Johnston's avatar
Matt Johnston committed
48
		debug.h channel.h chansession.h config.h queue.h sshpty.h \
Matt Johnston's avatar
Matt Johnston committed
49
		termcodes.h gendss.h genrsa.h runopts.h includes.h \
Matt Johnston's avatar
Matt Johnston committed
50
		loginrec.h atomicio.h x11fwd.h agentfwd.h tcpfwd.h compat.h \
Matt Johnston's avatar
Matt Johnston committed
51
		listener.h fake-rfc2553.h
52

53
54
dropbearobjs=$(COMMONOBJS) $(CLISVROBJS) $(SVROBJS) 
dbclientobjs=$(COMMONOBJS) $(CLISVROBJS) $(CLIOBJS)
Matt Johnston's avatar
Matt Johnston committed
55
56
57
dropbearkeyobjs=$(COMMONOBJS) $(KEYOBJS)
dropbearconvertobjs=$(COMMONOBJS) $(CONVERTOBJS)
scpobjs=$(SCPOBJS)
58

Matt Johnston's avatar
Matt Johnston committed
59
60
61
VPATH=@[email protected]
srcdir=@[email protected]

62
63
64
65
66
67
68
69
70
71
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
72
CPPFLAGS=@[email protected]
73
CFLAGS=-I. -I$(srcdir) -I$(srcdir)/libtomcrypt/src/headers/ $(CPPFLAGS) @[email protected]
74
75
76
LIBS=$(LTC) $(LTM) @[email protected]
LDFLAGS=@[email protected]

Matt Johnston's avatar
Matt Johnston committed
77
78
79
80
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
81
82
83
space:= $(empty) $(empty)
ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdropbearZ, Z$(prog)Z))))
	CFLAGS+= -DDROPBEAR_SERVER
Matt Johnston's avatar
Matt Johnston committed
84
endif
85
86
ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdbclientZ, Z$(prog)Z))))
	CFLAGS+= -DDROPBEAR_CLIENT
Matt Johnston's avatar
Matt Johnston committed
87
88
89
endif


90
91
92
93
94
# 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
95
96
97
ifeq ($(STATIC), 1)
	LDFLAGS+=-static
endif
98

Matt Johnston's avatar
Matt Johnston committed
99
100
101
102
103
ifeq ($(MULTI), 1)
	TARGETS=dropbearmulti
else
	TARGETS=$(PROGRAMS)
endif
104

Matt Johnston's avatar
Matt Johnston committed
105
106
107
108
# for the scp progress meter. The -D doesn't affect anything else.
ifeq ($(SCPPROGRESS), 1)
	CFLAGS+=-DPROGRESS_METER
endif
109

Matt Johnston's avatar
Matt Johnston committed
110
111
112
#%: $(HEADERS)
#%: $(HEADERS) Makefile
# TODO
113

114
all: $(TARGETS)
115

116
strip: $(TARGETS)
117
	$(STRIP) $(addsuffix $(EXEEXT), $(TARGETS))
118

119
install: $(addprefix inst_, $(TARGETS))
120
121
122
123
124

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

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

insmultidropbear: dropbearmulti
130
131
	-rm -f $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
	-ln -s $(DESTDIR)$(bindir)/dropbearmulti$(EXEEXT) $(DESTDIR)$(sbindir)/dropbear$(EXEEXT) 
132
133

insmulti%: dropbearmulti
134
135
	-rm -f $(DESTDIR)$(bindir)/$*$(EXEEXT) 
	-ln -s $(DESTDIR)$(bindir)/dropbearmulti$(EXEEXT) $(DESTDIR)$(bindir)/$*$(EXEEXT) 
136

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

144
inst_%: $*
Matt Johnston's avatar
Matt Johnston committed
145
	$(INSTALL) -d -m 755 $(DESTDIR)$(bindir)
146
147
148
	$(INSTALL) -m 755 $*$(EXEEXT) $(DESTDIR)$(bindir)
	-chown root $(DESTDIR)$(bindir)/$*$(EXEEXT)
	-chgrp 0 $(DESTDIR)$(bindir)/$*$(EXEEXT)
149
150


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

Matt Johnston's avatar
Matt Johnston committed
157
158
dropbear dbclient dropbearkey dropbearconvert: $(HEADERS)  $(LTC) $(LTM) \
													Makefile
159
	$(CC) $(LDFLAGS) -o [email protected]$(EXEEXT) $([email protected]objs) $(LIBS)
160

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


166
167
# multi-binary compilation.
MULTIOBJS=
Matt Johnston's avatar
Matt Johnston committed
168
ifeq ($(MULTI),1)
169
170
	MULTIOBJS=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs)))
	CFLAGS+=$(addprefix -DDBMULTI_, $(PROGRAMS)) -DDROPBEAR_MULTI
Matt Johnston's avatar
Matt Johnston committed
171
endif
172

173
174
175
dropbearmulti: multilink 

multibinary: $(HEADERS) $(MULTIOBJS) $(LTC) $(LTM) Makefile
176
	$(CC) $(LDFLAGS) -o dropbearmulti$(EXEEXT) $(MULTIOBJS) $(LIBS)
177
178
179
180

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

link%:
181
182
	-rm -f $*$(EXEEXT)
	-ln -s dropbearmulti$(EXEEXT) $*$(EXEEXT)
183

Matt Johnston's avatar
Matt Johnston committed
184
$(LTC): options.h
185
186
	cd libtomcrypt && $(MAKE) clean && $(MAKE)

Matt Johnston's avatar
Matt Johnston committed
187
$(LTM): options.h
188
189
	cd libtommath && $(MAKE)

190
191
.PHONY : clean sizes thisclean distclean tidy ltc-clean ltm-clean

192
193
194
195
196
197
198
199
200
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
201
202
203
clean: ltc-clean ltm-clean thisclean

thisclean:
204
205
	-rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \
			dropbearmulti *.o *.da *.bb *.bbg *.prof 
206
207

distclean: clean tidy
Matt Johnston's avatar
Matt Johnston committed
208
209
	-rm -f config.h
	-rm -f Makefile
210
211
212

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