File: Makefile

package info (click to toggle)
procps 1%3A2.0.6-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 932 kB
  • ctags: 1,146
  • sloc: ansic: 10,494; makefile: 229; sh: 80
file content (104 lines) | stat: -rw-r--r-- 3,077 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Auto-adaptive C library Makefile adapted for libproc, Chuck Blake.
# Assumptions are basically that all the .c files in the CWD are modules
# for the library and that all .h files are the interface to the library.

# PROJECT SPECIFIC MACROS
NAME       =  proc

# INSTALLATION OPTIONS
DESTDIR    = /
TOPDIR     = ${DESTDIR}/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     = -o root -g root -m 644 #		owner of header files
LIBOWN     = -o root -g root #		owner of library files
INSTALL    = install

# COMPILATION OPTIONS
CC         =  gcc -O2 -D_GNU_SOURCE #-ggdb # easy to command-line override
#CC         =  gcc -pg -O2 -D_GNU_SOURCE -g3 # easy to command-line override
CFLAGS     =  -I.. -W -Wall -Wstrict-prototypes -Wshadow -Wcast-align

# ----------------------------------------------------------------#
# The rest is the auto-magic section -- highly GNU make dependent #
# You should never need to edit this.                             #
# ----------------------------------------------------------------#

VC_SUF     =  ,v
VC_PFX     =  RCS/
RCSFILES   =  $(patsubst $(VC_PFX)%$(VC_SUF),%,$(wildcard $(VC_PFX)*$(VC_SUF)))

# We take the union of RCS files and other files in CWD so that new files do
# not need to alter this makefile.  'sort' removes duplicates.  This allows the
# convenience of compiling and testing new files before the initial check-in.

SRC        =  $(sort $(wildcard *.c) $(filter %.c,$(RCSFILES)))
HDR        =  $(sort $(wildcard *.h) $(filter %.h,$(RCSFILES)))

OBJ        =  $(SRC:.c=.o)
SONAME     =  lib$(NAME).so.$(LIBVERSION)

ifeq ($(SHARED),1)
CFLAGS += -fpic
all: lib$(NAME).a $(SONAME)
else
all: lib$(NAME).a
endif

lib$(NAME).a: $(OBJ)
	$(AR) rcs $@ $^

$(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)
-include .depend

# INSTALLATION

install: all
	if ! [ -d $(HDRDIR) ] ; then mkdir $(HDRDIR) ; fi
	$(INSTALL) $(HDROWN) $(HDR) $(TOPDIR)/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

# VARIOUS SHORT CUT TARGETS
.PHONY:	all install dep clean distclean checkout checkclean

dep:	.depend

clean:
	$(RM) lib$(NAME).* *.o DEADJOE

distclean:	clean
	$(RM) .depend *~

checkout:
	$(CO) $(RCSFILES)

checkclean:
	$(RM) $(RCSFILES)

# CUSTOM c -> o rule so that command-line has minimal whitespace

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

# PROJECT SPECIFIC DEPENDENCIES/BUILD RULES


version.o:	version.c version.h
ifdef MINORVERSION
	$(strip $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\" -c version.c)
else
	$(strip $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -c version.c)
endif