Makefile 7.13 KB
Newer Older
Phil Blundell's avatar
Phil Blundell committed
1 2 3 4 5 6 7
#
# Makefile	Main Makefile for the net-tools Package
#
# NET-TOOLS	A collection of programs that form the base set of the
#		NET-3 Networking Distribution for the LINUX operating
#		system.
#
8
# Version:	2001-02-13
Phil Blundell's avatar
Phil Blundell committed
9 10
#
# Author:	Bernd Eckenfels <net-tools@lina.inka.de>
11
#		Copyright 1995-1996 Bernd Eckenfels, Germany
Phil Blundell's avatar
Phil Blundell committed
12 13 14 15 16 17 18 19 20 21 22 23
#
# URLs:		ftp://ftp.inka.de/pub/comp/Linux/networking/NetTools/ 
#		ftp://ftp.linux.org.uk/pub/linux/Networking/PROGRAMS/NetTools/
#		http://www.inka.de/sites/lina/linux/NetTools/index_en.html
#
# Based on:	Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
#		Copyright 1988-1993 MicroWalt Corporation
#
# Modifications:
#		Extensively modified from 01/21/94 onwards by
#		Alan Cox <A.Cox@swansea.ac.uk>
#		Copyright 1993-1994 Swansea University Computer Society
24 25 26 27
#
# Be careful! 
# This Makefile doesn't describe complete dependencies for all include files.
# If you change include files you might need to do make clean. 
Phil Blundell's avatar
Phil Blundell committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
#
#	{1.20}	Bernd Eckenfels:	Even more modifications for the new 
#					package layout
#	{1.21}	Bernd Eckenfels:	Check if config.in is newer than 
#					config.status
#	{1.22}  Bernd Eckenfels:	Include ypdomainname and nisdomainame
#
#	1.3.50-BETA6 private Release
#				
#960125	{1.23}	Bernd Eckenfels:	Peter Tobias' rewrite for 
#					makefile-based installation
#	1.3.50-BETA6a private Release
#
#960201 {1.24}	Bernd Eckenfels:	net-features.h added
#
#960201 1.3.50-BETA6b private Release
#
#960203 1.3.50-BETA6c private Release
#
#960204 1.3.50-BETA6d private Release
#
#960204 {1.25}	Bernd Eckenfels:	DISTRIBUTION added
#
#960205 1.3.50-BETA6e private Release
#
#960206	{1.26}	Bernd Eckenfels:	afrt.o removed (cleaner solution)
#
#960215 1.3.50-BETA6f Release
#
#960216 {1.30}	Bernd Eckenfels:	net-lib support
#960322 {1.31}	Bernd Eckenfels:	moveable netlib, TOPDIR
#960424 {1.32}	Bernd Eckenfels:	included the URLs in the Comment
#
#960514 1.31-alpha release
#
#960518 {1.33}	Bernd Eckenfels:	-I/usr/src/linux/include comment added
#
#	This program is free software; you can redistribute it
#	and/or  modify it under  the terms of  the GNU General
#	Public  License as  published  by  the  Free  Software
#	Foundation;  either  version 2 of the License, or  (at
#	your option) any later version.
#

# set the base of the Installation 
# BASEDIR = /mnt
74
BASEDIR ?= $(DESTDIR)
Phil Blundell's avatar
Phil Blundell committed
75 76

# path to the net-lib support library. Default: lib
77 78
NET_LIB_PATH = lib
NET_LIB_NAME = net-tools
Phil Blundell's avatar
Phil Blundell committed
79

80
PROGS	:= ifconfig hostname arp netstat route rarp slattach plipconfig nameif
81 82 83 84 85

-include config.make
ifeq ($(HAVE_IP_TOOLS),1)
PROGS   += iptunnel ipmaddr
endif
86 87 88
ifeq ($(HAVE_MII),1)
PROGS	+= mii-tool
endif
Phil Blundell's avatar
Phil Blundell committed
89 90

# Compiler and Linker Options
91
# You may need to uncomment and edit these if you are using libc5 and IPv6.
92 93
CFLAGS ?= -O2 -g
CFLAGS += -Wall
94
CFLAGS += -fno-strict-aliasing # code needs a lot of work before strict aliasing is safe
95
CPPFLAGS += -D_GNU_SOURCE
Phil Blundell's avatar
Phil Blundell committed
96 97
RESLIB = # -L/usr/inet6/lib -linet6

98 99 100 101
ifeq ($(HAVE_AFDECnet),1)
DNLIB = -ldnet
endif

Phil Blundell's avatar
Phil Blundell committed
102 103 104
# -------- end of user definitions --------

