make considered very harmful

This commit is contained in:
albert 2002-10-10 09:11:50 +00:00
parent c8b28e1405
commit 5ef0ba1b18
2 changed files with 54 additions and 64 deletions

View File

@ -1,62 +1,59 @@
# This file gets included into the main Makefile, in the top directory.
# for lib$(NAME).so and /usr/include/($NAME) and such
NAME := proc
LIBSRC += $(wildcard proc/*.c)
SHARED := 1
SONAME := lib$(NAME).so.$(LIBVERSION)
ALL += proc/lib$(NAME).a
INSTALL += $(lib)/lib$(NAME).a
#ALL += proc/lib$(NAME).a
#INSTALL += $(usr/lib)/lib$(NAME).a # plus $(usr/include)$(NAME) gunk
LIB_CFLAGS := $(CFLAGS)
ifeq ($(SHARED),1)
ALL += proc/$(SONAME)
INSTALL += $(lib)/$(SONAME)
LIB_CFLAGS += -fpic
LIBPROC := proc/$(SONAME)
else
LIBPROC := proc/lib$(NAME).a
endif
# clean away all output files, .depend, and symlinks
CLEAN += $(addprefix proc/,$(ALL) .depend)
LIBSRC := $(wildcard proc/*.c)
LIBHDR := $(wildcard proc/*.h)
LIBOBJ := $(LIBSRC:.c=.o)
------
# Clean away all output files, .depend, and symlinks.
# Use wildcards in case the version has changed.
CLEAN += proc/.depend proc/lib*.so* proc/lib*.a $(LIBOBJ)
DIRS += proc
# INSTALLATION OPTIONS
HDRDIR := /usr/include/$(NAME)# where to put .h files
LIBDIR := /usr/lib# where to put library files
HDROWN := $(OWNERGROUP) # owner of header files
LIBOWN := $(OWNERGROUP) # owner of library files
INSTALL := install
#proc/lib$(NAME).a: $(LIBOBJ)
# $(AR) rcs $@ $^
SRC := $(sort $(wildcard *.c) $(filter %.c,$(RCSFILES)))
HDR := $(sort $(wildcard *.h) $(filter %.h,$(RCSFILES)))
OBJ := $(SRC:.c=.o)
proc/lib$(NAME).a: $(OBJ)
$(AR) rcs $@ $^
proc/$(SONAME): $(OBJ)
gcc -shared -Wl,-soname,$(SONAME) -o $@ $^ -lc
ln -sf $(SONAME) lib$(NAME).so
proc/$(SONAME): $(LIBOBJ)
$(CC) -shared -Wl,-soname,$(SONAME) -o $@ $^ -lc
cd proc && $(ln-sf) $(SONAME) lib$(NAME).so
# AUTOMATIC DEPENDENCY GENERATION -- GCC AND GNUMAKE DEPENDENT
.depend:
$(strip $(CC) $(LIB_CFLAGS) -MM -MG $(SRC) > .depend)
-include .depend
proc/.depend: $(LIBSRC) $(LIBHDR)
$(strip $(CC) $(LIB_CFLAGS) -MM -MG $(LIBSRC) > $@)
-include proc/.depend
# INSTALLATION
install: all
if ! [ -d $(HDRDIR) ] ; then mkdir $(HDRDIR) ; fi
$(INSTALL) $(HDROWN) $(HDR) /usr/include/$(NAME)
$(INSTALL) $(LIBOWN) lib$(NAME).a $(LIBDIR)
ifeq ($(SHARED),1)
$(INSTALL) $(LIBOWN) $(SONAME) $(SHLIBDIR)
cd $(SHLIBDIR) && ln -sf $(SONAME) lib$(NAME).so
ldconfig
endif
$(lib)/$(SONAME) : proc/$(SONAME)
$(install) --mode a=rx --strip $< $@
cd $(lib) && $(ln-sf) $(SONAME) lib$(NAME).so
$(ldconfig)
#$(usr/lib)/lib$(NAME).a : proc/lib$(NAME).a
# $(install) --mode a=r --strip $< $@
# Junk anyway... supposed to go in /usr/include/$(NAME)
#$(HDRFILES) ??? : $(addprefix proc/,$(HDRFILES)) ???
# $(install) --mode a=r $< $@
# CUSTOM c -> o rule so that command-line has minimal whitespace
@ -64,9 +61,9 @@ endif
$(strip $(CC) $(LIB_CFLAGS) -c $<)
version.o: version.c version.h
proc/version.o: proc/version.c proc/version.h
ifdef MINORVERSION
$(strip $(CC) $(LIB_CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\" -c version.c)
$(strip $(CC) $(LIB_CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\" -c proc/version.c)
else
$(strip $(CC) $(LIB_CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -c version.c)
$(strip $(CC) $(LIB_CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -c proc/version.c)
endif

View File

@ -2,8 +2,8 @@
INSTALL += $(bin)ps
# a file to remove
CLEAN += ps/ps
# files to remove
CLEAN += ps/ps ps/debug
# a directory for cleaning
DIRS += ps
@ -11,33 +11,26 @@ DIRS += ps
# a file to create
ALL += ps/ps
ps: escape.o global.o help.o select.o sortformat.o output.o parser.o display.o
$(CC) -o ps escape.o global.o help.o select.o sortformat.o output.o parser.o display.o -L../proc -lproc
PSNAMES := $(addprefix ps/,display escape global help output parser select sortformat)
PSOBJ := $(addsuffix .o,$(PSNAMES))
PSSRC := $(addsuffix .c,$(PSNAMES))
ps/ps: $(PSOBJ) $(LIBPROC)
$(CC) $(LDFLAGS) -o $@ $^
# This just adds the stacktrace code
debug: escape.o global.o help.o select.o sortformat.o output.o parser.o display.o stacktrace.o
$(CC) -o ps escape.o global.o help.o select.o sortformat.o output.o parser.o display.o stacktrace.o -L../proc -lproc -lefence
ps/debug: $(PSOBJ) stacktrace.o $(LIBPROC)
$(CC) -o $@ $^ -lefence
sortformat.o: sortformat.c common.h
$(PSOBJ): %.o: ps/%.c ps/common.h proc/$(SONAME)
# $(CC) -c $(CFLAGS) $< -o $@
global.o: global.c common.h
escape.o: escape.c
help.o: help.c
select.o: select.c common.h
output.o: output.c common.h
parser.o: parser.c common.h
display.o: display.c common.h
stacktrace.o: stacktrace.c
ps/stacktrace.o: ps/stacktrace.c
$(bin)ps: ps
install $(OWNERGROUP) --mode a=rx --strip ps $(BINDIR)/ps
install $(OWNERGROUP) --mode a=r ps.1 $(MAN1DIR)/ps.1
$(bin)ps: ps/ps
install --mode a=rx --strip $< $@
$(man1)ps.1 : ps/ps.1
install --mode a=r $< $@
-rm -f $(DESTDIR)/var/catman/cat1/ps.1.gz $(DESTDIR)/var/man/cat1/ps.1.gz