BSD 4_3_Reno release
[unix-history] / usr / src / share / mk / bsd.prog.mk
index 6956fd2..406f015 100644 (file)
-DEPENDFILE=    .depend
-LIBUTIL=       /usr/lib/libutil.a
+#      @(#)bsd.prog.mk 5.20 (Berkeley) 6/29/90
 
 
-.if defined(SUBDIR)
+.if exists(${.CURDIR}/../Makefile.inc)
+.include "${.CURDIR}/../Makefile.inc"
+.endif
 
 
-MACHINE != machine
-all depend clean cleandir lint tags:
-       cd ${SUBDIR}.${MACHINE}; pmake ${.TARGET}
+.SUFFIXES: .out .o .c .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
 
 
-.else
+.8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
+       nroff -mandoc -h ${.IMPSRC} > ${.TARGET}
 
 
-.MAIN: all
-all: ${PROGC} ${PROGO}
+CFLAGS+=${COPTS}
+
+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
+LIBDES?=       /usr/lib/libdes.a
+LIBL?=         /usr/lib/libl.a
+LIBKDB?=       /usr/lib/libkdb.a
+LIBKRB?=       /usr/lib/libkrb.a
+LIBM?=         /usr/lib/libm.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)
+CLEANFILES+=strings
+.c.o:
+       ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
+       @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
+       @rm -f x.c
+.endif
+
+.if defined(PROG)
+.if defined(SRCS)
+
+OBJS+= ${SRCS:.c=.o}
 
 
-.if defined(PROGC)
-SRCS=  ${PROGC}.c
+${PROG}: ${OBJS} ${LIBC} ${DPADD}
+       ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
 
 
-${PROGC}: ${SRCS} ${LIBC} ${SRCLIB}
-       ${CC} -o ${.TARGET} ${SRCS} ${LDLIB}
+.else defined(PROG)
 
 
-clean:
-       rm -f core ${PROGC}
+SRCS= ${PROG}.c
 
 
-depend: ${SRCS}
-       mkdep -p ${CFLAGS:M-[ID]*} ${.INCLUDES} ${.ALLSRC}
+${PROG}: ${SRCS} ${LIBC} ${DPADD}
+       ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
+
+MKDEP= -p
 
 .endif
 
 
 .endif
 
-.if defined(PROGO)
-OBJS=  ${SRCS:.c=.o}
+.if    !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
+       !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
+       !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
+MAN1=  ${PROG}.0
+.endif
+.endif
+MANALL=        ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
 
 
-${PROGO}: ${OBJS} ${LIBC} ${SRCLIB}
-       ${CC} -o ${.TARGET} ${OBJS} ${LDLIB}
+_PROGSUBDIR: .USE
+.if defined(SUBDIR) && !empty(SUBDIR)
+       @for entry in ${SUBDIR}; do \
+               (echo "===> $$entry"; \
+               if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
+                       cd ${.CURDIR}/$${entry}.${MACHINE}; \
+               else \
+                       cd ${.CURDIR}/$${entry}; \
+               fi; \
+               ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}) \
+       done
+.endif
 
 
-depend: ${SRCS}
-       mkdep ${CFLAGS:M-[ID]*} ${.INCLUDES} ${.ALLSRC}
+.MAIN: all
+all: ${PROG} ${MANALL} _PROGSUBDIR
 
 
-clean:
-       rm -f ${OBJS} core ${PROGO}
+.if !target(clean)
+clean: _PROGSUBDIR
+       rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
+.endif
 
 
-${OBJS}: ${.PREFIX}.c
+.if !target(cleandir)
+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)
+depend: .depend _PROGSUBDIR
+.depend: ${SRCS}
+.if defined(PROG)
+       mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}
+.endif
 .endif
 
 .endif
 
-.if !defined(MAN1)
-MAN1=  ${MDIR1} ${PROGC}.0
+.if !target(install)
+.if !target(beforeinstall)
+beforeinstall:
+.endif
+.if !target(afterinstall)
+afterinstall:
 .endif
 
 .endif
 
