BSD 4_3_Reno release
[unix-history] / usr / src / share / mk / bsd.prog.mk
index cc311f8..406f015 100644 (file)
@@ -1,3 +1,5 @@
+#      @(#)bsd.prog.mk 5.20 (Berkeley) 6/29/90
+
 .if exists(${.CURDIR}/../Makefile.inc)
 .include "${.CURDIR}/../Makefile.inc"
 .endif
 .if exists(${.CURDIR}/../Makefile.inc)
 .include "${.CURDIR}/../Makefile.inc"
 .endif
@@ -5,11 +7,17 @@
 .SUFFIXES: .out .o .c .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
 
 .8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
 .SUFFIXES: .out .o .c .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
 
 .8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
-       nroff -man -h ${.IMPSRC} > ${.TARGET}
+       nroff -mandoc -h ${.IMPSRC} > ${.TARGET}
 
 CFLAGS+=${COPTS}
 
 
 CFLAGS+=${COPTS}
 
-LIBC?=         /lib/libc.a
+STRIP?=        -s
+
+BINGRP?=       bin
+BINOWN?=       bin
+BINMODE?=      555
+
+LIBC?=         /usr/lib/libc.a
 LIBCOMPAT?=    /usr/lib/libcompat.a
 LIBCURSES?=    /usr/lib/libcurses.a
 LIBDBM?=       /usr/lib/libdbm.a
 LIBCOMPAT?=    /usr/lib/libcompat.a
 LIBCURSES?=    /usr/lib/libcurses.a
 LIBDBM?=       /usr/lib/libdbm.a
@@ -21,13 +29,15 @@ LIBM?=              /usr/lib/libm.a
 LIBMP?=                /usr/lib/libmp.a
 LIBPC?=                /usr/lib/libpc.a
 LIBPLOT?=      /usr/lib/libplot.a
 LIBMP?=                /usr/lib/libmp.a
 LIBPC?=                /usr/lib/libpc.a
 LIBPLOT?=      /usr/lib/libplot.a
+LIBRESOLV?=    /usr/lib/libresolv.a
 LIBRPC?=       /usr/lib/sunrpc.a
 LIBTERM?=      /usr/lib/libterm.a
 LIBUTIL?=      /usr/lib/libutil.a
 
 .if defined(SHAREDSTRINGS)
 LIBRPC?=       /usr/lib/sunrpc.a
 LIBTERM?=      /usr/lib/libterm.a
 LIBUTIL?=      /usr/lib/libutil.a
 
 .if defined(SHAREDSTRINGS)
+CLEANFILES+=strings
 .c.o:
 .c.o:
-       ${CC} -E ${CFLAGS} ${.IMPSRC} | /usr/bin/xstr -c -
+       ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
        @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
        @rm -f x.c
 .endif
        @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
        @rm -f x.c
 .endif
@@ -47,6 +57,8 @@ SRCS= ${PROG}.c
 ${PROG}: ${SRCS} ${LIBC} ${DPADD}
        ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
 
 ${PROG}: ${SRCS} ${LIBC} ${DPADD}
        ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
 
+MKDEP= -p
+
 .endif
 
 .if    !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
 .endif
 
 .if    !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
@@ -57,67 +69,104 @@ MAN1=      ${PROG}.0
 .endif
 MANALL=        ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
 
 .endif
 MANALL=        ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
 
-PROGSUBDIR: .USE
+_PROGSUBDIR: .USE
 .if defined(SUBDIR) && !empty(SUBDIR)
        @for entry in ${SUBDIR}; do \
 .if defined(SUBDIR) && !empty(SUBDIR)
        @for entry in ${SUBDIR}; do \
