date and time created 90/02/02 17:24:10 by bostic
[unix-history] / usr / src / share / mk / bsd.prog.mk
CommitLineData
2cf63a09
KB
1
2MAKE= pmake # for now...
c27da6a8 3CPP= newcpp
2cf63a09
KB
4
5# libraries used for dependency lines
68cbfc75 6LIBUTIL= /usr/lib/libutil.a
2cf63a09
KB
7LIBMATH= /usr/lib/libm.a
8LIBKRB= /usr/lib/libkrb.a
9LIBDES= /usr/lib/libdes.a
10LIBCOMPAT= /usr/lib/libcompat.a
272f5bac 11
2cf63a09
KB
12# any specified manual pages -- if none have been specified at this point,
13# we make assumptions about what they are and what they're called.
14MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
68cbfc75 15
2cf63a09
KB
16# user defines:
17# SUBDIR -- the list of subdirectories to be processed
18#
19# if SUBDIR is set, we're in a makefile that processes subdirectories;
20# for all the standard targets, change to the subdirectory and make the
21# target. If making one of the subdirectories, change to it and make
22# the target "all". Machine dependent subdirectories take precedence
23# over standard subdirectories.
24.if defined(SUBDIR)
c27da6a8 25all depend clean cleandir lint install tags:
2cf63a09 26 @for entry in ${SUBDIR}; do
c27da6a8 27 (echo "====> $$entry"
2cf63a09
KB
28 if test -d $${entry}.${MACHINE}; then
29 cd $${entry}.${MACHINE}
30 else
31 cd $${entry}
32 fi
33 ${MAKE} ${.TARGET})
34 done
68cbfc75 35
2cf63a09
KB
36${SUBDIR}:
37 @if test -d ${.TARGET}.${MACHINE}; then
38 cd ${.TARGET}.${MACHINE}
39 else
40 cd ${.TARGET}
41 fi
42 ${MAKE} all
43
44.else # !SUBDIR
45
46# user defines:
47# SHAREDSTRINGS -- boolean variable, if sharing strings in objects.
48#
49# if SHAREDSTRINGS is defined, use XSTR to build objects.
50#
51.if defined(SHAREDSTRINGS)
52.NOTPARALLEL:
53XSTR= xstr
54.c.o:
55 ${CC} -E ${.INCLUDES} ${CFLAGS} ${.IMPSRC} | ${XSTR} -c -
56 @${CC} ${.INCLUDES} ${CFLAGS} -c x.c -o ${.TARGET}
57 @rm -f x.c
58.endif
68cbfc75 59
2cf63a09 60# the default target is all
68cbfc75 61.MAIN: all
2cf63a09
KB
62
63# user defines:
64# PROGC -- the name of a program composed of a single source module
65# PROGO -- the name of a program composed of several object modules
66# SRCLIB -- the list of libraries that the program depends on;
67# normally from the LIB* list at the top of this file.
68# LDLIB -- the list of libraries that the program loads, in the
69# format expected by the loader.
70
272f5bac
KB
71all: ${PROGC} ${PROGO}
72
2cf63a09
KB
73# if the program is composed of a single source module, that module is
74# C source with the same name as the program. If no manual pages have
75# been defined, it's in section 1 with the same name as the program.
272f5bac
KB
76.if defined(PROGC)
77SRCS= ${PROGC}.c
78
c27da6a8 79.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && !defined(MAN7) && !defined(MAN8)
2cf63a09
KB
80MAN1= ${PROGC}.0
81.endif
272f5bac 82
2cf63a09
KB
83${PROGC}: ${SRCS} ${LIBC} ${SRCLIB}
84 ${CC} ${CFLAGS} -o ${.TARGET} ${SRCS} ${LDLIB}
272f5bac 85
c27da6a8
KB
86.depend: ${SRCS}
87 set -
88 ${CPP} -M ${CFLAGS:M-[ID]*} ${.INCLUDES} ${.ALLSRC} |
89 sed "s/^/${PROGC}: /" > ${DEPENDFILE}.new
90 mv ${DEPENDFILE}.new ${DEPENDFILE}
68cbfc75 91
2cf63a09 92.endif # PROGC
272f5bac 93
2cf63a09
KB
94# if the program is composed of several object modules, the modules are
95# the list of sources with the .o's translated to .c's. If no manual
96# pages have been defined, it's in section 1 with the same name as the
97# program. Objects depend on their C source counterparts.
68cbfc75 98.if defined(PROGO)
2cf63a09 99
68cbfc75 100OBJS= ${SRCS:.c=.o}
272f5bac 101
c27da6a8 102.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && !defined(MAN7) && !defined(MAN8)
2cf63a09
KB
103MAN1= ${PROGO}.0
104.endif
105
68cbfc75 106${PROGO}: ${OBJS} ${LIBC} ${SRCLIB}
2cf63a09 107 ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDLIB}
272f5bac 108
c27da6a8
KB
109.depend: ${SRCS}
110 set -
111 set ${OBJS}
112 rm -f ${DEPENDFILE}.new
113 for entry in ${.ALLSRC}; do
114 ${CPP} -M ${CFLAGS:M-[ID]*} ${.INCLUDES} $$entry |
115 sed "s/^/$$1: /" >> ${DEPENDFILE}.new
116 shift
117 done
118 mv ${DEPENDFILE}.new ${DEPENDFILE}
272f5bac 119
68cbfc75
KB
120${OBJS}: ${.PREFIX}.c
121
2cf63a09 122.endif # PROGO
272f5bac 123
c27da6a8
KB
124depend: .depend
125
2cf63a09
KB
126# user defines:
127# CLEANFILES -- list of files to be removed for the target clean;
128# used, for example, to specify .c's produced from
129# .y's.
c27da6a8 130JUNKFILES= a.out Errs errs mklog core
2cf63a09 131clean:
c27da6a8 132 rm -f ${PROGC} ${PROGO} ${OBJS} ${CLEANFILES} ${JUNKFILES}
272f5bac 133
2cf63a09 134TAGSFILE= tags
272f5bac
KB
135cleandir: clean
136 rm -f ${MANALL} ${TAGSFILE} ${DEPENDFILE}
137
68cbfc75
KB
138LINTFLAGS= -chapbx
139lint: ${SRCS}
140 lint ${LINTFLAGS} ${CFLAGS} ${.ALLSRC}
141
68cbfc75
KB
142tags: ${SRCS}
143 ctags ${.ALLSRC}
144
2cf63a09 145# user defines:
c27da6a8 146# MDIR -- default manual page installation directory
2cf63a09
KB
147# MANMODE -- default manual page installation mode
148# STRIP -- default strip flag
149# BINMODE -- default binary installation mode
150# BINOWN -- default binary owner
151# BINGRP -- default binary group
c27da6a8 152MDIR?= /usr/share/man/cat
2cf63a09
KB
153MANMODE?= 444
154STRIP?= -s
155BINMODE?= 755
156BINOWN?= bin
157BINGRP?= bin
158
159# install target -- creates manual pages, then installs the binaries,
160# manual pages, and manual page links.
272f5bac 161install: ${MANALL}
2cf63a09 162 install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
68cbfc75 163 ${PROGC} ${PROGO} ${DESTDIR}${DIR}
272f5bac 164.if defined(MAN1)
2cf63a09
KB
165 install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN1} \
166 ${DESTDIR}${MDIR}1
167.endif
272f5bac 168.if defined(MAN2)
2cf63a09
KB
169 install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN2} \
170 ${DESTDIR}${MDIR}2
171.endif
272f5bac 172.if defined(MAN3)
2cf63a09
KB
173 install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN3} \
174 ${DESTDIR}${MDIR}3
175.endif
272f5bac 176.if defined(MAN4)
2cf63a09
KB
177 install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN4} \
178 ${DESTDIR}${MDIR}4
179.endif
272f5bac 180.if defined(MAN5)
2cf63a09
KB
181 install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN5} \
182 ${DESTDIR}${MDIR}5
183.endif
272f5bac 184.if defined(MAN6)
2cf63a09
KB
185 install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN6} \
186 ${DESTDIR}${MDIR}6
187.endif
272f5bac 188.if defined(MAN7)
2cf63a09
KB
189 install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN7} \
190 ${DESTDIR}${MDIR}7
272f5bac 191.endif
2cf63a09
KB
192.if defined(MAN8)
193 install -c -o ${BINOWN} -g ${BINGRP} -m ${MANMODE} ${MAN8} \
194 ${DESTDIR}${MDIR}8
272f5bac 195.endif
2cf63a09 196# user defines:
c27da6a8
KB
197# LINKS -- list of binary links of the form "link target
198# link target"; for example, "/bin/[ /usr/bin/test"
199# would link /bin/[ to /usr/bin/test"; not particularly
200# labor saving, but prevents needing your own install
201# target.
202# MLINKS -- list of manual page linkes of the form "link target
2cf63a09
KB
203# link target"; for example, "a.1 b.2 c.3 d.4" would
204# link ${MDIR}1/a.0 to ${MDIR}2/b.0 and ${MDIR}3/c.0
205# to ${MDIR}4/d.0.
206.if defined(LINKS)
c27da6a8
KB
207 @set ${LINKS}
208 @while :; do
209 if `test $$# -lt 2`; then
210 break;
211 fi
212 t=$$1
213 shift
214 l=$$1
215 shift
216 echo $$l -\> $$t
217 rm -f $$t
218 ln ${DESTDIR}$$l ${DESTDIR}$$t
219 done
220.endif # LINKS
221.if defined(MLINKS)
222 @set ${MLINKS}
2cf63a09
KB
223 @while :; do
224 if `test $$# -lt 2`; then
225 break;
226 fi
227 name=$$1
2cf63a09 228 shift
c27da6a8
KB
229 dir=${MDIR}`expr $$name : '[^\.]*\.\(.*\)'`
230 t=${DESTDIR}$${dir}/`expr $$name : '\([^\.]*\)'`.0
2cf63a09 231 name=$$1
c27da6a8
KB
232 shift
233 dir=${MDIR}`expr $$name : '[^\.]*\.\(.*\)'`
2cf63a09 234 l=${DESTDIR}$${dir}/`expr $$name : '\([^\.]*\)'`.0
2cf63a09 235 echo $$l -\> $$t
c27da6a8 236 rm -f $$t
2cf63a09 237 ln $$l $$t
2cf63a09 238 done
c27da6a8 239.endif # MLINKS
2cf63a09 240.endif # SUBDIR