Home | History | Annotate | Line # | Download | only in mk
bsd.prog.mk revision 1.46
      1 #	$NetBSD: bsd.prog.mk,v 1.46 1994/07/06 04:13:37 mycroft Exp $
      2 #	@(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
      3 
      4 .if exists(${.CURDIR}/../Makefile.inc)
      5 .include "${.CURDIR}/../Makefile.inc"
      6 .endif
      7 
      8 .SUFFIXES: .out .o .c .cc .C .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
      9 
     10 CFLAGS+=	${COPTS}
     11 
     12 LIBCRT0?=	${DESTDIR}/usr/lib/crt0.o
     13 LIBC?=		${DESTDIR}/usr/lib/libc.a
     14 LIBCOMPAT?=	${DESTDIR}/usr/lib/libcompat.a
     15 LIBCRYPT?=	${DESTDIR}/usr/lib/libcrypt.a
     16 LIBCURSES?=	${DESTDIR}/usr/lib/libcurses.a
     17 LIBDBM?=	${DESTDIR}/usr/lib/libdbm.a
     18 LIBDES?=	${DESTDIR}/usr/lib/libdes.a
     19 LIBGCC?=	${DESTDIR}/usr/lib/libgcc.a
     20 LIBL?=		${DESTDIR}/usr/lib/libl.a
     21 LIBKDB?=	${DESTDIR}/usr/lib/libkdb.a
     22 LIBKRB?=	${DESTDIR}/usr/lib/libkrb.a
     23 LIBKVM?=	${DESTDIR}/usr/lib/libkvm.a
     24 LIBM?=		${DESTDIR}/usr/lib/libm.a
     25 LIBMP?=		${DESTDIR}/usr/lib/libmp.a
     26 LIBPC?=		${DESTDIR}/usr/lib/libpc.a
     27 LIBPLOT?=	${DESTDIR}/usr/lib/libplot.a
     28 LIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
     29 LIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
     30 LIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
     31 LIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
     32 LIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
     33 
     34 .if defined(SHAREDSTRINGS)
     35 CLEANFILES+=strings
     36 .c.o:
     37 	${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
     38 	@${CC} ${CFLAGS} -c x.c -o ${.TARGET}
     39 	@rm -f x.c
     40 
     41 .cc.o:
     42 	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
     43 	@mv -f x.c x.cc
     44 	@${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
     45 	@rm -f x.cc
     46 
     47 .C.o:
     48 	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
     49 	@mv -f x.c x.C
     50 	@${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET}
     51 	@rm -f x.C
     52 .endif
     53 
     54 
     55 .if defined(PROG)
     56 SRCS?=	${PROG}.c
     57 .if !empty(SRCS:N*.h:N*.sh)
     58 OBJS+=  ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
     59 .endif
     60 
     61 .if defined(DESTDIR)
     62 
     63 ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
     64 	${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib -L${DESTDIR}/usr/lib ${LIBCRT0} ${OBJS} ${LDADD} -lgcc -lc -lgcc
     65 
     66 .else
     67 
     68 ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
     69 	${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
     70 
     71 .endif
     72 
     73 .if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
     74 	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
     75 	!defined(MAN7) && !defined(MAN8)
     76 MAN1=	${PROG}.0
     77 .endif
     78 .endif
     79 
     80 .MAIN: all
     81 all: ${PROG} _SUBDIRUSE
     82 
     83 .if !target(clean)
     84 clean: _SUBDIRUSE
     85 	rm -f a.out [Ee]rrs mklog core *.core ${PROG} ${OBJS} ${CLEANFILES}
     86 .endif
     87 
     88 cleandir: _SUBDIRUSE clean
     89 
     90 .if !target(install)
     91 .if !target(beforeinstall)
     92 beforeinstall:
     93 .endif
     94 .if !target(afterinstall)
     95 afterinstall:
     96 .endif
     97 
     98 .if !target(realinstall)
     99 realinstall:
    100 .if defined(PROG)
    101 	install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
    102 	    ${PROG} ${DESTDIR}${BINDIR}
    103 .endif
    104 .if defined(HIDEGAME)
    105 	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG})
    106 .endif
    107 .endif
    108 
    109 install: maninstall _SUBDIRUSE
    110 .if defined(LINKS) && !empty(LINKS)
    111 	@set ${LINKS}; \
    112 	while test $$# -ge 2; do \
    113 		l=${DESTDIR}$$1; \
    114 		shift; \
    115 		t=${DESTDIR}$$1; \
    116 		shift; \
    117 		echo $$t -\> $$l; \
    118 		rm -f $$t; \
    119 		ln $$l $$t; \
    120 	done; true
    121 .endif
    122 
    123 maninstall: afterinstall
    124 afterinstall: realinstall
    125 realinstall: beforeinstall
    126 .endif
    127 
    128 .if !target(lint)
    129 lint: ${SRCS} _SUBDIRUSE
    130 .if defined(PROG)
    131 	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
    132 .endif
    133 .endif
    134 
    135 .if !defined(NOMAN)
    136 .include <bsd.man.mk>
    137 .endif
    138 
    139 .include <bsd.obj.mk>
    140 .include <bsd.dep.mk>
    141 .include <bsd.subdir.mk>
    142