Makefile.in 5.8 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
prefix=@[email protected]
69
70
71
72
datarootdir = @[email protected]
bindir=@[email protected]
sbindir=@[email protected]
mandir=@[email protected]
73
74
75
76
77
78

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

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


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

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

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

117
all: $(TARGETS)
118

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

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

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

insdbmulti: dropbearmulti
127
128
	$(INSTALL) -d $(DESTDIR)$(bindir)
	$(INSTALL) dropbearmulti$(EXEEXT) $(DESTDIR)$(bindir)
129
130

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

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

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

147
inst_%: $*
148
149
150
151
	$(INSTALL) -d $(DESTDIR)$(bindir)
	$(INSTALL) $*$(EXEEXT) $(DESTDIR)$(bindir)
	$(INSTALL) -d $(DESTDIR)$(mandir)/man1
	$(INSTALL) -m 644 $*.1  $(DESTDIR)$(mandir)/man1/$*.1
152
153


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

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

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


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

175
176
dropbearmulti: multilink 

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

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

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

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

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

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

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

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

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

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