Makefile 6.97 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 netstat route nameif
37 38

-include config.make
39 40 41
ifeq ($(HAVE_ARP_TOOLS),1)
PROGS	+= arp rarp
endif
42 43 44
ifeq ($(HAVE_HOSTNAME_TOOLS),1)
PROGS	+= hostname
endif
45 46 47
ifeq ($(HAVE_IP_TOOLS),1)
PROGS   += iptunnel ipmaddr
endif
48 49 50
ifeq ($(HAVE_MII),1)
PROGS	+= mii-tool
endif
51 52 53 54 55 56
ifeq ($(HAVE_PLIP_TOOLS),1)
PROGS	+= plipconfig
endif
ifeq ($(HAVE_SERIAL_TOOLS),1)
PROGS	+= slattach
endif
Phil Blundell's avatar
Phil Blundell committed
57 58

# Compiler and Linker Options
59 60
CFLAGS ?= -O2 -g
CFLAGS += -Wall
61
CFLAGS += -fno-strict-aliasing # code needs a lot of work before strict aliasing is safe
62
CPPFLAGS += -D_GNU_SOURCE
63 64
# Turn on transparent support for LFS
CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
Phil Blundell's avatar
Phil Blundell committed
65

66 67 68 69
ifeq ($(HAVE_AFDECnet),1)
DNLIB = -ldnet
endif

70 71 72 73 74 75
ifeq ($(origin CC), undefined)
CC	= gcc
endif
LD	= $(CC)
PKG_CONFIG ?= pkg-config

Phil Blundell's avatar
Phil Blundell committed
76 77
# -------- end of user definitions --------

78
MAINTAINER = net-tools-devel@lists.sourceforge.net
79
RELEASE	   = 2.10-alpha
Phil Blundell's avatar
Phil Blundell committed
80 81 82

.EXPORT_ALL_VARIABLES:

83
ifeq ("$(NET_LIB_PATH)","lib2")
Phil Blundell's avatar
Phil Blundell committed
84 85 86 87 88
TOPDIR   = ..
else
TOPDIR  := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
endif

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

91
ifeq ($(HAVE_SELINUX),1)
92 93
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
94
SELIB = $(SE_PC_LIBS)
95
CPPFLAGS += $(SE_PC_CFLAGS)
96 97
endif

98
CPPFLAGS += -I. -I$(TOPDIR)/include -I$(NET_LIB_PATH)
99
LDFLAGS  += -L$(NET_LIB_PATH)
Phil Blundell's avatar
Phil Blundell committed
100

101
SUBDIRS	= man/ $(NET_LIB_PATH)/
Phil Blundell's avatar
Phil Blundell committed
102

103
NLIB	= -l$(NET_LIB_NAME)
Phil Blundell's avatar
Phil Blundell committed
104

105 106
%.o:		%.c config.h version.h intl.h lib/net-features.h $<
		$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
Phil Blundell's avatar
Phil Blundell committed
107 108 109 110 111 112 113 114 115

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

config: 	cleanconfig config.h

install:	all savebin installbin installdata

update: 	all installbin installdata

