[KLUG Programming] Makefile Hell
Peter Buxton
programming@kalamazoolinux.org
Wed, 27 Aug 2003 23:40:31 -0400
--EVF5PPMfhYS0aIcm
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Okay. This is the Makefile for Rik van Riel's procps package. I am
trying to Debianize it, which means, in part, installing the files under
a subdir instead of under /. I get to:
gcc -D_GNU_SOURCE -O3 -Wall -Wstrict-prototypes -Wshadow
-I/var/home/peter/newproc/procps-surriel-2.0.11 -I/usr/include/ncurses
-I/usr/X11R6/include -Wl,-warn-common sysctl.c proc/libproc.so.2.0.11 -o sysctl
install --strip sysctl /var/home/peter/newproc/procps-surriel-2.0.11/debian/procps-surriel/sbin/sysctl
install: cannot create regular file `/var/home/peter/newproc/procps-surriel-2.0.11/debian/procps-surriel/sbin/sysctl':
No such file or directory
make[1]: *** [install_sysctl] Error 1
make[1]: Leaving directory `/var/home/peter/newproc/procps-surriel-2.0.11'
make: *** [install-arch] Error 2
I get these files:
debian/procps-surriel
debian/procps-surriel/usr
debian/procps-surriel/usr/bin
debian/procps-surriel/usr/bin/w
debian/procps-surriel/usr/bin/top
debian/procps-surriel/usr/bin/free
debian/procps-surriel/usr/bin/pmap
debian/procps-surriel/usr/bin/oldps
debian/procps-surriel/usr/bin/pgrep
debian/procps-surriel/usr/bin/pkill
debian/procps-surriel/usr/bin/skill
debian/procps-surriel/usr/bin/snice
debian/procps-surriel/usr/bin/tload
debian/procps-surriel/usr/bin/watch
debian/procps-surriel/usr/bin/uptime
debian/procps-surriel/usr/bin/vmstat
debian/procps-surriel/usr/sbin
but as you can see make shies away from creating 'debian/procps-surriel/sbin'.
Can anyone tell me why? Or where I put the command to create those
directories? TIA.
--
-23
I noticed that options had a tendency of sucking in very
intelligent people and blowing them up. -- Nassim Taleb
--EVF5PPMfhYS0aIcm
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=Makefile
# 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 DESTDIR = debian/procps-surriel
export MANDIR = /usr/share/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 OWNERGROUP =
#export OWNERGROUP = --owner 0 --group 0
export INSTALLBIN = install --strip
export INSTALLLIB = install
export INSTALLSCT = install
export INSTALLMAN = install --mode a=r
UPROG = oldps uptime tload free w top vmstat watch skill snice pmap # -> USRBINDIR
PPROG = pgrep pkill# -> PROCDIR
SPROG = sysctl
MAN1 = oldps.1 uptime.1 tload.1 free.1 w.1 top.1 watch.1 skill.1 snice.1 pgrep.1 pkill.1
MAN5 = sysctl.conf.5
MAN8 = vmstat.8 sysctl.8 # psupdate.8
SUBDIRS = ps # sub-packages to build/install
# easy to command-line override
export GCC_WARN = -Wall -Wstrict-prototypes -Wshadow
export INCDIRS = -I/usr/include/ncurses -I/usr/X11R6/include
export CC = gcc #-ggdb # this gets compiling and linking :-)
export OPT = -O3
export CFLAGS = -D_GNU_SOURCE $(OPT) $(GCC_WARN) -I$(shell pwd) $(INCDIRS)
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
export SHLDFLAGS = $(LDFLAGS)
#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. #
#----------------------------------------------------#
# Procps VERSION, could be higher than LIBVERSION...
# Note: if you change this, please adjust procps.spec too
VERSION = 2
SUBVERSION = 0
MINORVERSION = 11
# 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.
LIBVERSION = 2.0.11
BUILD = $(UPROG) $(PPROG) $(SPROG) $(SUBDIRS)
# BUILD LIBRARIES + PROGRAMS
all: $(BUILD)
# INSTALL PROGRAMS + DOCS
install: $(patsubst %,install_%,$(BUILD) $(MAN1) $(MAN5) $(MAN8))
ifeq ($(SHARED),1)
$(INSTALLLIB) $(OWNERGROUP) $(LIB_TGT) $(SHLIBDIR)
endif
# INSTALL LIBRARIES + HEADERS (OPTIONAL)
libinstall:
$(MAKE) -C proc install $(LIBPROCPASS)
clean:
@echo 'Making clean'
@$(RM) -f $(OBJ) $(UPROG) $(PPROG) $(SPROG)
@for i in proc $(SUBDIRS); do $(MAKE) -C $$i clean; done
distclean: clean
@echo 'Making distclean'
@for i in proc $(SUBDIRS); do $(MAKE) -C $$i clean; done
@$(RM) -f $(OBJ) $(UPROG) $(SPROG) \
proc/signames.h proc/.depend
@find . -name SCCS -prune -o -name BitKeeper -prune -o \
\( -not -type d \) -and \
\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
-o -name '*.bak' -o -name core -o -name '*.o' \
-o -name '*.tmp' -o -size 0 \) \
-type f -print | xargs rm -rf
#-----------------------------------------------------#
# End of user-callable make targets. #
# You should not need to read anything below this. #
#-----------------------------------------------------#
.PHONY: all install libinstall clean distclean
.PHONY: $(patsubst %,install_%, $(UPROG) $(SPROG))
.PHONY: proc ps
.PHONY: $(patsubst %,build_%, proc ps)
.PHONY: $(patsubst %,install_%, proc ps)
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])
$(MAKE) -C proc `basename $(LIB_TGT)` $(LIBPROCPASS)
proc/signames.h:
$(MAKE) -C proc `basename $@`
# 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
build_ps: ; $(MAKE) -C ps
install_ps: ps ; $(MAKE) -C ps install
# executable dependencies
oldps skill snice top w uptime tload free vmstat utmp sysctl: $(LIB_TGT)
# static pattern build/link rules:
%.o : %.c
$(strip $(CC) $(CFLAGS) -c $^)
oldps w uptime tload free vmstat utmp pgrep: % : %.o
$(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))
watch: % : %.o
$(strip $(CC) $(LDFLAGS) -o $@ $< $(LIB_TGT) $(LIBCURSES) $(EXTRALIBS))
# special instances of compile rules (need extra defines)
w.o: w.c
$(strip $(CC) $(CFLAGS) $(W_SHOWFROM) -c $<)
top.o: top.c
$(strip $(CC) $(CFLAGS) -fwritable-strings -c $<)
skill.o: skill.c
$(strip $(CC) $(CFLAGS) -DSYSV -c $<)
snice: skill
ln -f skill snice
pkill: pgrep
ln -f pgrep pkill
# static pattern installation rules
$(patsubst %,install_%,$(SPROG)): install_%: %
$(INSTALLBIN) $< $(SBINDIR)/$(PREFIX)$<
$(patsubst %,install_%,$(filter-out snice,$(UPROG))): install_%: %
$(INSTALLBIN) $< $(USRBINDIR)/$(PREFIX)$<
$(patsubst %,install_%,$(filter-out pkill,$(PPROG))): install_%: %
$(INSTALLBIN) $< $(PROCDIR)/$(PREFIX)$<
$(patsubst %,install_%,$(MAN1)) : install_%: %
$(INSTALLMAN) $< $(MAN1DIR)/$(PREFIX)$<
$(patsubst %,install_%,$(MAN5)) : install_%: %
$(INSTALLMAN) $< $(MAN5DIR)/$(PREFIX)$<
$(patsubst %,install_%,$(MAN8)) : install_%: %
$(INSTALLMAN) $< $(MAN8DIR)/$(PREFIX)$<
# special case install rules
install_snice: snice install_skill
cd $(USRBINDIR) && ln -f skill snice
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"
--EVF5PPMfhYS0aIcm--