-               (echo "===> ${PROG}/$$entry"; \
+               (echo "===> $$entry"; \
                if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
                        cd ${.CURDIR}/$${entry}.${MACHINE}; \
                else \
                        cd ${.CURDIR}/$${entry}; \
                fi; \
                if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
                        cd ${.CURDIR}/$${entry}.${MACHINE}; \
                else \
                        cd ${.CURDIR}/$${entry}; \
                fi; \
-               ${MAKE} ${.TARGET}) \
+               ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}) \
        done
 .endif
 
 .MAIN: all
        done
 .endif
 
 .MAIN: all
-all: ${PROG} ${MANALL} PROGSUBDIR
+all: ${PROG} ${MANALL} _PROGSUBDIR
 
 .if !target(clean)
 
 .if !target(clean)
-clean: PROGSUBDIR
+clean: _PROGSUBDIR
        rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
 .endif
 
 .if !target(cleandir)
        rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
 .endif
 
 .if !target(cleandir)
-cleandir: PROGSUBDIR
+cleandir: _PROGSUBDIR
        rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
        rm -f .depend ${.CURDIR}/tags ${MANALL}
 .endif
 
 # some of the rules involve .h sources, so remove them from mkdep line
 .if !target(depend)
        rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
        rm -f .depend ${.CURDIR}/tags ${MANALL}
 .endif
 
 # some of the rules involve .h sources, so remove them from mkdep line
 .if !target(depend)
-depend: .depend
-.depend: ${SRCS} PROGSUBDIR
-       mkdep ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
+depend: .depend _PROGSUBDIR
+.depend: ${SRCS}
+.if defined(PROG)
+       mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
+.endif
 .endif
 
 .if !target(install)
 .if !target(beforeinstall)
 beforeinstall:
 .endif
 .endif
 
 .if !target(install)
 .if !target(beforeinstall)
 beforeinstall:
 .endif
+.if !target(afterinstall)
+afterinstall:
+.endif
 
 
-realinstall: beforeinstall PROGSUBDIR
+realinstall: _PROGSUBDIR
+.if defined(PROG)
        install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
            ${PROG} ${DESTDIR}${BINDIR}
        install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
            ${PROG} ${DESTDIR}${BINDIR}
+.endif
 .if defined(HIDEGAME)
        (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
            chown games.bin ${PROG})
 .endif
 .if defined(HIDEGAME)
        (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
            chown games.bin ${PROG})
 .endif
+.if defined(LINKS) && !empty(LINKS)
+       @set ${LINKS}; \
+       while test $$# -ge 2; do \
+               l=${DESTDIR}$$1; \
+               shift; \
+               t=${DESTDIR}$$1; \
+               shift; \
+               echo $$t -\> $$l; \
+               rm -f $$t; \
+               ln $$l $$t; \
+       done; true
+.endif
 
 
-install: afterinstall PROGSUBDIR
-afterinstall: realinstall maninstall
-.else
-install: PROGSUBDIR
+install: maninstall
+maninstall: afterinstall
+afterinstall: realinstall
+realinstall: beforeinstall
 .endif
 
 .if !target(lint)
 .endif
 
 .if !target(lint)
-lint: ${SRCS} PROGSUBDIR
+lint: ${SRCS} _PROGSUBDIR
+.if defined(PROG)
        @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
 .endif
        @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
 .endif
+.endif
+
+.if !target(obj)
+.if defined(NOOBJ)
+obj: _PROGSUBDIR
+.else
+obj: _PROGSUBDIR
+       @cd ${.CURDIR}; rm -rf obj; \
+       here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \
+       echo "$$here -> $$dest"; ln -s $$dest obj
+.endif
+.endif
 
 .if !target(tags)
 
 .if !target(tags)
-tags: ${SRCS} PROGSUBDIR
-       ctags -f ${.CURDIR}/tags ${.ALLSRC}
+tags: ${SRCS} _PROGSUBDIR
+.if defined(PROG)
+       -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
+           sed "s;\${.CURDIR}/;;" > tags
+.endif
 .endif
 
 .endif
 
-.include <bsd.own.mk>
+.if !defined(NOMAN)
+.include <bsd.man.mk>
+.endif