MAINTAINER = Philip.Blundell@pobox.com
Phil Blundell's avatar
Phil Blundell committed
105
RELEASE	   = 1.60
Phil Blundell's avatar
Phil Blundell committed
106 107 108

.EXPORT_ALL_VARIABLES:

109
ifeq ("$(NET_LIB_PATH)","lib2")
Phil Blundell's avatar
Phil Blundell committed
110 111 112 113 114
TOPDIR   = ..
else
TOPDIR  := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
endif

115
NET_LIB = $(NET_LIB_PATH)/lib$(NET_LIB_NAME).a
Phil Blundell's avatar
Phil Blundell committed
116

117
CPPFLAGS += -I. -I$(TOPDIR)/include -I$(NET_LIB_PATH)
118
LDFLAGS  += -L$(NET_LIB_PATH)
Phil Blundell's avatar
Phil Blundell committed
119

120
SUBDIRS	= man/ $(NET_LIB_PATH)/
Phil Blundell's avatar
Phil Blundell committed
121

122
ifeq ($(origin CC), undefined)
Phil Blundell's avatar
Phil Blundell committed
123
CC	= gcc
124 125
endif
LD	= $(CC)
Phil Blundell's avatar
Phil Blundell committed
126

127
NLIB	= -l$(NET_LIB_NAME)
Phil Blundell's avatar
Phil Blundell committed
128

129 130
%.o:		%.c config.h version.h intl.h lib/net-features.h $<
		$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
Phil Blundell's avatar
Phil Blundell committed
131 132 133 134 135 136 137 138 139

all:		config.h version.h subdirs $(PROGS)

config: 	cleanconfig config.h

install:	all savebin installbin installdata

update: 	all installbin installdata

