arp(8): fixed typo (priveledge -> privilege)
[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 BASEDIR ?= $(DESTDIR)
75
76 # path to the net-lib support library. Default: lib
77 NET_LIB_PATH = lib
78 NET_LIB_NAME = net-tools
79
80 PROGS   := ifconfig hostname arp netstat route rarp slattach plipconfig nameif
81
82 -include config.make
83 ifeq ($(HAVE_IP_TOOLS),1)
84 PROGS   += iptunnel ipmaddr
85 endif
86 ifeq ($(HAVE_MII),1)
87 PROGS   += mii-tool
88 endif
89
90 # Compiler and Linker Options
91 # You may need to uncomment and edit these if you are using libc5 and IPv6.
92 CFLAGS ?= -O2 -g
93 CFLAGS += -Wall
94 CFLAGS += -fno-strict-aliasing # code needs a lot of work before strict aliasing is safe
95 CPPFLAGS += -D_GNU_SOURCE
96 RESLIB = # -L/usr/inet6/lib -linet6
97
98 ifeq ($(HAVE_AFDECnet),1)
99 DNLIB = -ldnet
100 endif
101
102 # -------- end of user definitions --------
103
104 MAINTAINER = Philip.Blundell@pobox.com
105 RELEASE    = 1.60
106
107 .EXPORT_ALL_VARIABLES:
108
109 ifeq ("$(NET_LIB_PATH)","lib2")
110 TOPDIR   = ..
111 else
112 TOPDIR  := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
113 endif
114
115 NET_LIB = $(NET_LIB_PATH)/lib$(NET_LIB_NAME).a
116
117 ifeq ($(HAVE_SELINUX),1)
118 LDFLAGS += -lselinux
119 CFLAGS += -DHAVE_SELINUX
120 endif
121
122 CPPFLAGS += -I. -I$(TOPDIR)/include -I$(NET_LIB_PATH)
123 LDFLAGS  += -L$(NET_LIB_PATH)
124
125 SUBDIRS = man/ $(NET_LIB_PATH)/
126
127 ifeq ($(origin CC), undefined)
128 CC      = gcc
129 endif
130 LD      = $(CC)
131
132 NLIB    = -l$(NET_LIB_NAME)
133
134 %.o:            %.c config.h version.h intl.h lib/net-features.h $<
135                 $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
136
137 all:            config.h version.h subdirs $(PROGS)
138
139 config:         cleanconfig config.h
140
141 install:        all savebin installbin installdata
142
143 update:         all installbin installdata
144
145 mostlyclean:
146                 rm -f *.o DEADJOE config.new *~ *.orig lib/*.o
147
148 clean: mostlyclean
149                 rm -f $(PROGS)
150                 @for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) ; done
151                 @cd po && $(MAKE) clean
152
153 cleanconfig:
154                 rm -f config.h
155
156 clobber:        clean
157                 rm -f $(PROGS) config.h version.h config.status config.make
158                 @for i in $(SUBDIRS); do (cd $$i && $(MAKE) clobber) ; done
159
160
161 dist:           clobber
162                 @$(MAKE) -C po $@
163                 @echo Creating net-tools-$(RELEASE) in ..
164                 @tar -cvz -f ../net-tools-$(RELEASE).tar.gz . \
165                         --transform='s,^[.],net-tools-$(RELEASE),' \
166                         --exclude=CVS --exclude=.cvsignore \
167                         --exclude='.git*'
168
169
170 config.h:       config.in Makefile 
171                 @echo "Configuring the Linux net-tools (NET-3 Base Utilities)..." ; echo
172                 @if [ config.status -nt config.in ]; \
173                         then ./configure.sh config.status; \
174                    else ./configure.sh config.in; \
175                  fi
176
177
178 version.h:      Makefile
179                 @echo "#define RELEASE \"net-tools $(RELEASE)\"" >version.h
180
181
182 $(NET_LIB):     config.h version.h intl.h libdir
183
184 i18n.h:         i18ndir
185
186 libdir:         version.h
187                 @$(MAKE) -C $(NET_LIB_PATH)
188
189 i18ndir:
190                 @$(MAKE) -C po
191
192 # use libdir target for lib/ to avoid parallel build issues
193 subdirs:        libdir
194                 @for i in $(SUBDIRS:$(NET_LIB_PATH)/=); do $(MAKE) -C $$i || exit $$? ; done
195
196 ifconfig:       $(NET_LIB) ifconfig.o
197                 $(CC) $(LDFLAGS) -o ifconfig ifconfig.o $(NLIB) $(RESLIB)
198                 
199 nameif: nameif.o
200                 $(CC) $(LDFLAGS) -o nameif nameif.o 
201
202 hostname:       hostname.o
203                 $(CC) $(LDFLAGS) -o hostname hostname.o $(DNLIB)
204
205 route:          $(NET_LIB) route.o
206                 $(CC) $(LDFLAGS) -o route route.o $(NLIB) $(RESLIB)
207
208 arp:            $(NET_LIB) arp.o
209                 $(CC) $(LDFLAGS) -o arp arp.o $(NLIB) $(RESLIB)
210
211 rarp:           $(NET_LIB) rarp.o
212                 $(CC) $(LDFLAGS) -o rarp rarp.o $(NLIB)
213
214 slattach:       $(NET_LIB) slattach.o
215                 $(CC) $(LDFLAGS) -o slattach slattach.o $(NLIB)
216
217 plipconfig:     $(NET_LIB) plipconfig.o
218                 $(CC) $(LDFLAGS) -o plipconfig plipconfig.o $(NLIB)
219
220 netstat:        $(NET_LIB) netstat.o statistics.o
221                 $(CC) $(LDFLAGS) -o netstat netstat.o statistics.o $(NLIB) $(RESLIB)
222
223 iptunnel:       $(NET_LIB) iptunnel.o
224                 $(CC) $(LDFLAGS) -o iptunnel iptunnel.o $(NLIB) $(RESLIB)
225
226 ipmaddr:        $(NET_LIB) ipmaddr.o
227                 $(CC) $(LDFLAGS) -o ipmaddr ipmaddr.o $(NLIB) $(RESLIB)
228
229 mii-tool:       mii-tool.o
230                 $(CC) $(LDFLAGS) -o mii-tool mii-tool.o
231
232 installbin:
233         @echo
234         @echo "######################################################"
235         @echo "Notice: ifconfig and route are now installed into /bin"
236         @echo "######################################################"
237         @echo
238         install -m 0755 -d ${BASEDIR}/sbin
239         install -m 0755 -d ${BASEDIR}/bin
240         install -m 0755 arp        ${BASEDIR}/sbin
241         install -m 0755 hostname   ${BASEDIR}/bin
242         install -m 0755 ifconfig   ${BASEDIR}/bin
243         install -m 0755 nameif     ${BASEDIR}/sbin
244         install -m 0755 netstat    ${BASEDIR}/bin
245         install -m 0755 plipconfig $(BASEDIR)/sbin
246         install -m 0755 rarp       ${BASEDIR}/sbin
247         install -m 0755 route      ${BASEDIR}/bin
248         install -m 0755 slattach   $(BASEDIR)/sbin
249 ifeq ($(HAVE_IP_TOOLS),1)
250         install -m 0755 ipmaddr    $(BASEDIR)/sbin
251         install -m 0755 iptunnel   $(BASEDIR)/sbin
252 endif
253 ifeq ($(HAVE_MII),1)
254         install -m 0755 mii-tool   $(BASEDIR)/sbin
255 endif
256         ln -fs hostname $(BASEDIR)/bin/dnsdomainname
257         ln -fs hostname $(BASEDIR)/bin/ypdomainname
258         ln -fs hostname $(BASEDIR)/bin/nisdomainname
259         ln -fs hostname $(BASEDIR)/bin/domainname
260 ifeq ($(HAVE_AFDECnet),1)
261         ln -fs hostname $(BASEDIR)/bin/nodename
262 endif
263
264 savebin:
265         @for i in ${BASEDIR}/sbin/arp ${BASEDIR}/sbin/ifconfig \
266                  ${BASEDIR}/bin/netstat \
267                  ${BASEDIR}/sbin/rarp ${BASEDIR}/sbin/route \
268                  ${BASEDIR}/bin/hostname ${BASEDIR}/bin/ypdomainname \
269                  ${BASEDIR}/bin/dnsdomainname ${BASEDIR}/bin/nisdomainname \
270                  ${BASEDIR}/bin/domainname ; do \
271                  [ -f $$i ] && cp -f $$i $$i.old ; done ; echo Saved.
272
273 installdata:
274         $(MAKE) -C man install
275         $(MAKE) -C po install
276
277 # End of Makefile.