Makefile.noam 7.73 KB
Newer Older
csmall's avatar
csmall committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# Makefile for procps.  Chuck Blake.
# Portions of this are highly dependent upon features specific to GNU make

export PREFIX     =  #proc# prefix for program names

export DESTDIR    =  /
export MANDIR     =  /usr/man
export MAN1DIR    =  $(DESTDIR)$(MANDIR)/man1
export MAN5DIR    =  $(DESTDIR)$(MANDIR)/man5
export MAN8DIR    =  $(DESTDIR)$(MANDIR)/man8
export BINDIR     =  $(DESTDIR)/bin
export SBINDIR    =  $(DESTDIR)/sbin
export XBINDIR    =  $(DESTDIR)/usr/X11R6/bin
export USRBINDIR  =  $(DESTDIR)/usr/bin
export PROCDIR    =  $(DESTDIR)/usr/bin# /usr/proc/bin for Solaris devotees
export APPLNK     =  $(DESTDIR)/etc/X11/applnk/Utilities
export OWNERGROUP =  --owner 0 --group 0
export INSTALLBIN =  install --mode a=rx --strip
export INSTALLSCT =  install --mode a=rx
export INSTALLMAN =  install --mode a=r

BPROG      =  kill #					-> BINDIR
albert's avatar
albert committed
23
UPROG      =  uptime tload free w top vmstat watch skill snice # -> USRBINDIR
csmall's avatar
csmall committed
24 25
PPROG      =  pgrep pkill# -> PROCDIR
SPROG      =  sysctl
albert's avatar
albert committed
26
MAN1       =  uptime.1 tload.1 free.1 w.1 top.1 watch.1 skill.1 kill.1 snice.1 pgrep.1 pkill.1
csmall's avatar
csmall committed
27 28 29 30 31 32 33 34 35 36 37 38
MAN5       =  sysctl.conf.5
MAN8       =  vmstat.8 sysctl.8
DESKTOP    =  top.desktop
XSCPT      =  XConsole # -> XBINDIR

SUBDIRS    =  ps # sub-packages to build/install

# easy to command-line override
export INCDIRS    =  -I/usr/include/ncurses -I/usr/X11R6/include

export CC         =  gcc #-ggdb # this gets compiling and linking :-)
export OPT        =  -O2
albert's avatar
albert committed
39
export CFLAGS     =  -D_GNU_SOURCE $(OPT) -I$(shell pwd) $(INCDIRS) -ffast-math -W -Wall -Wstrict-prototypes -Wshadow -Wcast-align -Wmissing-prototypes
csmall's avatar
csmall committed
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 74 75 76 77 78

export SHARED     =  1# build/install both a static and ELF shared library
export SHLIBDIR   =  $(DESTDIR)/lib# where to install the shared library

export LDFLAGS    =  -Wl,-warn-common #-s	recommended for ELF systems
#LDFLAGS    =  -qmagic -s#		recommended for a.out systems
#LDFLAGS    =  -Xlinker -qmagic -s#	older a.out systems may need this
#LDFLAGS    =  -N -s#			still older a.out systems use this

#BFD_CAPABLE = -DBFD_CAPABLE
#AOUT_CAPABLE = #-DAOUT_CAPABLE 
#ELF_CAPABLE = #-DELF_CAPABLE

#LIBBFD = -lbfd -liberty
LIBCURSES  =  -lncurses# watch is the only thing that needs this
#LIBCURSES  =  -lcurses -ltermcap# BSD Curses requires termcap
LIBTERMCAP =  -lncurses# provides perfectly good termcap support
#LIBTERMCAP =  -ltermcap
EXTRALIBS  =  # -lshadow

W_SHOWFROM =  -DW_SHOWFROM# show remote host users are logged in from.

#----------------------------------------------------#
# End of user-configurable portion of the Makefile.  #
# You should not need to modify anything below this. #
#----------------------------------------------------#
BUILD = $(BPROG) $(UPROG) $(PPROG) $(SPROG) $(SUBDIRS) $(DESKTOP)

# BUILD LIBRARIES + PROGRAMS
all: $(BUILD)

