[BACK]Return to bsd.prog.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / mk

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/share/mk/bsd.prog.mk between version 1.4 and 1.167

version 1.4, 1993/03/27 12:17:32 version 1.167, 2003/05/31 20:33:16
Line 1 
Line 1 
 #       @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91  #       $NetBSD$
   #       @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
   
 .if exists(${.CURDIR}/../Makefile.inc)  .ifndef HOSTPROG
 .include "${.CURDIR}/../Makefile.inc"  
 .endif  
   
 .SUFFIXES: .out .o .c .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0  
   
 .8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:  .include <bsd.init.mk>
         nroff -mandoc ${.IMPSRC} > ${.TARGET}  .include <bsd.shlib.mk>
   .include <bsd.gcc.mk>
 CFLAGS+=${COPTS}  
   ##### Basic targets
 STRIP?= -s  .PHONY:         cleanextra cleanobjs cleanprog proginstall scriptsinstall
   realinstall:    proginstall scriptsinstall
 BINGRP?=        bin  clean:          cleanprog
 BINOWN?=        bin  
 BINMODE?=       555  ##### Default values
   CPPFLAGS+=      ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
   CXXFLAGS+=      ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include/g++}
 LIBCRT0?=       /usr/lib/crt0.o  CFLAGS+=        ${COPTS}
 LIBC?=          /usr/lib/libc.a  .if ${MACHINE_ARCH} == "sparc64"
 LIBCOMPAT?=     /usr/lib/libcompat.a  CFLAGS+=        -mcmodel=medlow
 LIBCURSES?=     /usr/lib/libcurses.a  .endif
 LIBDBM?=        /usr/lib/libdbm.a  
 LIBDES?=        /usr/lib/libdes.a  # ELF platforms depend on crti.o, crtbegin.o, crtend.o, and crtn.o
 LIBL?=          /usr/lib/libl.a  .if ${OBJECT_FMT} == "ELF"
 LIBKDB?=        /usr/lib/libkdb.a  .ifndef LIBCRTBEGIN
 LIBKRB?=        /usr/lib/libkrb.a  LIBCRTBEGIN=    ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGIN}
 LIBM?=          /usr/lib/libm.a  .MADE: ${LIBCRTBEGIN}
 LIBMP?=         /usr/lib/libmp.a  .endif
 LIBPC?=         /usr/lib/libpc.a  .ifndef LIBCRTEND
 LIBPLOT?=       /usr/lib/libplot.a  LIBCRTEND=      ${_GCC_CRTEND} ${DESTDIR}/usr/lib/crtn.o
 LIBRESOLV?=     /usr/lib/libresolv.a  .MADE: ${LIBCRTEND}
 LIBRPC?=        /usr/lib/sunrpc.a  .endif
 LIBTERM?=       /usr/lib/libterm.a  _SHLINKER=      ${SHLINKDIR}/ld.elf_so
 LIBUTIL?=       /usr/lib/libutil.a  .else
   LIBCRTBEGIN?=
   LIBCRTEND?=
   _SHLINKER=      ${SHLINKDIR}/ld.so
   .endif
   
   .ifndef LIBCRT0
   LIBCRT0=        ${DESTDIR}/usr/lib/crt0.o
   .MADE: ${LIBCRT0}
   .endif
   
   ##### Installed system library definitions
   #     E.g. LIBC?=${DESTDIR}/usr/lib/libc.a
   #     etc..
   #
   __bsd_prog_mk_system_libs?= \
           BZ2 C C_PIC CDK COM_ERR COMPAT CRYPT CRYPTO CRYPTO_IDEA CRYPTO_MDC2 \
           CRYPTO_RC5 \
           CURSES DBM DES EDIT FORM GCC GNUMALLOC GSSAPI HDB INTL IPSEC \
           KADM KADM5CLNT KADM5SRV KAFS KDB KRB KRB5 KSTREAM KVM L M MENU \
           OBJC OSSAUDIO PCAP PCI PMC POSIX PTHREAD PTHREAD_DBG RESOLV RMT \
           ROKEN RPCSVC RT SKEY SS SSL SL TERMCAP TELNET USBHID UTIL WRAP Y Z
   
   .for _n in ${__bsd_prog_mk_system_libs}
   .ifndef LIB${_n}
   LIB${_n}= ${DESTDIR}/usr/lib/lib${_n:tl}.a
   # XXX - note that ${DESTDIR} will be expanded in the following rule
   .MADE: ${LIB${_n}}
   .endif
   .endfor
   .undef __bsd_prog_mk_system_libs
   
   ##### Build and install rules
 .if defined(SHAREDSTRINGS)  .if defined(SHAREDSTRINGS)
 CLEANFILES+=strings  CLEANFILES+=strings
 .c.o:  .c.o:
         ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -          ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
         @${CC} ${CFLAGS} -c x.c -o ${.TARGET}          @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
         @rm -f x.c          @rm -f x.c
   
   .cc.o:
           ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
           @mv -f x.c x.cc
           @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
           @rm -f x.cc
   
   .C.o:
           ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
           @mv -f x.c x.C
           @${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET}
           @rm -f x.C
 .endif  .endif
   
 .if defined(PROG)  .if defined(PROG_CXX)
 .if defined(SRCS)  PROG=   ${PROG_CXX}
   .endif
   
 OBJS+=  ${SRCS:R:S/$/.o/g}  .if defined(PROG)
   .if defined(PROG_CXX)
   SRCS?=          ${PROG}.cc
   .else
   SRCS?=          ${PROG}.c
   .endif
   
 .if defined(LDONLY)  DPSRCS+=        ${SRCS:M*.[ly]:C/\..$/.c/}
   CLEANFILES+=    ${DPSRCS} ${YHEADER:D${SRCS:M*.y:.y=.h}}
   
 ${PROG}: ${LIBCRT0} ${LIBC} ${OBJS} ${DPADD}  .if !empty(SRCS:N*.h:N*.sh:N*.fth)
         ${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDADD}  OBJS+=          ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
   LOBJS+=         ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
   .endif
   
 .else defined(LDONLY)  .if defined(OBJS) && !empty(OBJS)
   .NOPATH: ${OBJS} ${PROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
   
 ${PROG}: ${OBJS} ${LIBC} ${DPADD}  _PROGLDOPTS=
         ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}  .if ${SHLINKDIR} != "/usr/libexec"      # XXX: change or remove if ld.so moves
   .if ${OBJECT_FMT} == "ELF"
   _PROGLDOPTS+=   -Wl,-dynamic-linker=${_SHLINKER}
   .endif
   .if ${OBJECT_FMT} == "a.out"
   LIBCRT0=        ${DESTDIR}/lib/crt0.o
   .endif
   .endif
   .if ${SHLIBDIR} != ${LIBDIR}
   _PROGLDOPTS+=   -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
                   -Wl,-rpath,${SHLIBDIR}:/usr/lib \
                   -L${DESTDIR}${SHLIBDIR}
   .elif ${SHLIBINSTALLDIR} != ${LIBDIR}
   _PROGLDOPTS+=   -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
                   -L${DESTDIR}${SHLIBINSTALLDIR}
   .endif
   
   .if defined(PROG_CXX)
   _CCLINK=        ${CXX}
   _SUPCXX=        -lstdc++ -lm
   .else
   _CCLINK=        ${CC}
 .endif  .endif
   
 .else defined(PROG)  .gdbinit:
           rm -f .gdbinit
   .if defined(DESTDIR) && !empty(DESTDIR)
           echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit
   .else
           touch .gdbinit
   .endif
   .for __gdbinit in ${GDBINIT}
           echo "source ${__gdbinit}" >> .gdbinit
   .endfor
   
 SRCS= ${PROG}.c  .if defined(DESTDIR)
   
 ${PROG}: ${SRCS} ${LIBC} ${DPADD}  ${PROG}: .gdbinit ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
         ${CC} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}  .if !commands(${PROG})
           ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND}
   .endif
   
 MKDEP=  -p  .else
   
   ${PROG}: .gdbinit ${LIBCRT0} ${DPSRCS} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
   .if !commands(${PROG})
           ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
 .endif  .endif
   
 .if     !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \  .endif  # defined(DESTDIR)
         !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \  .endif  # defined(OBJS) && !empty(OBJS)
         !defined(MAN7) && !defined(MAN8) && !defined(NOMAN)  
 MAN1=   ${PROG}.0  .if !defined(MAN)
   MAN=    ${PROG}.1
   .endif  # !defined(MAN)
   .endif  # defined(PROG)
   
   realall: ${PROG} ${SCRIPTS}
   
   cleanprog: cleanobjs cleanextra
           rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG}
   
   cleanobjs:
   .if defined(OBJS) && !empty(OBJS)
           rm -f ${OBJS} ${LOBJS}
 .endif  .endif
   
   cleanextra:
   .if defined(CLEANFILES) && !empty(CLEANFILES)
           rm -f ${CLEANFILES}
 .endif  .endif
 MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}  
   
 _PROGSUBDIR: .USE  .if defined(SRCS) && !target(afterdepend)
 .if defined(SUBDIR) && !empty(SUBDIR)  afterdepend: .depend
         @for entry in ${SUBDIR}; do \          @(TMP=/tmp/_depend$$$$; \
                 (echo "===> $$entry"; \              sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
                 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \                < .depend > $$TMP; \
                         cd ${.CURDIR}/$${entry}.${MACHINE}; \              mv $$TMP .depend)
                 else \  
                         cd ${.CURDIR}/$${entry}; \  
                 fi; \  
                 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \  
         done  
 .endif  .endif
   
 .MAIN: all  .if defined(PROG) && !target(proginstall)
 all: ${PROG} ${MANALL} _PROGSUBDIR  PROGNAME?=${PROG}
   
 .if !target(clean)  proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME}
 clean: _PROGSUBDIR  .PRECIOUS: ${DESTDIR}${BINDIR}/${PROGNAME}
         rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}  
         rm -f .depend ${MANALL}  
 .endif  
   
 .if !target(cleandir)  __proginstall: .USE
 cleandir: _PROGSUBDIR          ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
         rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES} ${MANALL}                  ${STRIPFLAG} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
         rm -f .depend ${MANALL}  
 .endif  
   
 # some of the rules involve .h sources, so remove them from mkdep line  .if !defined(UPDATE)
 .if !target(depend)  ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall
 depend: .depend _PROGSUBDIR  .if !defined(BUILD) && !make(all) && !make(${PROG})
 .depend: ${SRCS}  ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE
 .if defined(PROG)  
         mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c}  
 .endif  .endif
   .else
   ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall
   .if !defined(BUILD) && !make(all) && !make(${PROG})
   ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
 .endif  .endif
   
 .if !target(install)  
 .if !target(beforeinstall)  
 beforeinstall:  
 .endif  .endif
 .if !target(afterinstall)  
 afterinstall:  
 .endif  .endif
   
 realinstall: _PROGSUBDIR  .if !target(proginstall)
 .if defined(PROG)  proginstall::
         install -c ${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  
   
 install: maninstall  
 maninstall: afterinstall  
 afterinstall: realinstall  
 realinstall: beforeinstall  
 .endif  .endif
   
 .if !target(lint)  .if defined(SCRIPTS) && !target(scriptsinstall)
 lint: ${SRCS} _PROGSUBDIR  SCRIPTSDIR?=${BINDIR}
 .if defined(PROG)  SCRIPTSOWN?=${BINOWN}
         @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1  SCRIPTSGRP?=${BINGRP}
   SCRIPTSMODE?=${BINMODE}
   
   scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
   .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
   
   __scriptinstall: .USE
           ${INSTALL_FILE} \
               -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
               -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
               -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
               ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
   
   .for S in ${SCRIPTS:O:u}
   .if !defined(UPDATE)
   ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall
   .if !defined(BUILD) && !make(all) && !make(${S})
   ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE
 .endif  .endif
   .else
   ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall
   .if !defined(BUILD) && !make(all) && !make(${S})
   ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
 .endif  .endif
   
 .if !target(obj)  
 .if defined(NOOBJ)  
 obj: _PROGSUBDIR  
 .else  
 obj: _PROGSUBDIR  
         @cd ${.CURDIR}; rm -f obj > /dev/null 2>&1 || true; \  
         here=`pwd`; subdir=`echo $$here | sed 's,^/usr/src/,,'`; \  
         if test $$here != $$subdir ; then \  
                 dest=/usr/obj/$$subdir ; \  
                 echo "$$here -> $$dest"; ln -s $$dest obj; \  
                 if test -d /usr/obj -a ! -d $$dest; then \  
                         mkdir -p $$dest; \  
                 else \  
                         true; \  
                 fi; \  
         else \  
                 true ; \  
                 dest=$$here/obj ; \  
                 echo "making $$here/obj" ; \  
                 if test ! -d obj ; then \  
                         mkdir $$here/obj; \  
                 fi ; \  
         fi;  
 .endif  .endif
   .endfor
 .endif  .endif
   
 .if !target(tags)  .if !target(scriptsinstall)
 tags: ${SRCS} _PROGSUBDIR  scriptsinstall::
 .if defined(PROG)  
         -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \  
             sed "s;\${.CURDIR}/;;" > tags  
 .endif  .endif
   
   lint: ${LOBJS}
   .if defined(LOBJS) && !empty(LOBJS)
           ${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
 .endif  .endif
   
 .if !defined(NOMAN)  ##### Pull in related .mk logic
 .include <bsd.man.mk>  .include <bsd.man.mk>
 .endif  .include <bsd.nls.mk>
   .include <bsd.files.mk>
   .include <bsd.inc.mk>
   .include <bsd.links.mk>
   .include <bsd.dep.mk>
   .include <bsd.sys.mk>
   
   ${TARGETS}:     # ensure existence
   
   .endif  # HOSTPROG

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.167

CVSweb <webmaster@jp.NetBSD.org>