Makefile.in 6.76 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
29
30
ifneq ($(wildcard localoptions.h),)
CFLAGS+=-DLOCALOPTIONS_H_EXISTS
endif

31
COMMONOBJS=dbutil.o buffer.o dbhelpers.o \
32
		dss.o bignum.o \
33
		signkey.o rsa.o dbrandom.o \
34
		queue.o \
Matt Johnston's avatar
Matt Johnston committed
35
		atomicio.o compat.o fake-rfc2553.o \
36
37
		ltc_prng.o ecc.o ecdsa.o crypto_desc.o \
		gensignkey.o gendss.o genrsa.o
38

39
SVROBJS=svr-kex.o svr-auth.o sshpty.o \
40
		svr-authpasswd.o svr-authpubkey.o svr-authpubkeyoptions.o svr-session.o svr-service.o \
Matt Johnston's avatar
Matt Johnston committed
41
		svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o\
42
		svr-tcpfwd.o svr-authpam.o
43

44
CLIOBJS=cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
45
		cli-session.o cli-runopts.o cli-chansession.o \
46
		cli-authpubkey.o cli-tcpfwd.o cli-channel.o cli-authinteract.o \
47
		cli-agentfwd.o 
48

49
50
CLISVROBJS=common-session.o packet.o common-algo.o common-kex.o \
			common-channel.o common-chansession.o termcodes.o loginrec.o \
51
			tcp-accept.o listener.o process-packet.o dh_groups.o \
52
			common-runopts.o circbuffer.o curve25519-donna.o list.o netio.o
53

54
KEYOBJS=dropbearkey.o
55
56
57

CONVERTOBJS=dropbearconvert.o keyimport.o

58
SCPOBJS=scp.o progressmeter.o atomicio.o scpmisc.o compat.o
59
60

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

67
dropbearobjs=$(COMMONOBJS) $(CLISVROBJS) $(SVROBJS)
68
dbclientobjs=$(COMMONOBJS) $(CLISVROBJS) $(CLIOBJS)
Matt Johnston's avatar
Matt Johnston committed
69
70
71
dropbearkeyobjs=$(COMMONOBJS) $(KEYOBJS)
dropbearconvertobjs=$(COMMONOBJS) $(CONVERTOBJS)
scpobjs=$(SCPOBJS)
72

Matt Johnston's avatar
Matt Johnston committed
73
74
75
VPATH=@[email protected]
srcdir=@[email protected]

76
prefix=@[email protected]
77
exec_prefix=@[email protected]
78
79
80
81
datarootdir = @[email protected]
bindir=@[email protected]
sbindir=@[email protected]
mandir=@[email protected]
82

83
84
.DELETE_ON_ERROR:

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

Matt Johnston's avatar
Matt Johnston committed
95
96
97
98
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
99
100
101
space:= $(empty) $(empty)
ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdropbearZ, Z$(prog)Z))))
	CFLAGS+= -DDROPBEAR_SERVER
Matt Johnston's avatar
Matt Johnston committed
102
endif
103
104
ifneq (,$(strip $(foreach prog, $(PROGRAMS), $(findstring ZdbclientZ, Z$(prog)Z))))
	CFLAGS+= -DDROPBEAR_CLIENT
Matt Johnston's avatar
Matt Johnston committed
105
106
107
endif


108
109
110
111
112
# 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
113
114
115
ifeq ($(STATIC), 1)
	LDFLAGS+=-static
endif
116

Matt Johnston's avatar
Matt Johnston committed
117
118
119
120
121
ifeq ($(MULTI), 1)
	TARGETS=dropbearmulti
else
	TARGETS=$(PROGRAMS)
endif
122

Matt Johnston's avatar
Matt Johnston committed
123
124
125
126
# for the scp progress meter. The -D doesn't affect anything else.
ifeq ($(SCPPROGRESS), 1)
	CFLAGS+=-DPROGRESS_METER
endif
127

128
all: $(TARGETS)
129

130
strip: $(TARGETS)
131
	$(STRIP) $(addsuffix $(EXEEXT), $(TARGETS))
132

133
install: $(addprefix inst_, $(TARGETS))
134
135

insmultidropbear: dropbearmulti
136
	$(INSTALL) -d $(DESTDIR)$(sbindir)
137
	-rm -f $(DESTDIR)$(sbindir)/dropbear$(EXEEXT)
138
	-ln -s $(bindir)/dropbearmulti$(EXEEXT) $(DESTDIR)$(sbindir)/dropbear$(EXEEXT) 
139
	$(INSTALL) -d $(DESTDIR)$(mandir)/man8
140
	$(INSTALL) -m 644 $(srcdir)/dropbear.8  $(DESTDIR)$(mandir)/man8/dropbear.8
141
142