140
mostlyclean:
Phil Blundell's avatar
Phil Blundell committed
141
		rm -f *.o DEADJOE config.new *~ *.orig lib/*.o
142 143 144

clean: mostlyclean
		rm -f $(PROGS)
145 146
		@for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) ; done
		@cd po && $(MAKE) clean
Phil Blundell's avatar
Phil Blundell committed
147 148 149 150 151

cleanconfig:
		rm -f config.h

clobber: 	clean
152
		rm -f $(PROGS) config.h version.h config.status config.make
153
		@for i in $(SUBDIRS); do (cd $$i && $(MAKE) clobber) ; done
Phil Blundell's avatar
Phil Blundell committed
154 155 156


dist: 		clobber
157
		@$(MAKE) -C po $@
Phil Blundell's avatar
Phil Blundell committed
158
		@echo Creating net-tools-$(RELEASE) in ..
159 160 161 162
		@tar -cvz -f ../net-tools-$(RELEASE).tar.gz . \
			--transform='s,^[.],net-tools-$(RELEASE),' \
			--exclude=CVS --exclude=.cvsignore \
			--exclude='.git*'
Phil Blundell's avatar
Phil Blundell committed
163 164 165 166 167


config.h: 	config.in Makefile 
		@echo "Configuring the Linux net-tools (NET-3 Base Utilities)..." ; echo
		@if [ config.status -nt config.in ]; \
168 169
			then ./configure.sh config.status; \
		   else ./configure.sh config.in; \
Phil Blundell's avatar
Phil Blundell committed
170 171 172 173 174 175 176
		 fi


version.h:	Makefile
		@echo "#define RELEASE \"net-tools $(RELEASE)\"" >version.h


177
$(NET_LIB):	config.h version.h intl.h libdir
Phil Blundell's avatar
Phil Blundell committed
178

179
i18n.h:		i18ndir
Phil Blundell's avatar
Phil Blundell committed
180

181
libdir:		version.h
182
		@$(MAKE) -C $(NET_LIB_PATH)
Phil Blundell's avatar
Phil Blundell committed
183

184 185
i18ndir:
		@$(MAKE) -C po
Phil Blundell's avatar
Phil Blundell committed
186

187 188 189
# use libdir target for lib/ to avoid parallel build issues
subdirs:	libdir
		@for i in $(SUBDIRS:$(NET_LIB_PATH)/=); do $(MAKE) -C $$i || exit $$? ; done
Phil Blundell's avatar
Phil Blundell committed
190

191
ifconfig:	$(NET_LIB) ifconfig.o
192
		$(CC) $(LDFLAGS) -o ifconfig ifconfig.o $(NLIB) $(RESLIB)
193 194 195
		
nameif:	nameif.o
		$(CC) $(LDFLAGS) -o nameif nameif.o 
Phil Blundell's avatar
Phil Blundell committed
196 197

hostname:	hostname.o
198
		$(CC) $(LDFLAGS) -o hostname hostname.o $(DNLIB)
Phil Blundell's avatar
Phil Blundell committed
199

200
route:		$(NET_LIB) route.o
Phil Blundell's avatar
Phil Blundell committed
201 202
		$(CC) $(LDFLAGS) -o route route.o $(NLIB) $(RESLIB)

203
arp:		$(NET_LIB) arp.o
Phil Blundell's avatar
Phil Blundell committed
204 205
		$(CC) $(LDFLAGS) -o arp arp.o $(NLIB) $(RESLIB)

206
rarp:		$(NET_LIB) rarp.o
Phil Blundell's avatar
Phil Blundell committed
207 208
		$(CC) $(LDFLAGS) -o rarp rarp.o $(NLIB)

209
slattach:	$(NET_LIB) slattach.o
210 211
		$(CC) $(LDFLAGS) -o slattach slattach.o $(NLIB)

212
plipconfig:	$(NET_LIB) plipconfig.o
213 214
		$(CC) $(LDFLAGS) -o plipconfig plipconfig.o $(NLIB)

215
netstat:	$(NET_LIB) netstat.o statistics.o
216 217
		$(CC) $(LDFLAGS) -o netstat netstat.o statistics.o $(NLIB) $(RESLIB)

218
iptunnel:	$(NET_LIB) iptunnel.o
219 220
		$(CC) $(LDFLAGS) -o iptunnel iptunnel.o $(NLIB) $(RESLIB)

221
ipmaddr:	$(NET_LIB) ipmaddr.o
222
		$(CC) $(LDFLAGS) -o ipmaddr ipmaddr.o $(NLIB) $(RESLIB)
Phil Blundell's avatar
Phil Blundell committed
223

224 225 226
mii-tool:	mii-tool.o
		$(CC) $(LDFLAGS) -o mii-tool mii-tool.o

Phil Blundell's avatar
Phil Blundell committed
227
installbin:
228 229
	install -m 0755 -d ${BASEDIR}/sbin
	install -m 0755 -d ${BASEDIR}/bin
230
	install -m 0755 arp        ${BASEDIR}/sbin
Phil Blundell's avatar
Phil Blundell committed
231
	install -m 0755 hostname   ${BASEDIR}/bin
232
	install -m 0755 ifconfig   ${BASEDIR}/sbin
Phil Blundell's avatar
Phil Blundell committed
233
	install -m 0755 nameif     ${BASEDIR}/sbin
234
	install -m 0755 netstat    ${BASEDIR}/bin
Phil Blundell's avatar
Phil Blundell committed
235
	install -m 0755 plipconfig $(BASEDIR)/sbin
236 237 238
	install -m 0755 rarp       ${BASEDIR}/sbin
	install -m 0755 route      ${BASEDIR}/sbin
	install -m 0755 slattach   $(BASEDIR)/sbin
239
ifeq ($(HAVE_IP_TOOLS),1)
240 241
	install -m 0755 ipmaddr    $(BASEDIR)/sbin
	install -m 0755 iptunnel   $(BASEDIR)/sbin
242 243 244
endif
ifeq ($(HAVE_MII),1)
	install -m 0755 mii-tool   $(BASEDIR)/sbin
245
endif
Phil Blundell's avatar
Phil Blundell committed
246 247 248 249
	ln -fs hostname $(BASEDIR)/bin/dnsdomainname
	ln -fs hostname $(BASEDIR)/bin/ypdomainname
	ln -fs hostname $(BASEDIR)/bin/nisdomainname
	ln -fs hostname $(BASEDIR)/bin/domainname
250 251 252
ifeq ($(HAVE_AFDECnet),1)
	ln -fs hostname $(BASEDIR)/bin/nodename
endif
Phil Blundell's avatar
Phil Blundell committed
253 254 255 256 257 258 259 260 261 262 263

savebin:
	@for i in ${BASEDIR}/sbin/arp ${BASEDIR}/sbin/ifconfig \
                 ${BASEDIR}/bin/netstat \
		 ${BASEDIR}/sbin/rarp ${BASEDIR}/sbin/route \
		 ${BASEDIR}/bin/hostname ${BASEDIR}/bin/ypdomainname \
                 ${BASEDIR}/bin/dnsdomainname ${BASEDIR}/bin/nisdomainname \
		 ${BASEDIR}/bin/domainname ; do \
		 [ -f $$i ] && cp -f $$i $$i.old ; done ; echo Saved.

installdata:
264 265
	$(MAKE) -C man install
	$(MAKE) -C po install
Phil Blundell's avatar
Phil Blundell committed
266 267

# End of Makefile.