Makefile 6.68 KB
Newer Older
Phil Blundell's avatar
Phil Blundell committed
1 2 3 4 5 6 7 8
#
# 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.
#
# Author:	Bernd Eckenfels <net-tools@lina.inka.de>
9
#		Copyright 1995-1996 Bernd Eckenfels, Germany
Phil Blundell's avatar
Phil Blundell committed
10
#
11
# URLs:		http://net-tools.sourceforge.net/
Phil Blundell's avatar
Phil Blundell committed
12 13 14 15 16 17 18 19
#
# 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
20
#
21
# Be careful!
22
# This Makefile doesn't describe complete dependencies for all include files.
23
# If you change include files you might need to do make clean.
Phil Blundell's avatar
Phil Blundell committed
24 25
#

26
# set the base of the Installation
Phil Blundell's avatar
Phil Blundell committed
27
# BASEDIR = /mnt
28
BASEDIR ?= $(DESTDIR)
29 30
BINDIR ?= /bin
SBINDIR ?= /sbin
Phil Blundell's avatar
Phil Blundell committed
31 32

# path to the net-lib support library. Default: lib
33 34
NET_LIB_PATH = lib
NET_LIB_NAME = net-tools
Phil Blundell's avatar
Phil Blundell committed
35

36
PROGS	:= ifconfig hostname arp netstat route rarp slattach plipconfig nameif
37 38 39 40 41

-include config.make
ifeq ($(HAVE_IP_TOOLS),1)
PROGS   += iptunnel ipmaddr
endif
42 43 44
ifeq ($(HAVE_MII),1)
PROGS	+= mii-tool
endif
Phil Blundell's avatar
Phil Blundell committed
45 46

# Compiler and Linker Options
47
# You may need to uncomment and edit these if you are using libc5 and IPv6.
48 49
CFLAGS ?= -O2 -g
CFLAGS += -Wall
50
CFLAGS += -fno-strict-aliasing # code needs a lot of work before strict aliasing is safe
51
CPPFLAGS += -D_GNU_SOURCE
Phil Blundell's avatar
Phil Blundell committed
52 53
RESLIB = # -L/usr/inet6/lib -linet6

54 55 56 57
ifeq ($(HAVE_AFDECnet),1)
DNLIB = -ldnet
endif

58 59 60 61 62 63
ifeq ($(origin CC), undefined)
CC	= gcc
endif
LD	= $(CC)
PKG_CONFIG ?= pkg-config

Phil Blundell's avatar
Phil Blundell committed
64 65
# -------- end of user definitions --------

66
MAINTAINER = net-tools-devel@lists.sourceforge.net
67
RELEASE	   = 2.10-alpha
Phil Blundell's avatar
Phil Blundell committed
68 69 70

.EXPORT_ALL_VARIABLES:

71
ifeq ("$(NET_LIB_PATH)","lib2")
Phil Blundell's avatar
Phil Blundell committed
72 73 74 75 76
TOPDIR   = ..
else
TOPDIR  := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
endif

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

79
ifeq ($(HAVE_SELINUX),1)
80 81
SE_PC_CFLAGS := $(shell $(PKG_CONFIG) --cflags libselinux)
SE_PC_LIBS := $(shell $(PKG_CONFIG) --libs libselinux || echo -lselinux)
Bernd Eckenfels's avatar
Bernd Eckenfels committed
82
SELIB = $(SE_PC_LIBS)
83
CPPFLAGS += $(SE_PC_CFLAGS)
84 85
endif

86
CPPFLAGS += -I. -I$(TOPDIR)/include -I$(NET_LIB_PATH)
87
LDFLAGS  += -L$(NET_LIB_PATH)
Phil Blundell's avatar
Phil Blundell committed
88

89
SUBDIRS	= man/ $(NET_LIB_PATH)/
Phil Blundell's avatar
Phil Blundell committed
90

