Commit 5ef0ba1b authored by albert's avatar albert

make considered very harmful

parent c8b28e14
# 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)
# 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
# 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
SRC := $(sort $(wildcard *.c) $(filter %.c,$(RCSFILES)))
HDR := $(sort $(wildcard *.h) $(filter %.h,$(RCSFILES)))
OBJ := $(SRC:.c=.o)
#proc/lib$(NAME).a: $(LIBOBJ)
# $(AR) rcs $@ $^
proc/$(SONAME): $(LIBOBJ)
$(CC) -shared -Wl,-soname,$(SONAME) -o $@ $^ -lc
cd proc && $(ln-sf) $(SONAME) lib$(NAME).so
proc/lib$(NAME).a: $(OBJ)
$(AR) rcs $@ $^
proc/$(SONAME): $(OBJ)
gcc -shared -Wl,-soname,$(SONAME) -o $@ $^ -lc
ln -sf $(SONAME) lib$(NAME).so
# AUTOMATIC DEPENDENCY GENERATION -- GCC AND GNUMAKE DEPENDENT
proc/.depend: $(LIBSRC) $(LIBHDR)
$(strip $(CC) $(LIB_CFLAGS) -MM -MG $(LIBSRC) > $@)
-include proc/.depend
# AUTOMATIC DEPENDENCY GENERATION -- GCC AND GNUMAKE DEPENDENT
.depend:
$(strip $(CC) $(LIB_CFLAGS) -MM -MG $(SRC) > .depend)
-include .depend
$(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 $< $@
# 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
# 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
......@@ -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))
# 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
sortformat.o: sortformat.c common.h
global.o: global.c common.h
escape.o: escape.c
ps/ps: $(PSOBJ) $(LIBPROC)
$(CC) $(LDFLAGS) -o $@ $^
help.o: help.c
select.o: select.c common.h
output.o: output.c common.h
# This just adds the stacktrace code
ps/debug: $(PSOBJ) stacktrace.o $(LIBPROC)
$(CC) -o $@ $^ -lefence
parser.o: parser.c common.h
$(PSOBJ): %.o: ps/%.c ps/common.h proc/$(SONAME)
# $(CC) -c $(CFLAGS) $< -o $@
display.o: display.c common.h
ps/stacktrace.o: ps/stacktrace.c
stacktrace.o: stacktrace.c
$(bin)ps: ps/ps
install --mode a=rx --strip $< $@
$(bin)ps: ps
install $(OWNERGROUP) --mode a=rx --strip ps $(BINDIR)/ps
install $(OWNERGROUP) --mode a=r ps.1 $(MAN1DIR)/ps.1
$(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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment