[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.222 and 1.223

version 1.222, 2007/11/04 23:28:20 version 1.223, 2007/11/12 15:04:35
Line 7 
Line 7 
 .include <bsd.shlib.mk>  .include <bsd.shlib.mk>
 .include <bsd.gcc.mk>  .include <bsd.gcc.mk>
   
 .if defined(PROG_CXX)  #
 PROG=   ${PROG_CXX}  # Definitions and targets shared among all programs built by a single
 .endif  # Makefile.
   #
 .if defined(PAXCTL_FLAGS)  
 PAXCTL_FLAGS.${PROG}?= ${PAXCTL_FLAGS}  
 .endif  
   
 ##### Basic targets  ##### Basic targets
 realinstall:    proginstall scriptsinstall  realinstall:    proginstall scriptsinstall
 clean:          cleanprog  clean:          cleanprog
   
 ##### PROG specific flags.  .gdbinit:
 COPTS+=     ${COPTS.${PROG}}          rm -f .gdbinit
 CPPFLAGS+=  ${CPPFLAGS.${PROG}}  .if defined(DESTDIR) && !empty(DESTDIR)
 CXXFLAGS+=  ${CXXFLAGS.${PROG}}          echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit
 OBJCOPTS+=  ${OBJCOPTS.${PROG}}  .else
 LDADD+=     ${LDADD.${PROG}}          touch .gdbinit
 LDFLAGS+=   ${LDFLAGS.${PROG}}  .endif
 LDSTATIC+=  ${LDSTATIC.${PROG}}  .for __gdbinit in ${GDBINIT}
           echo "source ${__gdbinit}" >> .gdbinit
   .endfor
   
   cleanextra: .PHONY
   .if defined(CLEANFILES) && !empty(CLEANFILES)
           rm -f ${CLEANFILES}
   .endif
   
   cleanobjs: .PHONY
   
   cleanprog: .PHONY cleanobjs cleanextra
           rm -f a.out [Ee]rrs mklog core *.core .gdbinit
   
   .if defined(SHAREDSTRINGS)
   CLEANFILES+=strings
   .c.o:
           ${CC} -E ${CPPFLAGS} ${CFLAGS} ${.IMPSRC} | xstr -c -
           @${CC} ${CPPFLAGS} ${CFLAGS} -c x.c -o ${.TARGET}
           @rm -f x.c
   
   .cc.o .cpp.o .cxx.o .C.o:
           ${CXX} -E ${CPPFLAGS} ${CXXFLAGS} ${.IMPSRC} | xstr -c -
           @mv -f x.c x.cc
           @${CXX} ${CPPFLAGS} ${CXXFLAGS} -c x.cc -o ${.TARGET}
           @rm -f x.cc
   .endif
   
 ##### Default values  ##### Default values
 CPPFLAGS+=      ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}  CPPFLAGS+=      ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
Line 123  LIB${_lib:tu}= ${DESTDIR}/usr/X11R6/lib/
Line 146  LIB${_lib:tu}= ${DESTDIR}/usr/X11R6/lib/
 .endif  .endif
 .endfor  .endfor
   
   
 ##### Build and install rules  
 .if defined(SHAREDSTRINGS)  
 CLEANFILES+=strings  
 .c.o:  
         ${CC} -E ${CPPFLAGS} ${CFLAGS} ${.IMPSRC} | xstr -c -  
         @${CC} ${CPPFLAGS} ${CFLAGS} -c x.c -o ${.TARGET}  
         @rm -f x.c  
   
 .cc.o .cpp.o .cxx.o .C.o:  
         ${CXX} -E ${CPPFLAGS} ${CXXFLAGS} ${.IMPSRC} | xstr -c -  
         @mv -f x.c x.cc  
         @${CXX} ${CPPFLAGS} ${CXXFLAGS} -c x.cc -o ${.TARGET}  
         @rm -f x.cc  
 .endif  
   
 .if defined(PROG)                                                       # {  
 .if defined(PROG_CXX)  
 SRCS?=          ${PROG}.cc  
 .else  
 SRCS?=          ${PROG}.c  
 .endif  
   
 PROGNAME?=      ${PROG}  
   
 .if defined(RESCUEDIR)  .if defined(RESCUEDIR)
 CPPFLAGS+=      -DRESCUEDIR=\"${RESCUEDIR}\"  CPPFLAGS+=      -DRESCUEDIR=\"${RESCUEDIR}\"
 .endif  .endif
   
 _YPSRCS=        ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}  
   
 DPSRCS+=        ${_YPSRCS}  
 CLEANFILES+=    ${_YPSRCS}  
   
 .if !empty(SRCS:N*.h:N*.sh:N*.fth)  
 OBJS+=          ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}  
 LOBJS+=         ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}  
 .endif  
   
 .if defined(OBJS) && !empty(OBJS)                                       # {  
 .NOPATH: ${OBJS} ${PROG} ${_YPSRCS}  
   
 _PROGLDOPTS=  _PROGLDOPTS=
 .if ${SHLINKDIR} != "/usr/libexec"      # XXX: change or remove if ld.so moves  .if ${SHLINKDIR} != "/usr/libexec"      # XXX: change or remove if ld.so moves
 .if ${OBJECT_FMT} == "ELF"  .if ${OBJECT_FMT} == "ELF"