91
NLIB	= -l$(NET_LIB_NAME)
Phil Blundell's avatar
Phil Blundell committed
92

93 94
%.o:		%.c config.h version.h intl.h lib/net-features.h $<
		$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
Phil Blundell's avatar
Phil Blundell committed
95 96 97 98 99 100 101 102 103

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

config: 	cleanconfig config.h

install:	all savebin installbin installdata

update: 	all installbin installdata

104
mostlyclean:
Phil Blundell's avatar
Phil Blundell committed
105
		rm -f *.o DEADJOE config.new *~ *.orig lib/*.o
106 107 108

clean: mostlyclean
		rm -f $(PROGS)
109 110
		@for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) ; done
		@cd po && $(MAKE) clean
Phil Blundell's avatar
Phil Blundell committed
111 112 113 114 115

cleanconfig:
		rm -f config.h

clobber: 	clean
116
		rm -f $(PROGS) config.h version.h config.status config.make
117
		@for i in $(SUBDIRS); do (cd $$i && $(MAKE) clobber) ; done
Phil Blundell's avatar
Phil Blundell committed
118 119


120 121 122 123 124 125
dist:
		rm -rf net-tools-$(RELEASE)
		git archive --prefix=net-tools-$(RELEASE)/ HEAD | tar xf -
		$(MAKE) -C net-tools-$(RELEASE)/po $@
		tar cf - net-tools-$(RELEASE)/ | xz > net-tools-$(RELEASE).tar.xz
		rm -rf net-tools-$(RELEASE)
Phil Blundell's avatar
Phil Blundell committed
126

127 128 129 130 131 132
distcheck:	dist
		tar xf net-tools-$(RELEASE).tar.xz
		yes "" | $(MAKE) -C net-tools-$(RELEASE) config
		$(MAKE) -C net-tools-$(RELEASE)
		rm -rf net-tools-$(RELEASE)
		@printf "\nThe tarball is ready to go:\n%s\n" "`du -b net-tools-$(RELEASE).tar.xz`"
Phil Blundell's avatar
Phil Blundell committed
133

134
config.h: 	config.in Makefile
Phil Blundell's avatar
Phil Blundell committed
135 136
		@echo "Configuring the Linux net-tools (NET-3 Base Utilities)..." ; echo
		@if [ config.status -nt config.in ]; \
137 138
			then ./configure.sh config.status; \
		   else ./configure.sh config.in; \
Phil Blundell's avatar
Phil Blundell committed
139 140 141 142 143 144 145
		 fi


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


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

148
i18n.h:		i18ndir
Phil Blundell's avatar
Phil Blundell committed
149

150
libdir:		version.h
151
		@$(MAKE) -C $(NET_LIB_PATH)
Phil Blundell's avatar
Phil Blundell committed
152

153 154
i18ndir:
		@$(MAKE) -C po
Phil Blundell's avatar
Phil Blundell committed
155

156 157 158
# 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
159

160
ifconfig:	$(NET_LIB) ifconfig.o
161
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ ifconfig.o $(NLIB) $(RESLIB)
162

163
nameif:		$(NET_LIB) nameif.o
164
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ nameif.o $(NLIB) $(RESLIB)
Phil Blundell's avatar
Phil Blundell committed
165 166

hostname:	hostname.o
167
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ hostname.o $(DNLIB)
Phil Blundell's avatar
Phil Blundell committed
168

169
route:		$(NET_LIB) route.o
170
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ route.o $(NLIB) $(RESLIB)
Phil Blundell's avatar
Phil Blundell committed
171

172
arp:		$(NET_LIB) arp.o
173
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ arp.o $(NLIB) $(RESLIB)
Phil Blundell's avatar
Phil Blundell committed
174

175
rarp:		$(NET_LIB) rarp.o
176
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ rarp.o $(NLIB)
Phil Blundell's avatar
Phil Blundell committed
177

178
slattach:	$(NET_LIB) slattach.o
179
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ slattach.o $(NLIB)
180

181
plipconfig:	$(NET_LIB) plipconfig.o
182
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ plipconfig.o $(NLIB)
183

184
netstat:	$(NET_LIB) netstat.o statistics.o
185
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ netstat.o statistics.o $(NLIB) $(RESLIB) $(SELIB)
186

187
iptunnel:	$(NET_LIB) iptunnel.o
188
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ iptunnel.o $(NLIB) $(RESLIB)
189

190
ipmaddr:	$(NET_LIB) ipmaddr.o
191
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ ipmaddr.o $(NLIB) $(RESLIB)
Phil Blundell's avatar
Phil Blundell committed
192

193
mii-tool:	$(NET_LIB) mii-tool.o
194
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ mii-tool.o $(NLIB) $(RESLIB)
195

Phil Blundell's avatar
Phil Blundell committed
196
installbin:
197 198 199 200 201
	@echo
	@echo "######################################################"
	@echo "Notice: ifconfig and route are now installed into /bin"
	@echo "######################################################"
	@echo
202 203 204 205 206 207 208 209 210 211 212
	install -m 0755 -d ${BASEDIR}${SBINDIR}
	install -m 0755 -d ${BASEDIR}${BINDIR}
	install -m 0755 arp        ${BASEDIR}${SBINDIR}
	install -m 0755 hostname   ${BASEDIR}${BINDIR}
	install -m 0755 ifconfig   ${BASEDIR}${BINDIR}
	install -m 0755 nameif     ${BASEDIR}${SBINDIR}
	install -m 0755 netstat    ${BASEDIR}${BINDIR}
	install -m 0755 plipconfig $(BASEDIR)${SBINDIR}
	install -m 0755 rarp       ${BASEDIR}${SBINDIR}
	install -m 0755 route      ${BASEDIR}${BINDIR}
	install -m 0755 slattach   $(BASEDIR)${SBINDIR}
213
ifeq ($(HAVE_IP_TOOLS),1)
214 215
	install -m 0755 ipmaddr    $(BASEDIR)${SBINDIR}
	install -m 0755 iptunnel   $(BASEDIR)${SBINDIR}
216 217
endif
ifeq ($(HAVE_MII),1)
218
	install -m 0755 mii-tool   $(BASEDIR)${SBINDIR}
219
endif
220 221 222 223
	ln -fs hostname $(BASEDIR)${BINDIR}/dnsdomainname
	ln -fs hostname $(BASEDIR)${BINDIR}/ypdomainname
	ln -fs hostname $(BASEDIR)${BINDIR}/nisdomainname
	ln -fs hostname $(BASEDIR)${BINDIR}/domainname
224
ifeq ($(HAVE_AFDECnet),1)
225
	ln -fs hostname $(BASEDIR)${BINDIR}/nodename
226
endif
Phil Blundell's avatar
Phil Blundell committed
227 228

savebin:
229 230 231 232 233 234
	@for i in ${BASEDIR}${SBINDIR}/arp ${BASEDIR}${SBINDIR}/ifconfig \
                 ${BASEDIR}${BINDIR}/netstat \
		 ${BASEDIR}${SBINDIR}/rarp ${BASEDIR}${SBINDIR}/route \
		 ${BASEDIR}${BINDIR}/hostname ${BASEDIR}${BINDIR}/ypdomainname \
                 ${BASEDIR}${BINDIR}/dnsdomainname ${BASEDIR}${BINDIR}/nisdomainname \
		 ${BASEDIR}${BINDIR}/domainname ; do \
Phil Blundell's avatar
Phil Blundell committed
235 236 237
		 [ -f $$i ] && cp -f $$i $$i.old ; done ; echo Saved.

installdata:
238 239
	$(MAKE) -C man install
	$(MAKE) -C po install
Phil Blundell's avatar
Phil Blundell committed
240 241

# End of Makefile.