Home | History | Annotate | Line # | Download | only in mk
bsd.prog.mk revision 1.71
      1  1.71   mycroft #	$NetBSD: bsd.prog.mk,v 1.71 1997/05/06 20:54:40 mycroft Exp $
      2  1.67     mikel #	@(#)bsd.prog.mk	8.2 (Berkeley) 4/2/94
      3   1.1       cgd 
      4   1.1       cgd .if exists(${.CURDIR}/../Makefile.inc)
      5   1.1       cgd .include "${.CURDIR}/../Makefile.inc"
      6   1.1       cgd .endif
      7  1.48   mycroft 
      8  1.71   mycroft .MAIN:		all
      9  1.71   mycroft .PHONY:		cleanprog afterdepend beforeinstall proginstall afterinstall
     10  1.71   mycroft 
     11  1.48   mycroft .include <bsd.own.mk>
     12   1.1       cgd 
     13  1.18   mycroft .SUFFIXES: .out .o .c .cc .C .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
     14   1.1       cgd 
     15  1.25   mycroft CFLAGS+=	${COPTS}
     16   1.1       cgd 
     17  1.69   thorpej # ELF platforms depend on crtbegin.o and crtend.o
     18  1.69   thorpej .if (${MACHINE_ARCH} == "alpha")   || \
     19  1.69   thorpej     (${MACHINE_ARCH} == "powerpc")
     20  1.69   thorpej LIBCRTBEGIN?=	${DESTDIR}/usr/lib/crtbegin.o
     21  1.69   thorpej LIBCRTEND?=	${DESTDIR}/usr/lib/crtend.o
     22  1.69   thorpej .else
     23  1.69   thorpej LIBCRTBEGIN?=
     24  1.69   thorpej LIBCRTEND?=
     25  1.69   thorpej .endif
     26  1.69   thorpej 
     27  1.46   mycroft LIBCRT0?=	${DESTDIR}/usr/lib/crt0.o
     28  1.46   mycroft LIBC?=		${DESTDIR}/usr/lib/libc.a
     29  1.63  christos LIBC_PIC?=	${DESTDIR}/usr/lib/libc_pic.a
     30  1.46   mycroft LIBCOMPAT?=	${DESTDIR}/usr/lib/libcompat.a
     31  1.46   mycroft LIBCRYPT?=	${DESTDIR}/usr/lib/libcrypt.a
     32  1.46   mycroft LIBCURSES?=	${DESTDIR}/usr/lib/libcurses.a
     33  1.46   mycroft LIBDBM?=	${DESTDIR}/usr/lib/libdbm.a
     34  1.46   mycroft LIBDES?=	${DESTDIR}/usr/lib/libdes.a
     35  1.51   mycroft LIBEDIT?=	${DESTDIR}/usr/lib/libedit.a
     36  1.46   mycroft LIBGCC?=	${DESTDIR}/usr/lib/libgcc.a
     37  1.63  christos LIBGNUMALLOC?=	${DESTDIR}/usr/lib/libgnumalloc.a
     38  1.46   mycroft LIBKDB?=	${DESTDIR}/usr/lib/libkdb.a
     39  1.46   mycroft LIBKRB?=	${DESTDIR}/usr/lib/libkrb.a
     40  1.46   mycroft LIBKVM?=	${DESTDIR}/usr/lib/libkvm.a
     41  1.55       jtc LIBL?=		${DESTDIR}/usr/lib/libl.a
     42  1.46   mycroft LIBM?=		${DESTDIR}/usr/lib/libm.a
     43  1.46   mycroft LIBMP?=		${DESTDIR}/usr/lib/libmp.a
     44  1.70  christos LIBNTP?=	${DESTDIR}/usr/lib/libntp.a
     45  1.46   mycroft LIBPC?=		${DESTDIR}/usr/lib/libpc.a
     46  1.58     mikel LIBPCAP?=	${DESTDIR}/usr/lib/libpcap.a
     47  1.46   mycroft LIBPLOT?=	${DESTDIR}/usr/lib/libplot.a
     48  1.46   mycroft LIBRESOLV?=	${DESTDIR}/usr/lib/libresolv.a
     49  1.46   mycroft LIBRPCSVC?=	${DESTDIR}/usr/lib/librpcsvc.a
     50  1.46   mycroft LIBSKEY?=	${DESTDIR}/usr/lib/libskey.a
     51  1.46   mycroft LIBTERMCAP?=	${DESTDIR}/usr/lib/libtermcap.a
     52  1.63  christos LIBTELNET?=	${DESTDIR}/usr/lib/libtelnet.a
     53  1.46   mycroft LIBUTIL?=	${DESTDIR}/usr/lib/libutil.a
     54  1.57       mrg LIBWRAP?=	${DESTDIR}/usr/lib/libwrap.a
     55  1.55       jtc LIBY?=		${DESTDIR}/usr/lib/liby.a
     56  1.57       mrg LIBZ?=		${DESTDIR}/usr/lib/libz.a
     57   1.1       cgd 
     58   1.1       cgd .if defined(SHAREDSTRINGS)
     59   1.1       cgd CLEANFILES+=strings
     60   1.1       cgd .c.o:
     61   1.1       cgd 	${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
     62   1.1       cgd 	@${CC} ${CFLAGS} -c x.c -o ${.TARGET}
     63   1.1       cgd 	@rm -f x.c
     64  1.18   mycroft 
     65  1.18   mycroft .cc.o:
     66  1.18   mycroft 	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
     67  1.18   mycroft 	@mv -f x.c x.cc
     68  1.18   mycroft 	@${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
     69  1.26   mycroft 	@rm -f x.cc
     70  1.18   mycroft 
     71  1.18   mycroft .C.o:
     72  1.18   mycroft 	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
     73  1.18   mycroft 	@mv -f x.c x.C
     74  1.18   mycroft 	@${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET}
     75  1.26   mycroft 	@rm -f x.C
     76   1.1       cgd .endif
     77   1.1       cgd 
     78  1.38       jtc 
     79   1.1       cgd .if defined(PROG)
     80  1.40       cgd SRCS?=	${PROG}.c
     81  1.45       cgd .if !empty(SRCS:N*.h:N*.sh)
     82  1.52       cgd OBJS+=	${SRCS:N*.h:N*.sh:R:S/$/.o/g}
     83  1.52       cgd LOBJS+=	${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
     84  1.45       cgd .endif
     85   1.1       cgd 
     86  1.47       cgd .if defined(OBJS) && !empty(OBJS)
     87  1.46   mycroft .if defined(DESTDIR)
     88   1.4      nate 
     89  1.69   thorpej ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
     90  1.69   thorpej 	${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib -L${DESTDIR}/usr/lib ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -lgcc -lc -lgcc ${LIBCRTEND}
     91   1.4      nate 
     92  1.46   mycroft .else
     93   1.4      nate 
     94  1.69   thorpej ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
     95  1.32       cgd 	${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
     96   1.1       cgd 
     97  1.47       cgd .endif	# defined(DESTDIR)
     98  1.47       cgd .endif	# defined(OBJS) && !empty(OBJS)
     99   1.1       cgd 
    100  1.49       cgd .if	!defined(MAN)
    101  1.49       cgd MAN=	${PROG}.1
    102  1.49       cgd .endif	# !defined(MAN)
    103  1.49       cgd .endif	# defined(PROG)
    104  1.11   mycroft 
    105  1.43       cgd all: ${PROG} _SUBDIRUSE
    106   1.1       cgd 
    107   1.1       cgd .if !target(clean)
    108  1.60       cgd cleanprog:
    109  1.53       cgd 	rm -f a.out [Ee]rrs mklog core *.core \
    110  1.53       cgd 	    ${PROG} ${OBJS} ${LOBJS} ${CLEANFILES}
    111   1.1       cgd 
    112  1.60       cgd clean: _SUBDIRUSE cleanprog
    113  1.60       cgd cleandir: _SUBDIRUSE cleanprog
    114  1.60       cgd .else
    115  1.43       cgd cleandir: _SUBDIRUSE clean
    116  1.60       cgd .endif
    117  1.59       cgd 
    118  1.59       cgd .if defined(SRCS)
    119  1.59       cgd afterdepend: .depend
    120  1.59       cgd 	@(TMP=/tmp/_depend$$$$; \
    121  1.59       cgd 	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
    122  1.59       cgd 	      < .depend > $$TMP; \
    123  1.59       cgd 	    mv $$TMP .depend)
    124  1.59       cgd .endif
    125  1.27   mycroft 
    126   1.1       cgd .if !target(install)
    127   1.1       cgd .if !target(beforeinstall)
    128   1.1       cgd beforeinstall:
    129   1.1       cgd .endif
    130   1.1       cgd .if !target(afterinstall)
    131   1.1       cgd afterinstall:
    132   1.1       cgd .endif
    133   1.1       cgd 
    134  1.14   mycroft .if !target(realinstall)
    135  1.63  christos 
    136   1.1       cgd .if defined(PROG)
    137  1.63  christos PROGNAME?= ${PROG}
    138  1.63  christos proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME}
    139  1.63  christos .if !defined(UPDATE)
    140  1.63  christos .PHONY: ${DESTDIR}${BINDIR}/${PROGNAME}
    141  1.63  christos .endif
    142  1.63  christos .if !defined(BUILD)
    143  1.63  christos ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
    144  1.63  christos .endif
    145  1.63  christos 
    146  1.63  christos ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG}
    147  1.69   thorpej 	${INSTALL} ${COPY} ${STRIPFLAG} -o ${BINOWN} -g ${BINGRP} \
    148  1.69   thorpej 	    -m ${BINMODE} ${.ALLSRC} ${.TARGET}
    149  1.23   mycroft .endif
    150  1.23   mycroft 
    151  1.63  christos .if defined(SCRIPTS)
    152  1.65   mycroft SCRIPTSDIR?=${BINDIR}
    153  1.65   mycroft SCRIPTSOWN?=${BINOWN}
    154  1.65   mycroft SCRIPTSGRP?=${BINGRP}
    155  1.65   mycroft SCRIPTSMODE?=${BINMODE}
    156  1.63  christos .for S in ${SCRIPTS}
    157  1.65   mycroft SCRIPTSDIR_${S}?=${SCRIPTSDIR}
    158  1.65   mycroft SCRIPTSOWN_${S}?=${SCRIPTSOWN}
    159  1.65   mycroft SCRIPTSGRP_${S}?=${SCRIPTSGRP}
    160  1.65   mycroft SCRIPTSMODE_${S}?=${SCRIPTSMODE}
    161  1.63  christos .if defined(SCRIPTSNAME)
    162  1.63  christos SCRIPTSNAME_${S} ?= ${SCRIPTSNAME}
    163  1.63  christos .else
    164  1.63  christos SCRIPTSNAME_${S} ?= ${S:T:R}
    165  1.63  christos .endif
    166  1.65   mycroft SCRIPTSDIR_${S} ?= ${SCRIPTSDIR}
    167  1.65   mycroft proginstall:: ${DESTDIR}${SCRIPTSDIR_${S}}/${SCRIPTSNAME_${S}}
    168  1.63  christos .if !defined(UPDATE)
    169  1.65   mycroft .PHONY: ${DESTDIR}${SCRIPTSDIR_${S}}/${SCRIPTSNAME_${S}}
    170  1.63  christos .endif
    171  1.63  christos .if !defined(BUILD)
    172  1.65   mycroft ${DESTDIR}${SCRIPTSDIR_${S}}/${SCRIPTSNAME_${S}}: .MADE
    173  1.63  christos .endif
    174  1.63  christos 
    175  1.65   mycroft ${DESTDIR}${SCRIPTSDIR_${S}}/${SCRIPTSNAME_${S}}: ${S}
    176  1.65   mycroft 	${INSTALL} ${COPY} -o ${SCRIPTSOWN_${S}} -g ${SCRIPTSGRP_${S}} \
    177  1.65   mycroft 		-m ${SCRIPTSMODE_${S}} ${.ALLSRC} ${.TARGET}
    178  1.63  christos .endfor
    179  1.14   mycroft .endif
    180   1.1       cgd 
    181  1.63  christos .if target(proginstall)
    182  1.66  christos realinstall: proginstall filesinstall
    183  1.63  christos .else
    184  1.66  christos realinstall: filesinstall
    185  1.63  christos .endif
    186  1.63  christos .endif
    187  1.63  christos 
    188  1.63  christos install: ${MANINSTALL} _SUBDIRUSE linksinstall
    189  1.63  christos 
    190  1.63  christos ${MANINSTALL}: afterinstall
    191   1.1       cgd afterinstall: realinstall
    192   1.1       cgd realinstall: beforeinstall
    193   1.1       cgd .endif
    194   1.1       cgd 
    195   1.1       cgd .if !target(lint)
    196  1.52       cgd lint: ${LOBJS}
    197  1.52       cgd .if defined(LOBJS) && !empty(LOBJS)
    198  1.52       cgd 	@${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
    199   1.1       cgd .endif
    200   1.1       cgd .endif
    201   1.1       cgd 
    202   1.1       cgd .if !defined(NOMAN)
    203   1.1       cgd .include <bsd.man.mk>
    204  1.50       jtc .endif
    205  1.50       jtc 
    206  1.50       jtc .if !defined(NONLS)
    207  1.50       jtc .include <bsd.nls.mk>
    208   1.1       cgd .endif
    209  1.24   mycroft 
    210  1.24   mycroft .include <bsd.obj.mk>
    211  1.63  christos .include <bsd.links.mk>
    212  1.66  christos .include <bsd.files.mk>
    213  1.63  christos .include <bsd.inc.mk>
    214  1.26   mycroft .include <bsd.dep.mk>
    215  1.28   mycroft .include <bsd.subdir.mk>
    216  1.54  christos .include <bsd.sys.mk>
    217