insmulti%: dropbearmulti
143
	$(INSTALL) -d $(DESTDIR)$(bindir)
144
	-rm -f $(DESTDIR)$(bindir)/$*$(EXEEXT) 
145
	-ln -s $(bindir)/dropbearmulti$(EXEEXT) $(DESTDIR)$(bindir)/$*$(EXEEXT) 
146
	$(INSTALL) -d $(DESTDIR)$(mandir)/man1
147
	if test -e $*.1; then $(INSTALL) -m 644 $*.1 $(DESTDIR)$(mandir)/man1/$*.1; fi
148

149
# dropbear should go in sbin, so it needs a separate rule
150
inst_dropbear: dropbear
151
152
153
	$(INSTALL) -d $(DESTDIR)$(sbindir)
	$(INSTALL) dropbear$(EXEEXT) $(DESTDIR)$(sbindir)
	$(INSTALL) -d $(DESTDIR)$(mandir)/man8
154
	$(INSTALL) -m 644 $(srcdir)/dropbear.8 $(DESTDIR)$(mandir)/man8/dropbear.8
155

156
inst_%: %
157
158
159
	$(INSTALL) -d $(DESTDIR)$(bindir)
	$(INSTALL) $*$(EXEEXT) $(DESTDIR)$(bindir)
	$(INSTALL) -d $(DESTDIR)$(mandir)/man1
160
161
162
	if test -e $*.1; then $(INSTALL) -m 644 $*.1 $(DESTDIR)$(mandir)/man1/$*.1; fi

inst_dropbearmulti: $(addprefix insmulti, $(PROGRAMS)) 
163

164
# for some reason the rule further down doesn't like $([email protected]) as a prereq.
Matt Johnston's avatar
Matt Johnston committed
165
dropbear: $(dropbearobjs)
166
167
168
dbclient: $(dbclientobjs)
dropbearkey: $(dropbearkeyobjs)
dropbearconvert: $(dropbearconvertobjs)
169

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

dbclient: $(HEADERS) $(LIBTOM_DEPS) Makefile
174
175
176
177
	$(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)
178

Matt Johnston's avatar
Matt Johnston committed
179
# scp doesn't use the libs so is special.
Matt Johnston's avatar
Matt Johnston committed
180
scp: $(SCPOBJS)  $(HEADERS) Makefile
181
	$(CC) $(LDFLAGS) -o [email protected]$(EXEEXT) $(SCPOBJS)
182
183


184
185
# multi-binary compilation.
MULTIOBJS=
Matt Johnston's avatar
Matt Johnston committed
186
ifeq ($(MULTI),1)
187
	MULTIOBJS=dbmulti.o $(sort $(foreach prog, $(PROGRAMS), $($(prog)objs)))
188
	CFLAGS+=$(addprefix -DDBMULTI_, $(PROGRAMS)) -DDROPBEAR_MULTI
Matt Johnston's avatar
Matt Johnston committed
189
endif
190

191
dropbearmulti$(EXEEXT): $(HEADERS) $(MULTIOBJS) $(LIBTOM_DEPS) Makefile
192
	$(CC) $(LDFLAGS) -o [email protected] $(MULTIOBJS) $(LIBTOM_LIBS) $(LIBS) @[email protected]
193

194
multibinary: dropbearmulti$(EXEEXT)
195
196
197
198

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

link%:
199
200
	-rm -f $*$(EXEEXT)
	-ln -s dropbearmulti$(EXEEXT) $*$(EXEEXT)
201

202
203
$(STATIC_LTC): options.h
	$(MAKE) -C libtomcrypt
204

205
206
$(STATIC_LTM): options.h
	$(MAKE) -C libtommath
207

208
209
.PHONY : clean sizes thisclean distclean tidy ltc-clean ltm-clean

210
ltc-clean:
211
	$(MAKE) -C libtomcrypt clean
212
213

ltm-clean:
214
	$(MAKE) -C libtommath clean
215
216
217
218

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

Matt Johnston's avatar
Matt Johnston committed
219
220
221
clean: ltc-clean ltm-clean thisclean

thisclean:
222
	-rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \
223
			dropbearmulti *.o *.da *.bb *.bbg *.prof
224
225

distclean: clean tidy
Matt Johnston's avatar
Matt Johnston committed
226
227
	-rm -f config.h
	-rm -f Makefile
228
229
230

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

232
233
# default_options.h is stored in version control, could not find a workaround
# for parallel "make -j" and dependency rules.
234
default_options.h: default_options.h.in 
235
236
237
238
	echo "# > > > Generated from $^, edit that file instead !" > [email protected].tmp
	echo >> [email protected].tmp
	$(srcdir)/ifndef_wrapper.sh < $^ > [email protected].tmp
	mv [email protected].tmp [email protected]