# INSTALL PROGRAMS + DOCS
install: $(patsubst %,install_%,$(BUILD) $(XSCPT) $(MAN1) $(MAN5) $(MAN8))
ifeq ($(SHARED),1)
	install $(OWNERGROUP) --mode a=rx $(LIB_TGT) $(SHLIBDIR)
endif

# INSTALL LIBRARIES + HEADERS (OPTIONAL)
libinstall:
albert's avatar
albert committed
79
	$(MAKE) -C proc -f Makefile.noam install $(LIBPROCPASS)
csmall's avatar
csmall committed
80 81 82

clean:
	$(RM) -f $(OBJ) $(BPROG) $(UPROG) $(PPROG) $(SPROG)
albert's avatar
albert committed
83
	for i in proc $(SUBDIRS); do $(MAKE) -C $$i -f Makefile.noam clean; done
csmall's avatar
csmall committed
84 85

distclean: clean
albert's avatar
albert committed
86
	for i in proc $(SUBDIRS); do $(MAKE) -C $$i -f Makefile.noam clean; done
csmall's avatar
csmall committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
	$(RM) -f $(OBJ) $(BPROG) $(UPROG) $(SPROG) \
	      proc/.depend


#-----------------------------------------------------#
# End of user-callable make targets.                  #
# You should not need to read anything below this.    #
#-----------------------------------------------------#

.PHONY:	all install libinstall clean distclean
.PHONY: $(patsubst %,install_%, $(BPROG) $(UPROG) $(SPROG))
.PHONY: proc ps
.PHONY: $(patsubst %,build_%, proc ps)
.PHONY: $(patsubst %,install_%, proc ps)

VERSION      = $(shell awk '/^%define major_version/ { print $$3 }' < procps.spec)
SUBVERSION   = $(shell awk '/^%define minor_version/ { print $$3 }' < procps.spec)
MINORVERSION = $(shell awk '/^%define revision/ { print $$3 }' < procps.spec)

# Note: LIBVERSION may be less than $(VERSION).$(SUBVERSION).$(MINORVERSION)
# LIBVERSION is only set to current $(VERSION).$(SUBVERSION).$(MINORVERSION)
# when an incompatible change is made in libproc.
albert's avatar
albert committed
109
LIBVERSION   =  3.0.2
csmall's avatar
csmall committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
ifdef MINORVERSION
LIBPROCPASS  =  SHARED=$(SHARED) SHLIBDIR=$(SHLIBDIR) VERSION=$(VERSION) SUBVERSION=$(SUBVERSION) MINORVERSION=$(MINORVERSION) LIBVERSION=$(LIBVERSION)
else
LIBPROCPASS  =  SHARED=$(SHARED) SHLIBDIR=$(SHLIBDIR) VERSION=$(VERSION) SUBVERSION=$(SUBVERSION) LIBVERSION=$(LIBVERSION)
endif

# libproc setup

ifeq ($(SHARED),1)
    LIB_TGT = proc/libproc.so.$(LIBVERSION)
else
    LIB_TGT = proc/libproc.a
endif