116
mostlyclean:
Mike Frysinger's avatar
Mike Frysinger committed
117
		rm -f -- *.o DEADJOE config.new *~ *.orig lib/*.o
118 119

clean: mostlyclean
Mike Frysinger's avatar
Mike Frysinger committed
120
		rm -f -- $(PROGS)
121 122
		@for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) ; done
		@cd po && $(MAKE) clean
Phil Blundell's avatar
Phil Blundell committed
123 124

cleanconfig:
Mike Frysinger's avatar
Mike Frysinger committed
125
		rm -f -- config.h
Phil Blundell's avatar
Phil Blundell committed
126 127

clobber: 	clean
Mike Frysinger's avatar
Mike Frysinger committed
128
		rm -f -- $(PROGS) config.h version.h config.status config.make
129
		@for i in $(SUBDIRS); do (cd $$i && $(MAKE) clobber) ; done
Phil Blundell's avatar
Phil Blundell committed
130 131


132
dist:
Mike Frysinger's avatar
Mike Frysinger committed
133
		rm -rf -- net-tools-$(RELEASE)
134 135 136
		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
Mike Frysinger's avatar
Mike Frysinger committed
137
		rm -rf -- net-tools-$(RELEASE)
Phil Blundell's avatar
Phil Blundell committed
138

139 140 141 142
distcheck:	dist
		tar xf net-tools-$(RELEASE).tar.xz
		yes "" | $(MAKE) -C net-tools-$(RELEASE) config
		$(MAKE) -C net-tools-$(RELEASE)
Mike Frysinger's avatar
Mike Frysinger committed
143
		rm -rf -- net-tools-$(RELEASE)
144
		@printf "\nThe tarball is ready to go:\n%s\n" "`du -b net-tools-$(RELEASE).tar.xz`"
Phil Blundell's avatar
Phil Blundell committed
145

146
config.h: 	config.in Makefile
Phil Blundell's avatar
Phil Blundell committed
147 148
		@echo "Configuring the Linux net-tools (NET-3 Base Utilities)..." ; echo
		@if [ config.status -nt config.in ]; \
149 150
			then ./configure.sh config.status; \
		   else ./configure.sh config.in; \
Phil Blundell's avatar
Phil Blundell committed
151 152 153 154 155 156 157
		 fi


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


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

160
i18n.h:		i18ndir
Phil Blundell's avatar
Phil Blundell committed
161

162
libdir:		version.h
163
		@$(MAKE) -C $(NET_LIB_PATH)
Phil Blundell's avatar
Phil Blundell committed
164

165 166
i18ndir:
		@$(MAKE) -C po
Phil Blundell's avatar
Phil Blundell committed
167

168 169 170
# 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
171

172
ifconfig:	$(NET_LIB) ifconfig.o
173
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ ifconfig.o $(NLIB)
174

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

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

181
route:		$(NET_LIB) route.o
182
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ route.o $(NLIB)
Phil Blundell's avatar
Phil Blundell committed
183

184
arp:		$(NET_LIB) arp.o
185
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ arp.o $(NLIB)
Phil Blundell's avatar
Phil Blundell committed
186

187
rarp:		$(NET_LIB) rarp.o
188
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ rarp.o $(NLIB)
Phil Blundell's avatar
Phil Blundell committed
189

190
slattach:	$(NET_LIB) slattach.o
191
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ slattach.o $(NLIB)
192

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

196
netstat:	$(NET_LIB) netstat.o statistics.o
197
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ netstat.o statistics.o $(NLIB) $(SELIB)
198

199
iptunnel:	$(NET_LIB) iptunnel.o
200
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ iptunnel.o $(NLIB)
201

202
ipmaddr:	$(NET_LIB) ipmaddr.o
203
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ ipmaddr.o $(NLIB)
Phil Blundell's avatar
Phil Blundell committed
204

205
mii-tool:	$(NET_LIB) mii-tool.o
206
		$(CC) $(CFLAGS) $(LDFLAGS) -o $@ mii-tool.o $(NLIB)
207

Phil Blundell's avatar
Phil Blundell committed
208
installbin:
209 210 211 212 213
	@echo
	@echo "######################################################"
	@echo "Notice: ifconfig and route are now installed into /bin"
	@echo "######################################################"
	@echo
214 215 216 217 218 219
	install -m 0755 -d ${BASEDIR}${SBINDIR}
	install -m 0755 -d ${BASEDIR}${BINDIR}
	install -m 0755 ifconfig   ${BASEDIR}${BINDIR}
	install -m 0755 nameif     ${BASEDIR}${SBINDIR}
	install -m 0755 netstat    ${BASEDIR}${BINDIR}
	install -m 0755 route      ${BASEDIR}${BINDIR}
220 221 222 223
ifeq ($(HAVE_ARP_TOOLS),1)
	install -m 0755 arp        ${BASEDIR}${SBINDIR}
	install -m 0755 rarp       ${BASEDIR}${SBINDIR}
endif
224 225
ifeq ($(HAVE_HOSTNAME_TOOLS),1)
	install -m 0755 hostname   ${BASEDIR}${BINDIR}
226
	ln -fs hostname $(BASEDIR)${BINDIR}/dnsdomainname
227
ifeq ($(HAVE_HOSTNAME_SYMLINKS),1)
228 229 230
	ln -fs hostname $(BASEDIR)${BINDIR}/ypdomainname
	ln -fs hostname $(BASEDIR)${BINDIR}/nisdomainname
	ln -fs hostname $(BASEDIR)${BINDIR}/domainname
231
endif
232
ifeq ($(HAVE_AFDECnet),1)
233
	ln -fs hostname $(BASEDIR)${BINDIR}/nodename
234
endif
235 236 237 238 239 240 241 242
endif
ifeq ($(HAVE_IP_TOOLS),1)
	install -m 0755 ipmaddr    $(BASEDIR)${SBINDIR}
	install -m 0755 iptunnel   $(BASEDIR)${SBINDIR}
endif
ifeq ($(HAVE_MII),1)
	install -m 0755 mii-tool   $(BASEDIR)${SBINDIR}
endif
243 244 245 246 247 248
ifeq ($(HAVE_PLIP_TOOLS),1)
	install -m 0755 plipconfig $(BASEDIR)${SBINDIR}
endif
ifeq ($(HAVE_SERIAL_TOOLS),1)
	install -m 0755 slattach   $(BASEDIR)${SBINDIR}
endif
Phil Blundell's avatar
Phil Blundell committed
249 250

savebin:
251 252 253 254 255 256
	@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
257 258 259
		 [ -f $$i ] && cp -f $$i $$i.old ; done ; echo Saved.

installdata:
260 261
	$(MAKE) -C man install
	$(MAKE) -C po install
Phil Blundell's avatar
Phil Blundell committed
262 263

# End of Makefile.