2002-10-11 02:25:36 +05:30
|
|
|
# procps Makefile
|
2004-07-17 20:55:45 +05:30
|
|
|
# Albert Cahalan, 2002-2004
|
2002-10-11 02:25:36 +05:30
|
|
|
#
|
|
|
|
# Recursive make is considered harmful:
|
|
|
|
# http://google.com/search?q=%22recursive+make+considered+harmful%22
|
|
|
|
#
|
|
|
|
# For now this Makefile uses explicit dependencies. The project
|
|
|
|
# hasn't grown big enough to need something complicated, and the
|
|
|
|
# dependency tracking files are an ugly annoyance.
|
|
|
|
#
|
|
|
|
# This file includes */module.mk files which add on to variables:
|
|
|
|
# FOO += bar/baz
|
2002-10-14 03:16:46 +05:30
|
|
|
#
|
|
|
|
#
|
|
|
|
# Set (or uncomment) SKIP if you wish to avoid something.
|
|
|
|
# For example, you may prefer the /bin/kill from util-linux or bsdutils.
|
|
|
|
|
2002-10-11 02:25:36 +05:30
|
|
|
|
|
|
|
VERSION := 3
|
2004-01-29 10:35:37 +05:30
|
|
|
SUBVERSION := 2
|
2006-06-24 10:04:55 +05:30
|
|
|
MINORVERSION := 7
|
2004-07-20 08:42:41 +05:30
|
|
|
TARVERSION := $(VERSION).$(SUBVERSION).$(MINORVERSION)
|
2002-10-11 02:25:36 +05:30
|
|
|
|
|
|
|
############ vars
|
|
|
|
|
|
|
|
# so you can disable them or choose alternates
|
|
|
|
ldconfig := ldconfig
|
2002-10-14 10:55:27 +05:30
|
|
|
ln_f := ln -f
|
|
|
|
ln_sf := ln -sf
|
2002-10-12 00:55:21 +05:30
|
|
|
install := install -D --owner 0 --group 0
|
2002-10-11 02:25:36 +05:30
|
|
|
|
2003-10-23 09:11:58 +05:30
|
|
|
# Lame x86-64 /lib64 and /usr/lib64 abomination:
|
|
|
|
lib64 := lib$(shell [ -d /lib64 ] && echo 64)
|
|
|
|
|
2002-10-11 02:25:36 +05:30
|
|
|
usr/bin := $(DESTDIR)/usr/bin/
|
|
|
|
bin := $(DESTDIR)/bin/
|
|
|
|
sbin := $(DESTDIR)/sbin/
|
|
|
|
usr/proc/bin := $(DESTDIR)/usr/bin/
|
|
|
|
man1 := $(DESTDIR)/usr/share/man/man1/
|
|
|
|
man5 := $(DESTDIR)/usr/share/man/man5/
|
|
|
|
man8 := $(DESTDIR)/usr/share/man/man8/
|
2003-10-23 09:11:58 +05:30
|
|
|
lib := $(DESTDIR)/$(lib64)/
|
|
|
|
usr/lib := $(DESTDIR)/usr/$(lib64)/
|
2002-10-11 02:25:36 +05:30
|
|
|
usr/include := $(DESTDIR)/usr/include/
|
|
|
|
|
2002-10-14 03:16:46 +05:30
|
|
|
#SKIP := $(bin)kill $(man1)kill.1
|
|
|
|
|
2002-10-11 02:25:36 +05:30
|
|
|
BINFILES := $(usr/bin)uptime $(usr/bin)tload $(usr/bin)free $(usr/bin)w \
|
|
|
|
$(usr/bin)top $(usr/bin)vmstat $(usr/bin)watch $(usr/bin)skill \
|
2002-10-27 16:05:13 +05:30
|
|
|
$(usr/bin)snice $(bin)kill $(sbin)sysctl $(usr/bin)pmap \
|
2004-09-21 03:27:49 +05:30
|
|
|
$(usr/proc/bin)pgrep $(usr/proc/bin)pkill $(usr/bin)slabtop \
|
|
|
|
$(usr/proc/bin)pwdx
|
2002-10-11 02:25:36 +05:30
|
|
|
|
|
|
|
MANFILES := $(man1)uptime.1 $(man1)tload.1 $(man1)free.1 $(man1)w.1 \
|
|
|
|
$(man1)top.1 $(man1)watch.1 $(man1)skill.1 $(man1)kill.1 \
|
2002-10-27 16:05:13 +05:30
|
|
|
$(man1)snice.1 $(man1)pgrep.1 $(man1)pkill.1 $(man1)pmap.1 \
|
2004-01-25 04:03:56 +05:30
|
|
|
$(man5)sysctl.conf.5 $(man8)vmstat.8 $(man8)sysctl.8 \
|
2004-09-21 03:27:49 +05:30
|
|
|
$(man1)slabtop.1 $(man1)pwdx.1
|
2002-10-11 02:25:36 +05:30
|
|
|
|
2002-12-15 06:02:45 +05:30
|
|
|
TARFILES := AUTHORS BUGS NEWS README TODO COPYING COPYING.LIB \
|
2004-02-24 00:17:42 +05:30
|
|
|
Makefile procps.lsm procps.spec v t README.top CodingStyle \
|
2004-07-17 21:53:45 +05:30
|
|
|
sysctl.conf minimal.c $(notdir $(MANFILES)) dummy.c \
|
2002-10-11 04:10:35 +05:30
|
|
|
uptime.c tload.c free.c w.c top.c vmstat.c watch.c skill.c \
|
2004-09-21 03:27:49 +05:30
|
|
|
sysctl.c pgrep.c top.h pmap.c slabtop.c pwdx.c
|
2004-01-25 04:03:56 +05:30
|
|
|
|
|
|
|
# Stuff (tests, temporary hacks, etc.) left out of the standard tarball
|
2004-01-30 03:58:13 +05:30
|
|
|
# plus the top-level Makefile to make it work stand-alone.
|
|
|
|
_TARFILES := Makefile
|
2002-10-11 04:10:35 +05:30
|
|
|
|
2004-04-13 09:26:52 +05:30
|
|
|
CURSES := -lncurses
|
2002-10-11 02:25:36 +05:30
|
|
|
|
2005-10-30 09:14:26 +05:30
|
|
|
# This seems about right for the dynamic library stuff.
|
|
|
|
# Something like this is probably needed to make the SE Linux
|
|
|
|
# library loading not conflict with embedded systems stuff.
|
|
|
|
#
|
|
|
|
#ifeq ($(SHARED),1)
|
|
|
|
#ldl := -ldl
|
|
|
|
#LIBTYPE := -DSHAREDLIB
|
|
|
|
#else
|
|
|
|
#LIBTYPE := -DSTATICLIB
|
|
|
|
#endif
|
|
|
|
|
2003-09-01 05:48:58 +05:30
|
|
|
# Preprocessor flags.
|
|
|
|
PKG_CPPFLAGS := -D_GNU_SOURCE -I proc
|
2004-04-13 09:26:52 +05:30
|
|
|
CPPFLAGS := -I/usr/include/ncurses
|
2003-09-01 05:48:58 +05:30
|
|
|
ALL_CPPFLAGS := $(PKG_CPPFLAGS) $(CPPFLAGS)
|
|
|
|
|
|
|
|
# Left out -Wconversion due to noise in glibc headers.
|
2004-07-15 06:47:15 +05:30
|
|
|
# Left out -Wunreachable-code and -Wdisabled-optimization
|
|
|
|
# because gcc spews many useless warnings with them.
|
2003-09-01 05:48:58 +05:30
|
|
|
#
|
|
|
|
# Since none of the PKG_CFLAGS things are truly required
|
|
|
|
# to compile procps, they might best be moved to CFLAGS.
|
|
|
|
# On the other hand, they aren't normal -O -g things either.
|
|
|
|
#
|
2004-07-15 06:47:15 +05:30
|
|
|
# Note that -O2 includes -fomit-frame-pointer only if the arch
|
|
|
|
# doesn't lose some debugging ability.
|
2004-07-06 09:54:39 +05:30
|
|
|
#
|
2004-04-13 09:26:52 +05:30
|
|
|
PKG_CFLAGS := -fno-common -ffast-math \
|
2002-10-12 07:27:05 +05:30
|
|
|
-W -Wall -Wshadow -Wcast-align -Wredundant-decls \
|
2002-10-11 02:25:36 +05:30
|
|
|
-Wbad-function-cast -Wcast-qual -Wwrite-strings -Waggregate-return \
|
2003-09-01 05:48:58 +05:30
|
|
|
-Wstrict-prototypes -Wmissing-prototypes
|
2004-07-15 06:47:15 +05:30
|
|
|
# Note that some stuff below is conditional on CFLAGS containing
|
|
|
|
# an option that starts with "-g". (-g, -g2, -g3, -ggdb, etc.)
|
|
|
|
CFLAGS := -O2 -s
|
2004-04-13 09:26:52 +05:30
|
|
|
ALL_CFLAGS := $(PKG_CFLAGS) $(CFLAGS)
|
2003-09-01 05:48:58 +05:30
|
|
|
|
2004-04-13 09:26:52 +05:30
|
|
|
PKG_LDFLAGS := -Wl,-warn-common
|
|
|
|
LDFLAGS :=
|
|
|
|
ALL_LDFLAGS := $(PKG_LDFLAGS) $(LDFLAGS)
|
2002-10-11 02:25:36 +05:30
|
|
|
|
2004-01-30 03:58:13 +05:30
|
|
|
############ Add some extra flags if gcc allows
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
ifneq ($(MAKECMDGOALS),tar)
|
|
|
|
ifneq ($(MAKECMDGOALS),extratar)
|
2004-09-23 19:11:33 +05:30
|
|
|
ifneq ($(MAKECMDGOALS),beta)
|
2004-01-30 03:58:13 +05:30
|
|
|
|
|
|
|
# Unlike the kernel one, this check_gcc goes all the way to
|
|
|
|
# producing an executable. There might be a -m64 that works
|
|
|
|
# until you go looking for a 64-bit curses library.
|
2004-04-13 09:26:52 +05:30
|
|
|
check_gcc = $(shell if $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) dummy.c $(ALL_LDFLAGS) $(1) -o /dev/null $(CURSES) > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
|
2004-01-30 03:58:13 +05:30
|
|
|
|
2004-09-21 03:27:49 +05:30
|
|
|
# Be 64-bit if at all possible. In a cross-compiling situation, one may
|
|
|
|
# do "make m64=-m32 lib64=lib" to produce 32-bit executables. DO NOT
|
|
|
|
# attempt to use a 32-bit executable on a 64-bit kernel. Packagers MUST
|
|
|
|
# produce separate executables for ppc and ppc64, s390 and s390x,
|
|
|
|
# i386 and x86-64, mips and mips64, sparc and sparc64, and so on.
|
|
|
|
# Failure to do so will cause data corruption.
|
|
|
|
m64 := $(call check_gcc,-m64,$(call check_gcc,-mabi=64,))
|
|
|
|
ALL_CFLAGS += $(m64)
|
|
|
|
|
2004-01-30 03:58:13 +05:30
|
|
|
ALL_CFLAGS += $(call check_gcc,-Wdeclaration-after-statement,)
|
|
|
|
ALL_CFLAGS += $(call check_gcc,-Wpadded,)
|
2004-10-12 05:42:25 +05:30
|
|
|
ALL_CFLAGS += $(call check_gcc,-Wstrict-aliasing,)
|
2004-07-07 05:41:19 +05:30
|
|
|
|
|
|
|
# Adding -fno-gcse might be good for those files which
|
|
|
|
# use computed goto.
|
|
|
|
#ALL_CFLAGS += $(call check_gcc,-fno-gcse,)
|
|
|
|
|
2004-07-15 06:47:15 +05:30
|
|
|
# if not debugging, enable things that could confuse gdb
|
|
|
|
ifeq (,$(findstring -g,$(filter -g%,$(CFLAGS))))
|
2004-07-07 05:41:19 +05:30
|
|
|
ALL_CFLAGS += $(call check_gcc,-fweb,)
|
|
|
|
ALL_CFLAGS += $(call check_gcc,-frename-registers,)
|
2004-07-15 06:47:15 +05:30
|
|
|
ALL_CFLAGS += $(call check_gcc,-fomit-frame-pointer,)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# in case -O3 is enabled, avoid bloat
|
|
|
|
ALL_CFLAGS += $(call check_gcc,-fno-inline-functions,)
|
2004-01-30 03:58:13 +05:30
|
|
|
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
2004-09-23 19:11:33 +05:30
|
|
|
endif
|
2004-01-30 03:58:13 +05:30
|
|
|
|
2002-10-11 02:25:36 +05:30
|
|
|
############ misc.
|
|
|
|
|
|
|
|
# free.c pmap.c sysctl.c uptime.c vmstat.c watch.c pgrep.c skill.c tload.c top.c w.c
|
|
|
|
# utmp.c oldtop.c tmp-junk.c minimal.c
|
|
|
|
|
|
|
|
.SUFFIXES:
|
|
|
|
.SUFFIXES: .a .o .c .s .h
|
|
|
|
|
2004-09-23 19:11:33 +05:30
|
|
|
.PHONY: all clean do_all install tar extratar beta
|
2002-10-11 02:25:36 +05:30
|
|
|
|
|
|
|
ALL := $(notdir $(BINFILES))
|
|
|
|
|
|
|
|
CLEAN := $(notdir $(BINFILES))
|
|
|
|
|
|
|
|
DIRS :=
|
|
|
|
|
2002-10-21 14:37:18 +05:30
|
|
|
INSTALL := $(BINFILES) $(MANFILES)
|
2002-10-11 02:25:36 +05:30
|
|
|
|
|
|
|
# want this rule first, use := on ALL, and ALL not filled in yet
|
|
|
|
all: do_all
|
|
|
|
|
|
|
|
-include */module.mk
|
|
|
|
|
|
|
|
do_all: $(ALL)
|
|
|
|
|
|
|
|
junk := DEADJOE *~ *.o core gmon.out
|
|
|
|
|
|
|
|
# Remove $(junk) from all $(DIRS)
|
|
|
|
CLEAN += $(junk) $(foreach dir,$(DIRS),$(addprefix $(dir), $(junk)))
|
|
|
|
|
2002-10-14 03:16:46 +05:30
|
|
|
##########
|
|
|
|
# not maintained because it isn't really needed:
|
2002-10-11 02:25:36 +05:30
|
|
|
#
|
|
|
|
#SRC :=
|
|
|
|
#OBJ := $(patsubst %.c,%.o, $(filter %.c,$(SRC)))
|
|
|
|
#
|
|
|
|
#ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
#-include $(OBJ:.o=.d)
|
|
|
|
#endif
|
|
|
|
#
|
|
|
|
#%.d: %.c
|
2003-09-01 05:48:58 +05:30
|
|
|
# depend.sh $(ALL_CPPFLAGS) $(ALL_CFLAGS) $< > $@
|
2002-10-14 03:16:46 +05:30
|
|
|
############
|
2002-10-11 02:25:36 +05:30
|
|
|
|
2002-10-11 04:10:35 +05:30
|
|
|
# don't want to type "make procps-$(TARVERSION).tar.gz"
|
|
|
|
tar: $(TARFILES)
|
|
|
|
mkdir procps-$(TARVERSION)
|
|
|
|
(tar cf - $(TARFILES)) | (cd procps-$(TARVERSION) && tar xf -)
|
|
|
|
tar cf procps-$(TARVERSION).tar procps-$(TARVERSION)
|
|
|
|
gzip -9 procps-$(TARVERSION).tar
|
|
|
|
|
2004-01-25 04:03:56 +05:30
|
|
|
extratar: $(_TARFILES)
|
2004-02-24 01:03:59 +05:30
|
|
|
mkdir procps-$(TARVERSION)
|
|
|
|
(tar cf - $(_TARFILES)) | (cd procps-$(TARVERSION) && tar xf -)
|
|
|
|
tar cf extra-$(TARVERSION).tar procps-$(TARVERSION)
|
2004-01-25 04:03:56 +05:30
|
|
|
gzip -9 extra-$(TARVERSION).tar
|
|
|
|
|
2004-09-23 19:11:33 +05:30
|
|
|
beta: $(TARFILES) $(_TARFILES)
|
|
|
|
mkdir beta-$(TARVERSION)
|
|
|
|
(tar cf - $(TARFILES) $(_TARFILES)) | (cd beta-$(TARVERSION) && tar xf -)
|
|
|
|
tar cf beta-$(TARVERSION).tar beta-$(TARVERSION)
|
|
|
|
gzip -9 beta-$(TARVERSION).tar
|
|
|
|
|
2002-10-11 02:25:36 +05:30
|
|
|
clean:
|
|
|
|
rm -f $(CLEAN)
|
|
|
|
|
|
|
|
###### install
|
|
|
|
|
2002-10-12 13:32:27 +05:30
|
|
|
$(BINFILES) : all
|
2004-07-15 06:47:15 +05:30
|
|
|
$(install) --mode a=rx $(notdir $@) $@
|
2002-10-11 02:25:36 +05:30
|
|
|
|
2002-10-12 13:32:27 +05:30
|
|
|
$(MANFILES) : all
|
2002-10-11 04:10:35 +05:30
|
|
|
$(install) --mode a=r $(notdir $@) $@
|
2002-10-11 02:25:36 +05:30
|
|
|
|
2003-03-19 06:45:58 +05:30
|
|
|
install: $(filter-out $(SKIP) $(addprefix $(DESTDIR),$(SKIP)),$(INSTALL))
|
2003-03-21 06:34:51 +05:30
|
|
|
cd $(usr/bin) && $(ln_f) skill snice
|
|
|
|
cd $(usr/proc/bin) && $(ln_f) pgrep pkill
|
2002-10-11 02:25:36 +05:30
|
|
|
|
|
|
|
############ prog.c --> prog.o
|
|
|
|
|
2003-09-17 22:44:32 +05:30
|
|
|
top.o : top.h
|
|
|
|
|
2002-10-11 02:25:36 +05:30
|
|
|
%.o : %.c
|
2004-07-20 00:59:31 +05:30
|
|
|
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
2002-10-11 02:25:36 +05:30
|
|
|
|
|
|
|
w.o: w.c
|
2003-09-01 05:48:58 +05:30
|
|
|
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(W_SHOWFROM) -c $<
|
2002-10-11 02:25:36 +05:30
|
|
|
|
|
|
|
############ prog.o --> prog
|
|
|
|
|
2004-09-21 03:27:49 +05:30
|
|
|
pmap w uptime tload free sysctl vmstat utmp pgrep skill pwdx: % : %.o $(LIBPROC)
|
2004-01-30 03:58:13 +05:30
|
|
|
$(CC) $(ALL_CFLAGS) $^ $(ALL_LDFLAGS) -o $@
|
2002-10-11 02:25:36 +05:30
|
|
|
|
2004-01-25 04:03:56 +05:30
|
|
|
slabtop top: % : %.o $(LIBPROC)
|
2004-01-30 03:58:13 +05:30
|
|
|
$(CC) $(ALL_CFLAGS) $^ $(ALL_LDFLAGS) -o $@ $(CURSES)
|
2002-10-11 02:25:36 +05:30
|
|
|
|
|
|
|
watch: % : %.o
|
2004-01-30 03:58:13 +05:30
|
|
|
$(CC) $(ALL_CFLAGS) $^ $(ALL_LDFLAGS) -o $@ $(CURSES)
|
2002-10-11 02:25:36 +05:30
|
|
|
|
|
|
|
############ progX --> progY
|
|
|
|
|
|
|
|
snice kill: skill
|
2006-06-24 10:04:55 +05:30
|
|
|
$(ln_f) skill $@
|
2002-10-11 02:25:36 +05:30
|
|
|
|
|
|
|
pkill: pgrep
|
2006-06-24 10:04:55 +05:30
|
|
|
$(ln_f) pgrep pkill
|