Line 180  _PROGLDOPTS+= -Wl,-rpath-link,${DESTDIR}
Line 165  _PROGLDOPTS+= -Wl,-rpath-link,${DESTDIR}
                 -L${DESTDIR}${SHLIBINSTALLDIR}                  -L${DESTDIR}${SHLIBINSTALLDIR}
 .endif  .endif
   
   __proginstall: .USE
           ${_MKTARGET_INSTALL}
           ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
                   ${STRIPFLAG} ${.ALLSRC} ${.TARGET}
   
   __progdebuginstall: .USE
           ${_MKTARGET_INSTALL}
           ${INSTALL_FILE} -o ${DEBUGOWN} -g ${DEBUGGRP} -m ${DEBUGMODE} \
                   ${.ALLSRC} ${.TARGET}
   
   
   
   #
   # Backwards compatibility with Makefiles that assume that bsd.prog.mk
   # can only build a single binary.
   #
   
   _APPEND_MANS=yes
   _APPEND_SRCS=yes
   
 .if defined(PROG_CXX)  .if defined(PROG_CXX)
 _CCLINK=        ${CXX}  PROG=           ${PROG_CXX}
 .else  _CCLINK=        ${CXX} # XXX Some Makefiles rely on this being public.
 _CCLINK=        ${CC}  
 .endif  .endif
   
 .if ${MKDEBUG} != "no" && ${OBJECT_FMT} == "ELF" && !commands(${PROG})  .if defined(PROG)
 _PROGDEBUG=     ${PROGNAME}.debug  _CCLINK?=       ${CC} # XXX Some Makefiles rely on this being public.
   .  if defined(MAN)
   MAN.${PROG}=    ${MAN}
   _APPEND_MANS=   no
   .  endif
   .  if !defined(OBJS)
   OBJS=           ${OBJS.${PROG}}
   .  endif
   .  if defined(PROGNAME)
   PROGNAME.${PROG}=       ${PROGNAME}
   .  endif
   .  if defined(SRCS)
   SRCS.${PROG}=   ${SRCS}
   _APPEND_SRCS=   no
   .  endif
   .endif
   
   # Turn the single-program PROG and PROG_CXX variables into their multi-word
   # counterparts, PROGS and PROGS_CXX.
   .if defined(PROG_CXX) && !defined(PROGS_CXX)
   PROGS_CXX=      ${PROG_CXX}
   .elif defined(PROG) && !defined(PROGS)
   PROGS=          ${PROG}
 .endif  .endif
   
 .gdbinit:  
         rm -f .gdbinit  
 .if defined(DESTDIR) && !empty(DESTDIR)  #
         echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit  # Per-program definitions and targets.
 .else  #
         touch .gdbinit  
 .endif  # Definitions specific to C programs.
 .for __gdbinit in ${GDBINIT}  .for _P in ${PROGS}
         echo "source ${__gdbinit}" >> .gdbinit  SRCS.${_P}?=    ${_P}.c
   _CCLINK.${_P}=  ${CC}
 .endfor  .endfor
   
 ${OBJS} ${LOBJS}: ${DPSRCS}  # Definitions specific to C++ programs.
   .for _P in ${PROGS_CXX}
   SRCS.${_P}?=    ${_P}.cc
   _CCLINK.${_P}=  ${CXX}
   .endfor
   
   # Language-independent definitions.
   .for _P in ${PROGS} ${PROGS_CXX}                                        # {
   
   BINDIR.${_P}?=          ${BINDIR}
   PROGNAME.${_P}?=        ${_P}
   
   .if ${MKDEBUG} != "no" && ${OBJECT_FMT} == "ELF" && !commands(${_P})
   _PROGDEBUG.${_P}:=      ${PROGNAME.${_P}}.debug
   .endif
   
 ${PROG}: .gdbinit ${LIBCRT0} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}  .if defined(PAXCTL_FLAGS)
 .if !commands(${PROG})  PAXCTL_FLAGS.${_P}?= ${PAXCTL_FLAGS}
   .endif
   
   ##### PROG specific flags.
   COPTS+=     ${COPTS.${_P}}
   CPPFLAGS+=  ${CPPFLAGS.${_P}}
   CXXFLAGS+=  ${CXXFLAGS.${_P}}
   OBJCOPTS+=  ${OBJCOPTS.${_P}}
   LDADD+=     ${LDADD.${_P}}
   LDFLAGS+=   ${LDFLAGS.${_P}}
   LDSTATIC+=  ${LDSTATIC.${_P}}
   
   _COPTS.${_P}=           ${COPTS}    ${COPTS.${_P}}
   _CPPFLAGS.${_P}=        ${CPPFLAGS} ${CPPFLAGS.${_P}}
   _CXXFLAGS.${_P}=        ${CXXFLAGS} ${CXXFLAGS.${_P}}
   _OBJCOPTS.${_P}=        ${OBJCOPTS} ${OBJCOPTS.${_P}}
   _LDADD.${_P}=           ${LDADD}    ${LDADD.${_P}}
   _LDFLAGS.${_P}=         ${LDFLAGS}  ${LDFLAGS.${_P}}
   _LDSTATIC.${_P}=        ${LDSTATIC} ${LDSTATIC.${_P}}
   
   ##### Build and install rules
   .if !empty(_APPEND_SRCS:M[Yy][Ee][Ss])
   SRCS+=          ${SRCS.${_P}} # For bsd.dep.mk
   .endif
   
   _YPSRCS.${_P}=  ${SRCS.${_P}:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS.${_P}:M*.y:.y=.h}}
   
   DPSRCS+=                ${_YPSRCS.${_P}}
   CLEANFILES+=            ${_YPSRCS.${_P}}
   
   .if !empty(SRCS.${_P}:N*.h:N*.sh:N*.fth)
   OBJS.${_P}+=    ${SRCS.${_P}:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
   LOBJS.${_P}+=   ${LSRCS:.c=.ln} ${SRCS.${_P}:M*.c:.c=.ln}
   .endif
   
   .if defined(OBJS.${_P}) && !empty(OBJS.${_P})                   # {
   .NOPATH: ${OBJS.${_P}} ${_P} ${_YPSRCS.${_P}}
   
   ${OBJS.${_P}} ${LOBJS.${_P}}: ${DPSRCS}
   
   ${_P}: .gdbinit ${LIBCRT0} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
   .if !commands(${_P})
         ${_MKTARGET_LINK}          ${_MKTARGET_LINK}
 .if defined(DESTDIR)  .if defined(DESTDIR)
         ${_CCLINK} -Wl,-nostdlib \          ${_CCLINK.${_P}} -Wl,-nostdlib \
             ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} \              ${_LDFLAGS.${_P}} ${_LDSTATIC.${_P}} -o ${.TARGET} ${_PROGLDOPTS} \
             -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/  \              -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/  \
             ${OBJS} ${LDADD} \              ${OBJS.${_P}} ${_LDADD.${_P}} \
             -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib              -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib
 .else  .else
         ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}          ${_CCLINK.${_P}} ${_LDFLAGS.${_P}} ${_LDSTATIC.${_P}} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS.${_P}} ${_LDADD.${_P}}
 .endif  # defined(DESTDIR)  .endif  # defined(DESTDIR)
 .if defined(PAXCTL_FLAGS.${PROG})  .if defined(PAXCTL_FLAGS.${_P})
         ${PAXCTL} ${PAXCTL_FLAGS.${PROG}} ${.TARGET}          ${PAXCTL} ${PAXCTL_FLAGS.${_P}} ${.TARGET}
 .endif  .endif
 .endif  # !commands(${PROG})  .endif  # !commands(${_P})
   
 ${PROG}.ro: ${OBJS} ${DPADD}  ${_P}.ro: ${OBJS.${_P}} ${DPADD}
         ${_MKTARGET_LINK}          ${_MKTARGET_LINK}
         ${LD} -r -dc -o ${.TARGET} ${OBJS}          ${LD} -r -dc -o ${.TARGET} ${OBJS.${_P}}
   
 .if defined(_PROGDEBUG)  .if defined(_PROGDEBUG.${_P})
 ${_PROGDEBUG}: ${PROG}  ${_PROGDEBUG}.${_P}: ${_P}
         ${_MKTARGET_CREATE}          ${_MKTARGET_CREATE}
         ${OBJCOPY} --only-keep-debug ${PROG} ${_PROGDEBUG}          ${OBJCOPY} --only-keep-debug ${_P} ${_PROGDEBUG.${_P}}
         ${OBJCOPY} -R .gnu_debuglink --add-gnu-debuglink=${_PROGDEBUG} ${PROG} \          ${OBJCOPY} -R .gnu_debuglink --add-gnu-debuglink=${_PROGDEBUG.${_P}} ${_P} \
             || rm -f ${_PROGDEBUG}              || rm -f ${_PROGDEBUG.${_P}}
 .endif  .endif
   
 .endif  # defined(OBJS) && !empty(OBJS)                                 # }  .endif  # defined(OBJS.${_P}) && !empty(OBJS.${_P})                     # }
   
 .if !defined(MAN)  
 MAN=    ${PROG}.1  
 .endif  # !defined(MAN)  
 .endif  # defined(PROG)                                                 # }  
   
 realall: ${PROG} ${_PROGDEBUG} ${SCRIPTS}  
   
 cleanprog: .PHONY cleanobjs cleanextra  
         rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG} ${_PROGDEBUG}  
   
 cleanobjs: .PHONY  .if !defined(MAN.${_P})
 .if defined(OBJS) && !empty(OBJS)  MAN.${_P}=      ${_P}.1
         rm -f ${OBJS} ${LOBJS}  .endif  # !defined(MAN.${_P})
   .if !empty(_APPEND_MANS:M[Yy][Ee][Ss])
   MAN+=           ${MAN.${_P}}
 .endif  .endif
   
 cleanextra: .PHONY  realall: ${_P} ${_PROGDEBUG.${_P}}
 .if defined(CLEANFILES) && !empty(CLEANFILES)  
         rm -f ${CLEANFILES}  
 .endif  
   
 .if defined(PROG) && !target(proginstall)                               # {  cleanprog: cleanprog-${_P}
   cleanprog-${_P}:
           rm -f ${_P} ${_PROGDEBUG.${_P}}
   
 proginstall::   ${DESTDIR}${BINDIR}/${PROGNAME} ${_PROGDEBUG:D${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}}  .if defined(OBJS.${_P}) && !empty(OBJS.${_P})
 .PRECIOUS:      ${DESTDIR}${BINDIR}/${PROGNAME} ${_PROGDEBUG:D${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}}  cleanobjs: cleanobjs-${_P}
   cleanobjs-${_P}:
           rm -f ${OBJS.${_P}} ${LOBJS.${_P}}
   .endif
   
 __proginstall: .USE  _PROG_INSTALL+= proginstall-${_P}
         ${_MKTARGET_INSTALL}  
         ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \  
                 ${STRIPFLAG} ${.ALLSRC} ${.TARGET}  
   
 __progdebuginstall: .USE  .if !target(proginstall-${_P})                                          # {
         ${_MKTARGET_INSTALL}  proginstall-${_P}::     ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}} \
         ${INSTALL_FILE} -o ${DEBUGOWN} -g ${DEBUGGRP} -m ${DEBUGMODE} \                  ${_PROGDEBUG.${_P}:D${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}}
                 ${.ALLSRC} ${.TARGET}  .PRECIOUS:      ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}} \
                   ${_PROGDEBUG.${_P}:D${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}}
   
 .if ${MKUPDATE} == "no"  .if ${MKUPDATE} == "no"
 ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall  ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}! ${_P} __proginstall
 .if !defined(BUILD) && !make(all) && !make(${PROG})  .if !defined(BUILD) && !make(all) && !make(${_P})
 ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE  ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}! .MADE
 .endif  .endif
 .if defined(_PROGDEBUG)  .if defined(_PROGDEBUG.${_P})
 ${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}! ${_PROGDEBUG} __progdebuginstall  ${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}! ${_PROGDEBUG.${_P}} __progdebuginstall
 .if !defined(BUILD) && !make(all) && !make(${PROG})  .if !defined(BUILD) && !make(all) && !make(${_P})
 ${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}! .MADE  ${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}! .MADE
 .endif  .endif
 .endif  #  define(_PROGDEBUG)  .endif  #  define(_PROGDEBUG.${_P})
 .else   # MKUPDATE != no  .else   # MKUPDATE != no
 ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall  ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}: ${_P} __proginstall
 .if !defined(BUILD) && !make(all) && !make(${PROG})  .if !defined(BUILD) && !make(all) && !make(${_P})
 ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE  ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}: .MADE
 .endif  .endif
 .if defined(_PROGDEBUG)  .if defined(_PROGDEBUG.${_P})
 ${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}: ${_PROGDEBUG} __progdebuginstall  ${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}: ${_PROGDEBUG.${_P}} __progdebuginstall
 .if !defined(BUILD) && !make(all) && !make(${PROG})  .if !defined(BUILD) && !make(all) && !make(${_P})
 ${DESTDIR}${DEBUGDIR}${BINDIR}/${_PROGDEBUG}: .MADE  ${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}: .MADE
 .endif  .endif
 .endif  #  defined(_PROGDEBUG)  .endif  #  defined(_PROGDEBUG.${_P})
 .endif  # MKUPDATE != no  .endif  # MKUPDATE != no
   
 .endif  # defined(PROG) && !target(proginstall)                         # }  .endif  # !target(proginstall-${_P})                                    # }
   
   lint: lint-${_P}
   lint-${_P}: ${LOBJS.${_P}}
   .if defined(LOBJS.${_P}) && !empty(LOBJS.${_P})
           ${LINT} ${LINTFLAGS} ${_LDFLAGS.${_P}:C/-L[  ]*/-L/Wg:M-L*} ${LOBJS.${_P}} ${_LDADD.${_P}}
   .endif
   
   .endfor # _P in ${PROGS} ${PROGS_CXX}                                   # }
   
 .if !target(proginstall)  .if !target(proginstall)
 proginstall::  proginstall:: ${_PROG_INSTALL}
 .endif  .endif
 .PHONY:         proginstall  .PHONY:         proginstall
   
   
   
   realall: ${SCRIPTS}
 .if defined(SCRIPTS) && !target(scriptsinstall)                         # {  .if defined(SCRIPTS) && !target(scriptsinstall)                         # {
 SCRIPTSDIR?=${BINDIR}  SCRIPTSDIR?=${BINDIR}
 SCRIPTSOWN?=${BINOWN}  SCRIPTSOWN?=${BINOWN}
Line 337  scriptsinstall::
Line 422  scriptsinstall::
 .endif  .endif
 .PHONY:         scriptsinstall  .PHONY:         scriptsinstall
   
 lint: ${LOBJS}  
 .if defined(LOBJS) && !empty(LOBJS)  
         ${LINT} ${LINTFLAGS} ${LDFLAGS:C/-L[  ]*/-L/Wg:M-L*} ${LOBJS} ${LDADD}  
 .endif  
   
 ##### Pull in related .mk logic  ##### Pull in related .mk logic
 .include <bsd.man.mk>  .include <bsd.man.mk>
 .include <bsd.nls.mk>  .include <bsd.nls.mk>

Legend:
Removed from v.1.222  
changed lines
  Added in v.1.223

CVSweb <webmaster@jp.NetBSD.org>