Home | History | Annotate | Line # | Download | only in mk
bsd.prog.mk revision 1.60
      1 #	$NetBSD: bsd.prog.mk,v 1.60 1997/01/22 01:34:13 cgd 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 LIBEDIT?=	${DESTDIR}/usr/lib/libedit.a
     22 LIBGCC?=	${DESTDIR}/usr/lib/libgcc.a
     23 LIBKDB?=	${DESTDIR}/usr/lib/libkdb.a
     24 LIBKRB?=	${DESTDIR}/usr/lib/libkrb.a
     25 LIBKVM?=	${DESTDIR}/usr/lib/libkvm.a
     26 LIBL?=		${DESTDIR}/usr/lib/libl.a
     27 LIBM?=		${DESTDIR}/usr/lib/libm.a
     28 LIBMP?=		${DESTDIR}/usr/lib/libmp.a
     29 LIBPC?=		${DESTDIR}/usr/lib/libpc.a
     30 LIBPCAP?=	${DESTDIR}/usr/lib/libpcap.a
     31 LIBPLOT?=	${DESTDIR}/usr/lib/libplot.a
     32 LIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
     33 LIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
     34 LIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
     35 LIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
     36 LIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
     37 LIBWRAP?=	${DESTDIR}/usr/lib/libwrap.a
     38 LIBY?=		${DESTDIR}/usr/lib/liby.a
     39 LIBZ?=		${DESTDIR}/usr/lib/libz.a
     40 
     41 .if defined(SHAREDSTRINGS)
     42 CLEANFILES+=strings
     43 .c.o:
     44 	${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
     45 	@${CC} ${CFLAGS} -c x.c -o ${.TARGET}
     46 	@rm -f x.c
     47 
     48 .cc.o:
     49 	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
     50 	@mv -f x.c x.cc
     51 	@${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
     52 	@rm -f x.cc
     53 
     54 .C.o:
     55 	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
     56 	@mv -f x.c x.C
     57 	@${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET}
     58 	@rm -f x.C
     59 .endif
     60 
     61 
     62 .if defined(PROG)
     63 SRCS?=	${PROG}.c
     64 .if !empty(SRCS:N*.h:N*.sh)
     65 OBJS+=	${SRCS:N*.h:N*.sh:R:S/$/.o/g}
     66 LOBJS+=	${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
     67 .endif
     68 
     69 .if defined(OBJS) && !empty(OBJS)
     70 .if defined(DESTDIR)
     71 
     72 ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
     73 	${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib -L${DESTDIR}/usr/lib ${LIBCRT0} ${OBJS} ${LDADD} -lgcc -lc -lgcc
     74 
     75 .else
     76 
     77 ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
     78 	${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
     79 
     80 .endif	# defined(DESTDIR)
     81 .endif	# defined(OBJS) && !empty(OBJS)
     82 
     83 .if	!defined(MAN)
     84 MAN=	${PROG}.1
     85 .endif	# !defined(MAN)
     86 .endif	# defined(PROG)
     87 
     88 .MAIN: all
     89 all: ${PROG} _SUBDIRUSE
     90 
     91 .if !target(clean)
     92 cleanprog:
     93 	rm -f a.out [Ee]rrs mklog core *.core \
     94 	    ${PROG} ${OBJS} ${LOBJS} ${CLEANFILES}
     95 
     96 clean: _SUBDIRUSE cleanprog
     97 cleandir: _SUBDIRUSE cleanprog
     98 .else
     99 cleandir: _SUBDIRUSE clean
    100 .endif
    101 
    102 .if defined(SRCS)
    103 afterdepend: .depend
    104 	@(TMP=/tmp/_depend$$$$; \
    105 	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
    106 	      < .depend > $$TMP; \
    107 	    mv $$TMP .depend)
    108 .endif
    109 
    110 .if !target(install)
    111 .if !target(beforeinstall)
    112 beforeinstall:
    113 .endif
    114 .if !target(afterinstall)
    115 afterinstall:
    116 .endif
    117 
    118 .if !target(realinstall)
    119 realinstall:
    120 .if defined(PROG)
    121 	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
    122 	    ${PROG} ${DESTDIR}${BINDIR}
    123 .endif
    124 .if defined(HIDEGAME)
    125 	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG})
    126 .endif
    127 .endif
    128 
    129 install: maninstall _SUBDIRUSE
    130 .if defined(LINKS) && !empty(LINKS)
    131 	@set ${LINKS}; \
    132 	while test $$# -ge 2; do \
    133 		l=${DESTDIR}$$1; \
    134 		shift; \
    135 		t=${DESTDIR}$$1; \
    136 		shift; \
    137 		echo $$t -\> $$l; \
    138 		rm -f $$t; \
    139 		ln $$l $$t; \
    140 	done; true
    141 .endif
    142 
    143 maninstall: afterinstall
    144 afterinstall: realinstall
    145 realinstall: beforeinstall
    146 .endif
    147 
    148 .if !target(lint)
    149 lint: ${LOBJS}
    150 .if defined(LOBJS) && !empty(LOBJS)
    151 	@${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
    152 .endif
    153 .endif
    154 
    155 .if !defined(NOMAN)
    156 .include <bsd.man.mk>
    157 .endif
    158 
    159 .if !defined(NONLS)
    160 .include <bsd.nls.mk>
    161 .endif
    162 
    163 .include <bsd.obj.mk>
    164 .include <bsd.dep.mk>
    165 .include <bsd.subdir.mk>
    166 .include <bsd.sys.mk>
    167