comparison Makefile.in @ 29:0fcf63e1cb01

Totally reworked Makefile.in Doesn't totally work, but getting there
author Matt Johnston <matt@ucc.asn.au>
date Tue, 27 Jul 2004 13:32:54 +0000
parents 469950e86d0f
children 223b0f5f8dce
comparison
equal deleted inserted replaced
28:45ee5ffd6ea0 29:0fcf63e1cb01
1 # This Makefile is for Dropbear SSH Server and Client
2
3 # invocation:
4 # make PROGRAMS="dropbear dbclient scp" MULTI=1 STATIC=1 SCPPROGRESS=1
5 #
6 # to make a single multiple statically linked binary "staticdropbearmulti",
7 # which includes dropbear, scp and dbclient functionality, and includes the
8 # progress-bar functionality in scp. Hopefully that seems intuitive.
9
10 # This makefile is quite evil.
11
12 ifndef PROGRAMS
13 PROGRAMS="dropbear dbclient dropbearkey dropbearmulti"
14 endif
15
1 LTC=libtomcrypt/libtomcrypt.a 16 LTC=libtomcrypt/libtomcrypt.a
2 LTM=libtommath/libtommath.a 17 LTM=libtommath/libtommath.a
3 18
4 COMMONOBJS=dbutil.o common-session.o common-packet.o common-algo.o buffer.o \ 19 COMMONOBJS=dbutil.o common-session.o packet.o common-algo.o buffer.o \
5 common-kex.o dss.o bignum.o \ 20 common-kex.o dss.o bignum.o \
6 signkey.o rsa.o random.o common-channel.o \ 21 signkey.o rsa.o random.o common-channel.o \
7 common-chansession.o queue.o termcodes.o \ 22 common-chansession.o queue.o termcodes.o \
8 loginrec.o atomicio.o svr-x11fwd.o tcpfwd-direct.o compat.o \ 23 loginrec.o atomicio.o tcpfwd-direct.o compat.o \
9 tcpfwd-remote.o listener.o process-packet.o common-runopts.o 24 tcpfwd-remote.o listener.o process-packet.o common-runopts.o
10 25
11 SVROBJS=svr-kex.o svr-algo.o svr-auth.o sshpty.o \ 26 SVROBJS=svr-kex.o svr-algo.o svr-auth.o sshpty.o \
12 svr-authpasswd.o svr-authpubkey.o svr-session.o svr-service.o \ 27 svr-authpasswd.o svr-authpubkey.o svr-session.o svr-service.o \
13 svr-chansession.o svr-runopts.o svr-agentfwd.o 28 svr-chansession.o svr-runopts.o svr-agentfwd.o svr-main.o svr-x11fwd.o
14 29
15 CLIOBJS= 30 CLIOBJS=cli-algo.o cli-main.o cli-auth.o cli-authpasswd.o cli-kex.o \
31 cli-session.o cli-service.o
16 32
17 OBJS=$(COMMONOBJS) $(SVROBJS) 33 DROPBEAROBJS=
18
19 DROPBEAROBJS=main.o
20 34
21 DROPBEARKEYOBJS=dropbearkey.o gendss.o genrsa.o 35 DROPBEARKEYOBJS=dropbearkey.o gendss.o genrsa.o
22 36
23 CONVERTOBJS=dropbearconvert.o keyimport.o 37 CONVERTOBJS=dropbearconvert.o keyimport.o
24 38
29 debug.h channel.h chansession.h config.h queue.h sshpty.h \ 43 debug.h channel.h chansession.h config.h queue.h sshpty.h \
30 termcodes.h gendss.h genrsa.h authpubkey.h runopts.h includes.h \ 44 termcodes.h gendss.h genrsa.h authpubkey.h runopts.h includes.h \
31 loginrec.h atomicio.h x11fwd.h agentfwd.h tcpfwd-direct.h compat.h \ 45 loginrec.h atomicio.h x11fwd.h agentfwd.h tcpfwd-direct.h compat.h \
32 tcpfwd-remote.h listener.h 46 tcpfwd-remote.h listener.h
33 47
34 ALLOBJS=$(OBJS) $(DROPBEARKEYOBJS) $(DROPBEAROBJS) 48 dropbearobjs=$(COMMONOBJS) $(SVROBJS)
49 dbclientobjs=$(COMMONOBJS) $(CLIOBJS)
50 dropbearkeyobjs=$(COMMONOBJS) $(KEYOBJS)
51 dropbearconvertobjs=$(COMMONOBJS) $(CONVERTOBJS)
52 scpobjs=$(SCPOBJS)
35 53
36 prefix=@prefix@ 54 prefix=@prefix@
37 exec_prefix=${prefix} 55 exec_prefix=${prefix}
38 bindir=${exec_prefix}/bin 56 bindir=${exec_prefix}/bin
39 sbindir=${exec_prefix}/sbin 57 sbindir=${exec_prefix}/sbin
42 LD=@CC@ 60 LD=@CC@
43 AR=@AR@ 61 AR=@AR@
44 RANLIB=@RANLIB@ 62 RANLIB=@RANLIB@
45 STRIP=@STRIP@ 63 STRIP=@STRIP@
46 INSTALL=@INSTALL@ 64 INSTALL=@INSTALL@
47 CFLAGS=-Ilibtomcrypt @CFLAGS@ 65 CFLAGS=@CFLAGS@
48 LIBS=$(LTC) $(LTM) @LIBS@ 66 LIBS=$(LTC) $(LTM) @LIBS@
49 LDFLAGS=@LDFLAGS@ 67 LDFLAGS=@LDFLAGS@
68
69 EXEEXT=@EXEEXT@
70
71 # whether we're building client, server, or both for the common objects.
72 space:= $(empty) $(empty)
73 CLISVRFLAGS=
74 # evilness so we detect 'dropbear' by itself as a word
75 ifneq (,$(findstring $(space)dropbear$(space), $(space)$(PROGRAMS)$(space)))
76 CLISVRFLAGS+= -DDROPBEAR_SERVER
77 endif
78 ifneq (,$(findstring $(space)dbclient$(space), $(space)$(PROGRAMS)$(space)))
79 CLISVRFLAGS+= -DDROPBEAR_CLIENT
80 endif
81
82 CFLAGS+=$(CLISVRFLAGS)
50 83
51 # these are exported so that libtomcrypt's makefile will use them 84 # these are exported so that libtomcrypt's makefile will use them
52 export CC 85 export CC
53 export CFLAGS 86 export CFLAGS
54 export RANLIB AR STRIP 87 export RANLIB AR STRIP
55 88
56 all: dropbear dropbearkey dropbearconvert 89 ifeq ($(STATIC), 1)
57 @echo 90 LDFLAGS+=-static
58 @echo Run \"make strip\" if you want stripped binaries, 91 SPREFIX=static
59 @echo or \"make install\" to install to ${prefix} 92 else
93 SPREFIX=
94 endif
60 95
61 strip: 96 ifeq ($(MULTI), 1)
62 -$(STRIP) dropbear 97 TARGETS=dropbearmulti
63 -$(STRIP) dropbearkey 98 else
64 -$(STRIP) dropbearconvert 99 TARGETS=$(PROGRAMS)
100 endif
65 101
66 install: all 102 # for the scp progress meter. The -D doesn't affect anything else.
67 $(INSTALL) -d -m 755 $(DESTDIR)$(sbindir) 103 ifeq ($(SCPPROGRESS), 1)
68 $(INSTALL) -d -m 755 $(DESTDIR)$(bindir) 104 CFLAGS+=-DPROGRESS_METER
69 $(INSTALL) -m 755 dropbear $(DESTDIR)$(sbindir) 105 endif
70 $(INSTALL) -m 755 dropbearkey $(DESTDIR)$(bindir) 106
71 $(INSTALL) -m 755 dropbearconvert $(DESTDIR)$(bindir) 107 #%: $(HEADERS)
72 # chown might fail, so do it separately to the install 108 #%: $(HEADERS) Makefile
73 -chown root $(DESTDIR)$(sbindir)/dropbear 109 # TODO
74 -chgrp 0 $(DESTDIR)$(sbindir)/dropbear
75 -chown root $(DESTDIR)$(bindir)/dropbearkey
76 -chgrp 0 $(DESTDIR)$(bindir)/dropbearkey
77 -chown root $(DESTDIR)$(bindir)/dropbearconvert
78 -chgrp 0 $(DESTDIR)$(bindir)/dropbearconvert
79 110
80 111
81 static: dropbear-static dropbearkey-static dropbearconvert-static 112 strip: $(TARGETS)
113 $(STRIP) $(foreach prog, $(TARGETS), $(SPREFIX)$(prog)$(EXEEXT))
82 114
83 $(ALLOBJS): $(HEADERS) Makefile
84 115
85 dropbear: $(DROPBEAROBJS) $(OBJS) $(HEADERS) Makefile $(LTC) $(LTM) 116 install: $(foreach prog, $(TARGETS), install$prog)
86 $(LD) $(LDFLAGS) -o dropbear $(DROPBEAROBJS) $(OBJS) $(LIBS)
87 117
88 dropbear-static: $(DROPBEAROBJS) $(OBJS) $(HEADERS) Makefile $(LTC) $(LTM) 118 # dropbear should go in sbin, so it needs a seperate rule
89 $(LD) $(LDFLAGS) -o staticdropbear $(DROPBEAROBJS) $(OBJS) $(LIBS) -static 119 installdropbear: dropbear
120 $(INSTALL) -d -m 755 $(DESTDIR)$(sbindir)
121 $(INSTALL) -m 755 $(SPREFIX)dropbear$(EXEEXT) $(DESTDIR)$(sbindir)
122 -chown root $(DESTDIR)$(sbindir)/$(SPREFIX)dropbear$(EXEEXT)
123 -chgrp 0 $(DESTDIR)$(sbindir)/$(SPREFIX)dropbear$(EXEEXT)
90 124
91 dropbearkey: $(OBJS) $(HEADERS) Makefile $(DROPBEARKEYOBJS) $(LTC) $(LTM) 125 install%: $*
92 $(LD) $(LDFLAGS) -o dropbearkey $(DROPBEARKEYOBJS) \ 126 $(INSTALL) -d -m 755 $(DESTDIR)$(bindir)
93 $(OBJS) $(LIBS) 127 $(INSTALL) -m 755 $(SPREFIX)$*$(EXEEXT) $(DESTDIR)$(bindir)
128 -chown root $(DESTDIR)$(sbindir)/$(SPREFIX)$*$(EXEEXT)
129 -chgrp 0 $(DESTDIR)$(sbindir)/$(SPREFIX)$*$(EXEEXT)
130 ifeq ($(MULTI), 1)
131 @echo "You must manually create links for $*"
132 endif
94 133
95 dropbearkey-static: $(OBJS) $(HEADERS) Makefile $(DROPBEARKEYOBJS) $(LTC) $(LTM)
96 $(LD) $(LDFLAGS) -o staticdropbearkey $(DROPBEARKEYOBJS) \
97 $(OBJS) $(LIBS) -static
98 134
99 dropbearconvert: $(OBJS) $(HEADERS) Makefile $(CONVERTOBJS) $(LTC) $(LTM)
100 $(LD) $(LDFLAGS) -o dropbearconvert $(CONVERTOBJS) $(OBJS) $(LIBS)
101 135
102 dropbearconvert-static: $(OBJS) $(HEADERS) Makefile $(CONVERTOBJS) $(LTC) $(LTM) 136 # The actual binaries
103 $(LD) $(LDFLAGS) -o staticdropbearconvert $(CONVERTOBJS) $(OBJS) $(LIBS) \ 137 dropbear: $(dropbearobjs)
104 -static
105 138
106 multi: dropbearmulti 139 dropbear dbclient dropbearkey dropbearconvert: $($($@objs)) $(HEADERS) \
140 $(LTC) $(LTM)
141 @echo $(CLISVRFLAGS)
142 $(LD) $(LDFLAGS) -o $(SPREFIX)$@$(EXEEXT) $($@objs) $(LIBS)
107 143
108 dropbearmulti: $(HEADERS) $(OBJS) $(LTC) $(LTM) $(CONVERTOBJS) \ 144
109 $(DROPBEARKEYOBJS) $(DROPBEAROBJS) dbmulti.o 145 # scp doesn't use the libs so is special.
110 $(LD) $(LDFLAGS) -o dropbearmulti $(OBJS) $(LTM) $(LTM) $(CONVERTOBJS) \ 146 scp: $(SCPOBJS) $(HEADERS)
111 $(DROPBEARKEYOBJS) $(DROPBEAROBJS) dbmulti.o $(LIBS) 147 $(LD) $(LDFLAGS) -o $(SPREFIX)$@$(EXEEXT) $(SCPOBJS)
148
149
150 MULTIOBJS=dbmulti.o
151 ifeq ($(MULTI),1)
152 deftarget=multi
153 MULTIOBJS=$(foreach prog, $(PROGRAMS), $($(prog)objs))
154 endif
155
156 dropbearmulti: $(HEADERS) $(MULTIOBJS) $(LTC) $(LTM)
157 $(LD) $(LDFLAGS) -o $(SPREFIX)$@$(EXEEXT) $(MULTIOBJS) $(LIBS)
112 @echo "You should now create symlinks to the programs you have included" 158 @echo "You should now create symlinks to the programs you have included"
113 @echo "ie 'ln -s dropbearmulti dropbear'" 159 @echo "ie 'ln -s dropbearmulti dropbear'"
114
115 dropbearmultistatic: $(HEADERS) $(OBJS) $(LTC) $(LTM) $(CONVERTOBJS) \
116 $(DROPBEARKEYOBJS) $(DROPBEAROBJS) dbmulti.o
117 $(LD) $(LDFLAGS) -o staticdropbearmulti $(OBJS) $(LTM) $(LTM) \
118 $(CONVERTOBJS) $(DROPBEARKEYOBJS) $(DROPBEAROBJS) \
119 dbmulti.o $(LIBS) -static
120 @echo "You should now create symlinks to the programs you have included"
121 @echo "ie 'ln -s dropbearmultistatic dropbear'"
122
123 stripmulti: dropbearmulti
124 -$(STRIP) dropbearmulti
125
126
127 scp: $(SCPOBJS) Makefile
128 $(LD) $(LDFLAGS) -o $@ $(SCPOBJS)
129
130 # gnumake before 3.80 is broken. So this is uglyish
131 scp-progress: atomicio.o scpmisc.o $(HEADERS) Makefile
132 -rm scp.o progressmeter.o
133 $(MAKE) CFLAGS="$(CFLAGS) -DPROGRESS_METER" scp.o progressmeter.o
134 $(LD) $(LDFLAGS) -o $@ $(SCPOBJS)
135
136 scpstatic: $(SCPOBJS) $(HEADERS) Makefile
137 $(LD) $(LDFLAGS) -o $@ $(SCPOBJS) -static
138 160
139 $(LTC): $(HEADERS) 161 $(LTC): $(HEADERS)
140 cd libtomcrypt && $(MAKE) clean && $(MAKE) 162 cd libtomcrypt && $(MAKE) clean && $(MAKE)
141 163
142 $(LTM): $(HEADERS) 164 $(LTM): $(HEADERS)
150 172
151 sizes: dropbear 173 sizes: dropbear
152 objdump -t dropbear|grep ".text"|cut -d "." -f 2|sort -rn 174 objdump -t dropbear|grep ".text"|cut -d "." -f 2|sort -rn
153 175
154 clean: ltc-clean ltm-clean 176 clean: ltc-clean ltm-clean
155 -rm -f dropbear dropbear dropbearkey staticdropbear staticdropbearkey 177 -rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress
156 -rm -f dropbearconvert staticdropbearconvert scp scp-progress scpstatic 178 -rm -f staticdropbear staticdropbearkey staticdropbearconvert staticscp
157 -rm -f dropbearmulti dropbearmultistatic 179 -rm -f dropbearmulti staticdropbearmulti
158 -rm -f *.o *.da *.bb *.bbg *.prof 180 -rm -f *.o *.da *.bb *.bbg *.prof
159 181
160 distclean: clean tidy 182 distclean: clean tidy
161 -rm -f Makefile config.h 183 -rm -f config.h
184 -rm -f Makefile
162 185
163 tidy: 186 tidy:
164 -rm -f *~ *.gcov */*~ 187 -rm -f *~ *.gcov */*~