$(LIB_TGT): $(wildcard proc/*.[ch])
albert's avatar
albert committed
125
	$(MAKE) -C proc -f Makefile.noam `basename $(LIB_TGT)` $(LIBPROCPASS)
csmall's avatar
csmall committed
126 127 128 129 130 131

# component package setup -- the pattern should be obvious: A build rule and
# unified executable+documentation install rule. (An extra makefile rule is
# needed for those packages which use Imake.)

ps:              build_ps
albert's avatar
albert committed
132 133
build_ps:				; $(MAKE) -C ps -f Makefile.noam
install_ps:      ps		; $(MAKE) -C ps -f Makefile.noam install
csmall's avatar
csmall committed
134 135

# executable dependencies
albert's avatar
albert committed
136
kill skill snice top w uptime tload free vmstat utmp oldtop : $(LIB_TGT)
csmall's avatar
csmall committed
137 138 139 140 141 142

# static pattern build/link rules:

%.o : %.c
	$(strip $(CC) $(CFLAGS) -c $^)

albert's avatar
albert committed
143
w uptime tload free vmstat utmp pgrep: % : %.o
csmall's avatar
csmall committed
144 145 146 147 148 149 150 151
	$(strip $(CC) $(LDFLAGS) -o $@ $< $(LIB_TGT) $(EXTRALIBS))


# special instances of link rules (need extra libraries/objects)

top:   % : %.o
	$(strip $(CC)  $(LDFLAGS) -o $@ $^ $(LIB_TGT) $(LIBTERMCAP) $(EXTRALIBS))

albert's avatar
albert committed
152 153 154
oldtop:   % : %.o
	$(strip $(CC)  $(LDFLAGS) -o $@ $^ $(LIB_TGT) $(LIBTERMCAP) $(EXTRALIBS))

csmall's avatar
csmall committed
155 156 157 158 159 160 161 162 163
watch:	% : %.o
	$(strip $(CC) $(SLDFLAGS) -o $@ $< $(LIBCURSES) $(EXTRALIBS))


# special instances of compile rules (need extra defines)
w.o:	w.c
	$(strip $(CC) $(CFLAGS) $(W_SHOWFROM) -c $<)

top.o:	top.c
albert's avatar
albert committed
164 165 166
	$(strip $(CC) $(CFLAGS) -c $<)

oldtop.o:	oldtop.c
csmall's avatar
csmall committed
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
	$(strip $(CC) $(CFLAGS) -fwritable-strings -c $<)

skill.o:	skill.c
	$(strip $(CC) $(CFLAGS) -DSYSV -c $<)

snice:	skill
	ln -f skill snice

kill:	skill
	ln -f skill kill

pkill:	pgrep
	ln -f pgrep pkill

# static pattern installation rules

$(patsubst %,install_%,$(BPROG)): install_%: %
	$(INSTALLBIN) $< $(BINDIR)/$(PREFIX)$<
$(patsubst %,install_%,$(SPROG)): install_%: %
	$(INSTALLBIN) $< $(SBINDIR)/$(PREFIX)$<
$(patsubst %,install_%,$(UPROG)): install_%: %
	$(INSTALLBIN) $< $(USRBINDIR)/$(PREFIX)$<
$(patsubst %,install_%,$(PPROG)): install_%: %
	$(INSTALLBIN) $< $(PROCDIR)/$(PREFIX)$<
$(patsubst %,install_%,$(XSCPT)): install_%: %
	$(INSTALLSCT) $< $(XBINDIR)/$(PREFIX)$<
$(patsubst %,install_%,$(MAN1)) : install_%: %
	$(INSTALLMAN) $< $(MAN1DIR)/$(PREFIX)$<
$(patsubst %,install_%,$(MAN5)) : install_%: %
	$(INSTALLMAN) $< $(MAN5DIR)/$(PREFIX)$<
$(patsubst %,install_%,$(MAN8)) : install_%: %
	$(INSTALLMAN) $< $(MAN8DIR)/$(PREFIX)$<
$(patsubst %,install_%,$(DESKTOP)) : install_%: %
	$(INSTALLSCT $< $(APPLNK)/$(PREFIX)$<

# special case install rules
install_snice: snice install_skill
	cd $(USRBINDIR) && ln -f skill snice
install_kill: snice install_skill
	cd $(USRBINDIR) && ln -f skill kill
install_pkill: pgrep install_pgrep
	cd $(USRBINDIR) && ln -f pgrep pkill

# Find all the source and object files in this directory

SRC      =  $(sort $(wildcard *.c))
OBJ      =  $(SRC:.c=.o)

CVSTAG = ps_$(VERSION)_$(SUBVERSION)_$(MINORVERSION)
FILEVERSION = $(VERSION).$(SUBVERSION).$(MINORVERSION)
dist: archive
archive:
	@cvs -Q tag -F $(CVSTAG)
	@rm -rf /tmp/procps
	@cd /tmp; cvs -Q -d $(CVSROOT) export -r$(CVSTAG) procps || echo GRRRrrrrr -- ignore [export aborted]
	@mv /tmp/procps /tmp/procps-$(FILEVERSION)
	@cd /tmp; tar czSpf procps-$(FILEVERSION).tar.gz procps-$(FILEVERSION)
	@cd /tmp; cp procps-$(FILEVERSION)/procps.lsm procps-$(FILEVERSION).lsm
	@rm -rf /tmp/procps-$(FILEVERSION)
	@echo "The final archive is /tmp/procps-$(FILEVERSION).tar.gz"