netstat: fix %*s handling -- the field takes an int, not a size_t
[platform/upstream/net-tools.git] / Makefile
1 #
2 # Makefile      Main Makefile for the net-tools Package
3 #
4 # NET-TOOLS     A collection of programs that form the base set of the
5 #               NET-3 Networking Distribution for the LINUX operating
6 #               system.
7 #
8 # Version:      2001-02-13
9 #
10 # Author:       Bernd Eckenfels <net-tools@lina.inka.de>
11 #               Copyright 1995-1996 Bernd Eckenfels, Germany
12 #
13 # URLs:         ftp://ftp.inka.de/pub/comp/Linux/networking/NetTools/ 
14 #               ftp://ftp.linux.org.uk/pub/linux/Networking/PROGRAMS/NetTools/
15 #               http://www.inka.de/sites/lina/linux/NetTools/index_en.html
16 #
17 # Based on:     Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
18 #               Copyright 1988-1993 MicroWalt Corporation
19 #
20 # Modifications:
21 #               Extensively modified from 01/21/94 onwards by
22 #               Alan Cox <A.Cox@swansea.ac.uk>
23 #               Copyright 1993-1994 Swansea University Computer Society
24 #
25 # Be careful! 
26 # This Makefile doesn't describe complete dependencies for all include files.
27 # If you change include files you might need to do make clean. 
28 #
29 #       {1.20}  Bernd Eckenfels:        Even more modifications for the new 
30 #                                       package layout
31 #       {1.21}  Bernd Eckenfels:        Check if config.in is newer than 
32 #                                       config.status
33 #       {1.22}  Bernd Eckenfels:        Include ypdomainname and nisdomainame
34 #
35 #       1.3.50-BETA6 private Release
36 #                               
37 #960125 {1.23}  Bernd Eckenfels:        Peter Tobias' rewrite for 
38 #                                       makefile-based installation
39 #       1.3.50-BETA6a private Release
40 #
41 #960201 {1.24}  Bernd Eckenfels:        net-features.h added
42 #
43 #960201 1.3.50-BETA6b private Release
44 #
45 #960203 1.3.50-BETA6c private Release
46 #
47 #960204 1.3.50-BETA6d private Release
48 #
49 #960204 {1.25}  Bernd Eckenfels:        DISTRIBUTION added
50 #
51 #960205 1.3.50-BETA6e private Release
52 #
53 #960206 {1.26}  Bernd Eckenfels:        afrt.o removed (cleaner solution)
54 #
55 #960215 1.3.50-BETA6f Release
56 #
57 #960216 {1.30}  Bernd Eckenfels:        net-lib support
58 #960322 {1.31}  Bernd Eckenfels:        moveable netlib, TOPDIR
59 #960424 {1.32}  Bernd Eckenfels:        included the URLs in the Comment
60 #
61 #960514 1.31-alpha release
62 #
63 #960518 {1.33}  Bernd Eckenfels:        -I/usr/src/linux/include comment added
64 #
65 #       This program is free software; you can redistribute it
66 #       and/or  modify it under  the terms of  the GNU General
67 #       Public  License as  published  by  the  Free  Software
68 #       Foundation;  either  version 2 of the License, or  (at
69 #       your option) any later version.
70 #
71
72 # set the base of the Installation 
73 # BASEDIR = /mnt
74
75 # path to the net-lib support library. Default: lib
76 NET_LIB_PATH = lib
77 NET_LIB_NAME = net-tools
78
79 PROGS   := ifconfig hostname arp netstat route rarp slattach plipconfig nameif
80
81 -include config.make
82 ifeq ($(HAVE_IP_TOOLS),1)
83 PROGS   += iptunnel ipmaddr
84 endif
85 ifeq ($(HAVE_MII),1)
86 PROGS   += mii-tool
87 endif
88
89 # Compiler and Linker Options
90 # You may need to uncomment and edit these if you are using libc5 and IPv6.
91 CFLAGS ?= -O2 -g
92 CFLAGS += -Wall
93 CFLAGS += -fno-strict-aliasing # code needs a lot of work before strict aliasing is safe
94 CPPFLAGS += -D_GNU_SOURCE
95 RESLIB = # -L/usr/inet6/lib -linet6
96
97 ifeq ($(HAVE_AFDECnet),1)
98 DNLIB = -ldnet
99 endif
100
101 # -------- end of user definitions --------
102
103 MAINTAINER = Philip.Blundell@pobox.com
104 RELEASE    = 1.60
105
106 .EXPORT_ALL_VARIABLES:
107
108 ifeq ("$(NET_LIB_PATH)","lib2")
109 TOPDIR   = ..
110 else
111 TOPDIR  := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
112 endif
113
114 NET_LIB = $(NET_LIB_PATH)/lib$(NET_LIB_NAME).a
115
116 CPPFLAGS += -I. -I$(TOPDIR)/include -I$(NET_LIB_PATH)
117 LDFLAGS  += -L$(NET_LIB_PATH)
118
119 SUBDIRS = man/ $(NET_LIB_PATH)/
120
121 ifeq ($(origin CC), undefined)
122 CC      = gcc
123 endif
124 LD      = $(CC)
125
126 NLIB    = -l$(NET_LIB_NAME)
127
128 %.o:            %.c config.h version.h intl.h net-features.h $<
129                 $(CC) $(CFLAGS) -c $<
130
131 all:            config.h version.h subdirs $(PROGS)
132
133 config:         cleanconfig config.h
134
135 install:        all savebin installbin installdata
136
137 update:         all installbin installdata
138
139 mostlyclean:
140                 rm -f *.o DEADJOE config.new *~ *.orig lib/*.o
141
142 clean: mostlyclean
143                 rm -f $(PROGS)
144                 @for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) ; done
145                 @cd po && $(MAKE) clean
146
147 cleanconfig:
148                 rm -f config.h
149
150 clobber:        clean
151                 rm -f $(PROGS) config.h version.h config.status config.make
152                 @for i in $(SUBDIRS); do (cd $$i && $(MAKE) clobber) ; done
153
154
155 dist:           clobber
156                 @echo Creating net-tools-$(RELEASE) in ..
157                 @tar -cvz -f ../net-tools-$(RELEASE).tar.gz -C .. net-tools
158
159
160 config.h:       config.in Makefile 
161                 @echo "Configuring the Linux net-tools (NET-3 Base Utilities)..." ; echo
162                 @if [ config.status -nt config.in ]; \
163                         then ./configure.sh config.status; \
164                    else ./configure.sh config.in; \
165                  fi
166
167
168 version.h:      Makefile
169                 @echo "#define RELEASE \"net-tools $(RELEASE)\"" >version.h
170
171
172 $(NET_LIB):     config.h version.h intl.h libdir
173
174 i18n.h:         i18ndir
175
176 libdir:         version.h
177                 @$(MAKE) -C $(NET_LIB_PATH)
178
179 i18ndir:
180                 @$(MAKE) -C po
181
182 subdirs:
183                 @for i in $(SUBDIRS); do $(MAKE) -C $$i || exit $$? ; done
184
185 ifconfig:       $(NET_LIB) ifconfig.o
186                 $(CC) $(LDFLAGS) -o ifconfig ifconfig.o $(NLIB) $(RESLIB)
187                 
188 nameif: nameif.o
189                 $(CC) $(LDFLAGS) -o nameif nameif.o 
190
191 hostname:       hostname.o
192                 $(CC) $(LDFLAGS) -o hostname hostname.o $(DNLIB)
193
194 route:          $(NET_LIB) route.o
195                 $(CC) $(LDFLAGS) -o route route.o $(NLIB) $(RESLIB)
196
197 arp:            $(NET_LIB) arp.o
198                 $(CC) $(LDFLAGS) -o arp arp.o $(NLIB) $(RESLIB)
199
200 rarp:           $(NET_LIB) rarp.o
201                 $(CC) $(LDFLAGS) -o rarp rarp.o $(NLIB)
202
203 slattach:       $(NET_LIB) slattach.o
204                 $(CC) $(LDFLAGS) -o slattach slattach.o $(NLIB)
205
206 plipconfig:     $(NET_LIB) plipconfig.o
207                 $(CC) $(LDFLAGS) -o plipconfig plipconfig.o $(NLIB)
208
209 netstat:        $(NET_LIB) netstat.o statistics.o
210                 $(CC) $(LDFLAGS) -o netstat netstat.o statistics.o $(NLIB) $(RESLIB)
211
212 iptunnel:       $(NET_LIB) iptunnel.o
213                 $(CC) $(LDFLAGS) -o iptunnel iptunnel.o $(NLIB) $(RESLIB)
214
215 ipmaddr:        $(NET_LIB) ipmaddr.o
216                 $(CC) $(LDFLAGS) -o ipmaddr ipmaddr.o $(NLIB) $(RESLIB)
217
218 mii-tool:       mii-tool.o
219                 $(CC) $(LDFLAGS) -o mii-tool mii-tool.o
220
221 installbin:
222         install -m 0755 -d ${BASEDIR}/sbin
223         install -m 0755 -d ${BASEDIR}/bin
224         install -m 0755 arp        ${BASEDIR}/sbin
225         install -m 0755 hostname   ${BASEDIR}/bin
226         install -m 0755 ifconfig   ${BASEDIR}/sbin
227         install -m 0755 nameif     ${BASEDIR}/sbin
228         install -m 0755 netstat    ${BASEDIR}/bin
229         install -m 0755 plipconfig $(BASEDIR)/sbin
230         install -m 0755 rarp       ${BASEDIR}/sbin
231         install -m 0755 route      ${BASEDIR}/sbin
232         install -m 0755 slattach   $(BASEDIR)/sbin
233 ifeq ($(HAVE_IP_TOOLS),1)
234         install -m 0755 ipmaddr    $(BASEDIR)/sbin
235         install -m 0755 iptunnel   $(BASEDIR)/sbin
236 endif
237 ifeq ($(HAVE_MII),1)
238         install -m 0755 mii-tool   $(BASEDIR)/sbin
239 endif
240         ln -fs hostname $(BASEDIR)/bin/dnsdomainname
241         ln -fs hostname $(BASEDIR)/bin/ypdomainname
242         ln -fs hostname $(BASEDIR)/bin/nisdomainname
243         ln -fs hostname $(BASEDIR)/bin/domainname
244 ifeq ($(HAVE_AFDECnet),1)
245         ln -fs hostname $(BASEDIR)/bin/nodename
246 endif
247
248 savebin:
249         @for i in ${BASEDIR}/sbin/arp ${BASEDIR}/sbin/ifconfig \
250                  ${BASEDIR}/bin/netstat \
251                  ${BASEDIR}/sbin/rarp ${BASEDIR}/sbin/route \
252                  ${BASEDIR}/bin/hostname ${BASEDIR}/bin/ypdomainname \
253                  ${BASEDIR}/bin/dnsdomainname ${BASEDIR}/bin/nisdomainname \
254                  ${BASEDIR}/bin/domainname ; do \
255                  [ -f $$i ] && cp -f $$i $$i.old ; done ; echo Saved.
256
257 installdata:
258         $(MAKE) -C man install
259         $(MAKE) -C po install
260
261 # End of Makefile.