]> granicus.if.org Git - procps-ng/commitdiff
make considered harmful
authoralbert <>
Thu, 10 Oct 2002 07:08:13 +0000 (07:08 +0000)
committeralbert <>
Thu, 10 Oct 2002 07:08:13 +0000 (07:08 +0000)
proc/module.mk
ps/module.mk

index 15ef7e5635dc7c36dcc8e90d085b34ce41458bdc..b558ecf0ffe3c84fa230b7c9f4f5636b38253ed2 100644 (file)
@@ -1,53 +1,56 @@
-# Google "recursive make considered harmful" for how this works.
+# This file gets included into the main Makefile, in the top directory.
 
-SRC += $(wildcard proc/*.c) $(wildcard proc/*.c)
+NAME      :=  proc
 
-------
+LIBSRC += $(wildcard proc/*.c)
 
-# PROJECT SPECIFIC MACROS
-NAME       =  proc
+SONAME    :=  lib$(NAME).so.$(LIBVERSION)
 
-# INSTALLATION OPTIONS
-TOPDIR     = /usr
-HDRDIR     = $(TOPDIR)/include/$(NAME)#        where to put .h files
-LIBDIR     = $(TOPDIR)/lib#            where to put library files
-SHLIBDIR   = /lib#                     where to put shared library files
-HDROWN     = $(OWNERGROUP) #           owner of header files
-LIBOWN     = $(OWNERGROUP) #           owner of library files
-INSTALL    = install
+ALL        += proc/lib$(NAME).a
+INSTALL    += $(lib)/lib$(NAME).a
+LIB_CFLAGS := $(CFLAGS)
 
-SRC        =  $(sort $(wildcard *.c) $(filter %.c,$(RCSFILES)))
-HDR        =  $(sort $(wildcard *.h) $(filter %.h,$(RCSFILES)))
-OBJ        =  $(SRC:.c=.o)
+ifeq ($(SHARED),1)
+ALL        += proc/$(SONAME)
+INSTALL    += $(lib)/$(SONAME)
+LIB_CFLAGS += -fpic
+endif
 
+# clean away all output files, .depend, and symlinks
+CLEAN += $(addprefix proc/,$(ALL) .depend)
 
-SONAME     =  lib$(NAME).so.$(LIBVERSION)
+------
+
+# 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
+
+SRC       :=  $(sort $(wildcard *.c) $(filter %.c,$(RCSFILES)))
+HDR       :=  $(sort $(wildcard *.h) $(filter %.h,$(RCSFILES)))
+OBJ       :=  $(SRC:.c=.o)
 
-ifeq ($(SHARED),1)
-CFLAGS += -fpic
-all: lib$(NAME).a $(SONAME)
-else
-all: lib$(NAME).a
-endif
 
-lib$(NAME).a: $(OBJ)
+proc/lib$(NAME).a: $(OBJ)
        $(AR) rcs $@ $^
 
-$(SONAME): $(OBJ)
+proc/$(SONAME): $(OBJ)
        gcc -shared -Wl,-soname,$(SONAME) -o $@ $^ -lc
        ln -sf $(SONAME) lib$(NAME).so
 
 
 # AUTOMATIC DEPENDENCY GENERATION -- GCC AND GNUMAKE DEPENDENT
 .depend:
-       $(strip $(CC) $(CFLAGS) -MM -MG $(SRC) > .depend)
+       $(strip $(CC) $(LIB_CFLAGS) -MM -MG $(SRC) > .depend)
 -include .depend
 
 
 # INSTALLATION
 install: all
        if ! [ -d $(HDRDIR) ] ; then mkdir $(HDRDIR) ; fi
-       $(INSTALL) $(HDROWN) $(HDR) $(TOPDIR)/include/$(NAME)
+       $(INSTALL) $(HDROWN) $(HDR) /usr/include/$(NAME)
        $(INSTALL) $(LIBOWN) lib$(NAME).a $(LIBDIR)
 ifeq ($(SHARED),1)
        $(INSTALL) $(LIBOWN) $(SONAME) $(SHLIBDIR)
@@ -58,12 +61,12 @@ endif
 
 # CUSTOM c -> o rule so that command-line has minimal whitespace
 %.o : %.c
-       $(strip $(CC) $(CFLAGS) -c $<)
+       $(strip $(CC) $(LIB_CFLAGS) -c $<)
 
 
 version.o:     version.c version.h
 ifdef MINORVERSION
-       $(strip $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\" -c version.c)
+       $(strip $(CC) $(LIB_CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\" -c version.c)
 else
-       $(strip $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -c version.c)
+       $(strip $(CC) $(LIB_CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -c version.c)
 endif
index d0d16c2234585fc53e794ddda3000c61fae26a70..e75474851851f90118b39f89f638f3d928f2ae08 100755 (executable)
@@ -1,8 +1,15 @@
-INSTALL += install_ps
+# This file gets included into the main Makefile, in the top directory.
 
------
+INSTALL += $(bin)ps
 
-all: ps
+# a file to remove
+CLEAN += ps/ps
+
+# a directory for cleaning
+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
@@ -30,10 +37,7 @@ display.o: display.c common.h
 stacktrace.o: stacktrace.c
 
 
-install: ps
+$(bin)ps: ps
        install $(OWNERGROUP) --mode a=rx --strip ps $(BINDIR)/ps
        install $(OWNERGROUP) --mode a=r ps.1 $(MAN1DIR)/ps.1
        -rm -f $(DESTDIR)/var/catman/cat1/ps.1.gz $(DESTDIR)/var/man/cat1/ps.1.gz
-
-clean:
-       rm -f *.o DEADJOE *~ core ps gmon.out