-cleandir: clean
-       rm -f ${MANALL} ${TAGSFILE} ${DEPENDFILE}
+realinstall: _PROGSUBDIR
+.if defined(PROG)
+       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(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
 
 
-LINTFLAGS=     -chapbx
-lint: ${SRCS}
-       lint ${LINTFLAGS} ${CFLAGS} ${.ALLSRC}
+install: maninstall
+maninstall: afterinstall
+afterinstall: realinstall
+realinstall: beforeinstall
+.endif
 
 
-TAGSFILE=      tags
-tags: ${SRCS}
-       ctags ${.ALLSRC}
+.if !target(lint)
+lint: ${SRCS} _PROGSUBDIR
+.if defined(PROG)
+       @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
+.endif
+.endif
 
 
-STRIP=         -s
-BINMODE=       755
-DEFOWN=                bin
-DEFGRP=                bin
-MANMODE=       444
-MDIR1=         /usr/man/cat1
-MDIR2=         /usr/man/cat2
-MDIR3=         /usr/man/cat3
-MDIR4=         /usr/man/cat4
-MDIR5=         /usr/man/cat5
-MDIR6=         /usr/man/cat6
-MDIR7=         /usr/man/cat7
-MDIR8=         /usr/man/cat8
-MANALL=        ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
+.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
 
 
-install: ${MANALL}
-       install ${STRIP} -o ${DEFOWN} -g ${DEFGRP} -m ${BINMODE} \
-           ${PROGC} ${PROGO} ${DESTDIR}${DIR}
-.if defined(MAN1)
-       install -c -o ${DEFOWN} -g ${DEFGRP} -m ${MANMODE} ${MAN1} \
-           ${DESTDIR}${MDIR1}
-.if defined(LINKS1)
-       rm -f ${DESTDIR}${MDIR1}/${LINKS1}
-       for i in ${LINKS1}; do
-               ln ${DESTDIR}${MDIR1}/${MAN1} ${DESTDIR}${MDIR1}/$$i
-       done
-.endif # LINKS1
-.endif # MAN1
-.if defined(MAN2)
-       install -c -o ${DEFOWN} -g ${DEFGRP} -m ${MANMODE} ${MAN2} \
-           ${DESTDIR}${MDIR2}
-.endif # MAN2
-.if defined(MAN3)
-       install -c -o ${DEFOWN} -g ${DEFGRP} -m ${MANMODE} ${MAN3} \
-           ${DESTDIR}${MDIR3}
-.endif # MAN3
-.if defined(MAN4)
-       install -c -o ${DEFOWN} -g ${DEFGRP} -m ${MANMODE} ${MAN4} \
-           ${DESTDIR}${MDIR4}
-.endif # MAN4
-.if defined(MAN5)
-       install -c -o ${DEFOWN} -g ${DEFGRP} -m ${MANMODE} ${MAN5} \
-           ${DESTDIR}${MDIR5}
-.endif # MAN5
-.if defined(MAN6)
-       install -c -o ${DEFOWN} -g ${DEFGRP} -m ${MANMODE} ${MAN6} \
-           ${DESTDIR}${MDIR6}
-.endif # MAN6
-.if defined(MAN7)
-       install -c -o ${DEFOWN} -g ${DEFGRP} -m ${MANMODE} ${MAN7} \
-           ${DESTDIR}${MDIR7}
-.endif # MAN7
-.if defined(MAN8)
-       install -c -o ${DEFOWN} -g ${DEFGRP} -m ${MANMODE} ${MAN8} \
-           ${DESTDIR}${MDIR8}
-.endif # MAN8
+.if !target(tags)
+tags: ${SRCS} _PROGSUBDIR
+.if defined(PROG)
+       -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
+           sed "s;\${.CURDIR}/;;" > tags
+.endif
 .endif
 
 .endif
 
-.if defined(SHAREDSTRINGS)
-.NOTPARALLEL:
-XSTR=  xstr
-.c.o:
-       ${CC} -E ${.INCLUDES} ${CFLAGS} ${.IMPSRC} | ${XSTR} -c -
-       @${CC} ${.INCLUDES} ${CFLAGS} -c x.c -o ${.TARGET}
-       @rm -f x.c
+.if !defined(NOMAN)
+.include <bsd.man.mk>
 .endif
 .endif