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