diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..77e8d3a --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,108 @@ +PMAKE= ${CURDIR}/usr.bin/make/pmake -m ${CURDIR}/share/mk +CROSSDIR= /usr/obj${CURDIR}/cross +CROSSPATH= ${CROSSDIR}/usr/bin:${CROSSDIR}/usr/sbin:${PATH} +CROSSCFLAGS= -D__FBSDID='static const char *id=' -D__unused= \ + -D__dead2= -DS_ISTXT=S_ISVTX -DEFTYPE=EINVAL \ + -DCROSS_BUILDING -I${CROSSDIR}/usr/include +CROSSMAKE= PATH=${CROSSPATH} \ + ${PMAKE} WARNS=0 MAKEOBJDIRPREFIX=${CROSSDIR} \ + -DWITHOUT_PROFILE -DWITHOUT_CLANG \ + DESTDIR=${CROSSDIR} BINOWN=`id -nu` BINGRP=`id -ng` \ + NO_MAN=1 CFLAGS_APPEND="${CROSSCFLAGS}" \ + LDFLAGS_APPEND="-L${CROSSDIR}/usr/lib" TSORTFLAGS='' + + +TGTS= kernel-toolchain buildkernel installkernel buildenv \ + buildenvvars xdev-build xdev-install + +# Tools required to cross build +TOOLS= tools/compat usr.bin/file2c usr.bin/m4 usr.bin/make \ + usr.bin/mkdep usr.bin/lex usr.bin/tsort usr.bin/unifdef \ + usr.bin/yacc usr.sbin/mtree lib/libmd + +.PHONY: ${TGTS} ${TOOLS} + +all: + @echo "Run ${MAKE} with one of:" + @echo "\t${TGTS}" + @false + +usr.bin/make: + ${MAKE} -C ${CURDIR}/$@ -f Makefile.dist pmake + +pretools: usr.bin/make +# Headers that are needed in the build and may conflict with the OS's headers + mkdir -p /usr/obj/${CURDIR}/cross/lib + mkdir -p /usr/obj/${CURDIR}/cross/usr/bin + mkdir -p /usr/obj/${CURDIR}/cross/usr/sbin + mkdir -p /usr/obj/${CURDIR}/cross/usr/lib + mkdir -p /usr/obj/${CURDIR}/cross/usr/include + mkdir -p /usr/obj/${CURDIR}/cross/usr/include/sys + mkdir -p /usr/obj/${CURDIR}/cross/usr/include/machine + + cp ${CURDIR}/sys/sys/sbuf.h /usr/obj/${CURDIR}/cross/usr/include/sys + cp ${CURDIR}/sys/sys/md5.h /usr/obj/${CURDIR}/cross/usr/include/sys +# Not all systems have machine/endian.h or sys/endian.h + echo '#include ' > /usr/obj/${CURDIR}/cross/usr/include/sys/endian.h + echo '#include ' > /usr/obj/${CURDIR}/cross/usr/include/machine/endian.h + +# For headers not on other systems that won't conflict with the OS's + mkdir -p /usr/obj/${CURDIR}/compat/usr/include + cp ${CURDIR}/include/elf-hints.h /usr/obj/${CURDIR}/compat/usr/include + +# lorder assumes FreeBSD's mktemp +usr.bin/mktemp: pretools + ${CROSSMAKE} -C ${CURDIR}/$@ obj + ${CROSSMAKE} -C ${CURDIR}/$@ all + ${CROSSMAKE} -C ${CURDIR}/$@ install + +usr.bin/lorder: pretools usr.bin/mktemp + ${CROSSMAKE} -C ${CURDIR}/$@ obj + ${CROSSMAKE} -C ${CURDIR}/$@ all + ${CROSSMAKE} -C ${CURDIR}/$@ install + +tools/compat: pretools usr.bin/lorder + ${CROSSMAKE} -C ${CURDIR}/$@ obj + ${CROSSMAKE} -C ${CURDIR}/$@ includes + ${CROSSMAKE} -C ${CURDIR}/$@ all + ${CROSSMAKE} -C ${CURDIR}/$@ install + +usr.bin/mkdep usr.bin/unifdef usr.bin/yacc: tools/compat + ${CROSSMAKE} -C ${CURDIR}/$@ obj + ${CROSSMAKE} -C ${CURDIR}/$@ all + ${CROSSMAKE} -C ${CURDIR}/$@ install + +usr.bin/tsort: tools/compat + ${CROSSMAKE} -C ${CURDIR}/$@ obj + ${CROSSMAKE} -C ${CURDIR}/$@ all LDADD_APPEND="-ldb -lcompat" + ${CROSSMAKE} -C ${CURDIR}/$@ install + +usr.sbin/mtree: lib/libmd +usr.bin/file2c usr.bin/m4 usr.sbin/mtree: tools/compat + ${CROSSMAKE} -C ${CURDIR}/$@ obj + ${CROSSMAKE} -C ${CURDIR}/$@ all LDADD_APPEND="-lcompat" + ${CROSSMAKE} -C ${CURDIR}/$@ install + +usr.bin/lex: pretools tools/compat usr.bin/yacc + ${CROSSMAKE} -C ${CURDIR}/$@ obj + ${CROSSMAKE} -C ${CURDIR}/$@ bootstrap + ${CROSSMAKE} -C ${CURDIR}/$@ all + ${CROSSMAKE} -C ${CURDIR}/$@ install + +lib/libmd: pretools + ${CROSSMAKE} -C ${CURDIR}/$@ obj + ${CROSSMAKE} -C ${CURDIR}/$@ all + ${CROSSMAKE} -C ${CURDIR}/$@ install + +MACHINE?= i386 +MACHINE_ARCH?= i386 + +TGTARGS=-DWITHOUT_CDDL -DWITHOUT_GAMES -DWITHOUT_CXX -DWITHOUT_NIS \ + -DWITHOUT_KERBEROS -DNO_MODULES -DNO_KERNELCLEAN -DNO_KERNELDEPEND \ + -DNO_SHARE + +${TGTS}: ${TOOLS} + FORCE_PATH=${CROSSPATH} \ + ${PMAKE} ${TGTARGS} MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} \ + BINGRP=`id -ng root` INSTALL="sh ${CURDIR}/tools/install.sh" LIBC= $@ + diff --git a/Makefile b/Makefile index 5edb4da..2e46bed 100644 --- a/Makefile +++ b/Makefile @@ -105,11 +105,13 @@ TGTS+= ${BITGTS} .ORDER: buildkernel reinstallkernel .ORDER: buildkernel reinstallkernel.debug -PATH= /sbin:/bin:/usr/sbin:/usr/bin +# Allow the path to be overridden but only when asked +FORCE_PATH?= /sbin:/bin:/usr/sbin:/usr/bin +PATH= ${FORCE_PATH} MAKEOBJDIRPREFIX?= /usr/obj _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \ ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ - -f /dev/null -V MAKEOBJDIRPREFIX dummy + -f /dev/null -m ${.CURDIR}/share/mk -V MAKEOBJDIRPREFIX dummy .if !empty(_MAKEOBJDIRPREFIX) .error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ (in make.conf(5)) or command-line variable. diff --git a/Makefile.inc1 b/Makefile.inc1 index d292ea9..555876a 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -102,6 +102,8 @@ SUPFLAGS?= -g -L 2 SUPFLAGS+= -h ${SUPHOST} .endif +OSKERN!= uname -s + MAKEOBJDIRPREFIX?= /usr/obj .if !defined(OSRELDATE) .if exists(/usr/include/osreldate.h) @@ -167,9 +169,12 @@ OBJTREE= ${MAKEOBJDIRPREFIX} .else OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH} .endif +# CROSSTMP is used to hole compat tools when building from not FreeBSD +CROSSTMP?= ${OBJTREE}${.CURDIR}/cross +COMPATTMP?= ${OBJTREE}${.CURDIR}/compat WORLDTMP= ${OBJTREE}${.CURDIR}/tmp # /usr/games added for fortune which depend on strfile -BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games +BPATH= ${CROSSTMP}/usr/bin:${CROSSTMP}/usr/sbin:${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games STRICTTMPPATH= ${BPATH}:${XPATH} TMPPATH= ${STRICTTMPPATH}:${PATH} @@ -1017,6 +1022,12 @@ _kerberos5_tools= kerberos5/tools _rescue= rescue/rescue .endif +.if ${OSKERN} == "FreeBSD" +_sysinstall= usr.sbin/sysinstall +.else +BUILDTOOLSARGS= CFLAGS_APPEND='-D__FBSDID="static const char *id=" -D__unused= -I${CROSSTMP}/usr/include -DCROSS_BUILDING' +.endif + build-tools: .for _tool in \ bin/csh \ @@ -1028,11 +1039,11 @@ build-tools: ${_aicasm} \ usr.bin/awk \ lib/libmagic \ - usr.sbin/sysinstall + ${_sysinstall} ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \ cd ${.CURDIR}/${_tool}; \ ${MAKE} DIRPRFX=${_tool}/ obj; \ - ${MAKE} DIRPRFX=${_tool}/ build-tools + ${MAKE} DIRPRFX=${_tool}/ ${BUILDTOOLSARGS} build-tools .endfor .for _tool in \ gnu/usr.bin/cc/cc_tools \ @@ -1375,6 +1386,8 @@ NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \ XDDIR=${XDEV}-freebsd XDTP=/usr/${XDDIR} CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \ + CROSSTMP=${CROSSTMP} \ + COMPATTMP=${COMPATTMP} \ TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} CDENV= ${CDBENV} \ _SHLIBDIRPREFIX=${XDTP} \ @@ -1382,10 +1395,10 @@ CDENV= ${CDBENV} \ CD2ENV=${CDENV} \ MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH} +XDDESTDIR=${DESTDIR}${XDTP} CDTMP= ${MAKEOBJDIRPREFIX}/${XDEV}/${.CURDIR}/tmp CDMAKE=${CDENV} ${MAKE} ${NOFUN} -CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN} -XDDESTDIR=${DESTDIR}${XDTP} +CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN} .if !defined(OSREL) OSREL!= uname -r | sed -e 's/[-(].*//' .endif @@ -1407,8 +1420,8 @@ _xb-cross-tools: ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \ cd ${.CURDIR}/${_tool}; \ ${CDMAKE} DIRPRFX=${_tool}/ obj; \ - ${CDMAKE} DIRPRFX=${_tool}/ depend; \ - ${CDMAKE} DIRPRFX=${_tool}/ all + ${CDMAKE} DIRPRFX=${_tool}/ depend CFLAGS_APPEND=-I${COMPATTMP}/usr/include; \ + ${CDMAKE} DIRPRFX=${_tool}/ all CFLAGS_APPEND=-I${COMPATTMP}/usr/include .endfor _xi-mtree: @@ -1443,6 +1456,7 @@ _xi-libraries: DESTDIR=${XDDESTDIR} _xi-links: +.if ${OSKERN} == "FreeBSD" || !empty(${FORCE_XLINKS}) ${_+_}cd ${XDDESTDIR}/usr/bin; \ for i in *; do \ ln -sf ../../${XDTP}/usr/bin/$$i \ @@ -1452,6 +1466,8 @@ _xi-links: done .endif +.endif + .if !empty(KRNLOBJDIR) && !empty(KERNCONF) DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/ diff --git a/bin/sh/mknodes.c b/bin/sh/mknodes.c index 1a177f8..0dae52d 100644 --- a/bin/sh/mknodes.c +++ b/bin/sh/mknodes.c @@ -55,6 +55,10 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef CROSS_BUILDING +#include +#endif + #define MAXTYPES 50 /* max number of node types */ #define MAXFIELDS 20 /* max fields in a structure */ #define BUFLEN 100 /* size of character buffers */ diff --git a/contrib/ncurses/ncurses/tinfo/MKfallback.sh b/contrib/ncurses/ncurses/tinfo/MKfallback.sh index 9feab35..aad5d18 100755 --- a/contrib/ncurses/ncurses/tinfo/MKfallback.sh +++ b/contrib/ncurses/ncurses/tinfo/MKfallback.sh @@ -36,13 +36,13 @@ # specified list of types generated in. # -terminfo_dir=$1 -shift +if test $# != 0 ; then + terminfo_dir=$1 + shift -terminfo_src=$1 -shift + terminfo_src=$1 + shift -if test $# != 0 ; then tmp_info=tmp_info echo creating temporary terminfo directory... >&2 diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist index a138bba..e347385 100644 --- a/etc/mtree/BSD.include.dist +++ b/etc/mtree/BSD.include.dist @@ -3,7 +3,7 @@ # Please see the file src/etc/mtree/README before making changes to this file. # -/set type=dir uname=root gname=wheel mode=0755 +/set type=dir uname=root gid=0 mode=0755 . altq .. diff --git a/etc/mtree/BSD.root.dist b/etc/mtree/BSD.root.dist index ce8a456..b56ce22 100644 --- a/etc/mtree/BSD.root.dist +++ b/etc/mtree/BSD.root.dist @@ -3,7 +3,7 @@ # Please see the file src/etc/mtree/README before making changes to this file. # -/set type=dir uname=root gname=wheel mode=0755 +/set type=dir uname=root gid=0 mode=0755 . bin .. diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist index 1443ada..b910168 100644 --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -3,7 +3,7 @@ # Please see the file src/etc/mtree/README before making changes to this file. # -/set type=dir uname=root gname=wheel mode=0755 +/set type=dir uname=root gid=0 mode=0755 . bin .. diff --git a/gnu/lib/libgcc/Makefile b/gnu/lib/libgcc/Makefile index b54e0bd..cdb4b1c 100644 --- a/gnu/lib/libgcc/Makefile +++ b/gnu/lib/libgcc/Makefile @@ -332,7 +332,7 @@ CLEANFILES += libgcc.map lib${LIB}_eh.a: ${EH_OBJS_T} @${ECHO} building static ${LIB}_eh library @rm -f ${.TARGET} - @${AR} cq ${.TARGET} `lorder ${EH_OBJS_T} | tsort -q` + @${AR} cq ${.TARGET} `lorder ${EH_OBJS_T} | ${TSORT} ${TSORTFLAGS}` ${RANLIB} ${.TARGET} all: lib${LIB}_eh.a @@ -341,7 +341,7 @@ all: lib${LIB}_eh.a lib${LIB}_eh_p.a: ${EH_OBJS_P} @${ECHO} building profiled ${LIB}_eh library @rm -f ${.TARGET} - @${AR} cq ${.TARGET} `lorder ${EH_OBJS_P} | tsort -q` + @${AR} cq ${.TARGET} `lorder ${EH_OBJS_P} | ${TSORT} ${TSORTFLAGS}` ${RANLIB} ${.TARGET} all: lib${LIB}_eh_p.a .endif diff --git a/gnu/usr.bin/cc/cc_tools/Makefile b/gnu/usr.bin/cc/cc_tools/Makefile index f248313..6f670d5 100644 --- a/gnu/usr.bin/cc/cc_tools/Makefile +++ b/gnu/usr.bin/cc/cc_tools/Makefile @@ -334,7 +334,7 @@ GENSRCS+= specs.h gstdint.h: echo '#include "sys/types.h"' > ${.TARGET} - echo '#include "sys/stdint.h"' >> ${.TARGET} + echo '#include "stdint.h"' >> ${.TARGET} GENSRCS+= gstdint.h @@ -507,7 +507,7 @@ ${_src:R:S/$/.o/}: ${_src} ${LIBIBERTY}: ${LIBIBERTY_OBJS} @rm -f ${.TARGET} - @${AR} cq ${.TARGET} `lorder ${LIBIBERTY_OBJS} | tsort -q` + @${AR} cq ${.TARGET} `lorder ${LIBIBERTY_OBJS} | ${TSORT} ${TSORTFLAGS}` ${RANLIB} ${.TARGET} CLEANFILES+= ${LIBIBERTY} ${LIBIBERTY_OBJS} diff --git a/include/db.h b/include/db.h index 4d04db4..0043951 100644 --- a/include/db.h +++ b/include/db.h @@ -37,6 +37,7 @@ #include #include +#include #define RET_ERROR -1 /* Return values. */ #define RET_SUCCESS 0 diff --git a/include/vis.h b/include/vis.h index f388954..c221039 100644 --- a/include/vis.h +++ b/include/vis.h @@ -33,7 +33,7 @@ #ifndef _VIS_H_ #define _VIS_H_ -#include +#include #ifndef _SIZE_T_DECLARED typedef __size_t size_t; diff --git a/lib/Makefile b/lib/Makefile index 6dcd178..beda73a 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -139,7 +139,7 @@ _libbsnmp= libbsnmp .endif .if ${MK_CLANG} != "no" && !defined(COMPAT_32BIT) -_clang= clang +#_clang= clang .endif .if ${MK_GPIB} != "no" diff --git a/lib/libc/db/db/db.c b/lib/libc/db/db/db.c index 3cfd0a9..38cf19a 100644 --- a/lib/libc/db/db/db.c +++ b/lib/libc/db/db/db.c @@ -34,9 +34,12 @@ static char sccsid[] = "@(#)db.c 8.4 (Berkeley) 2/21/94"; __FBSDID("$FreeBSD$"); #include +#include #include +#define __USE_GNU /* Define this so O_NOFOLLOW is defined */ #include +#undef __USE_GNU /* Having this defined breaks stdio.h */ #include #include diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc index 4eadf98..7ddd177 100644 --- a/lib/libc/net/Makefile.inc +++ b/lib/libc/net/Makefile.inc @@ -37,7 +37,7 @@ LFLAGS+=-P_nsyy CLEANFILES+=nslexer.c nslexer.c: nslexer.l - ${LEX} ${LFLAGS} -o/dev/stdout ${.IMPSRC} | \ + ${LEX} ${LFLAGS} -t ${.IMPSRC} | \ sed -e '/YY_BUF_SIZE/s/16384/1024/' >${.TARGET} MAN+= byteorder.3 ethers.3 eui64.3 \ diff --git a/lib/libmd/sha256.h b/lib/libmd/sha256.h index ce51787..930a121 100644 --- a/lib/libmd/sha256.h +++ b/lib/libmd/sha256.h @@ -30,6 +30,7 @@ #define _SHA256_H_ #include +#include typedef struct SHA256Context { uint32_t state[8]; diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 67a09d7..0e6a542 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -144,9 +144,9 @@ lib${LIB}.a: ${OBJS} ${STATICOBJS} @${ECHO} building static ${LIB} library @rm -f ${.TARGET} .if !defined(NM) - @${AR} cq ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD} + @${AR} cq ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | ${TSORT} ${TSORTFLAGS}` ${ARADD} .else - @${AR} cq ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD} + @${AR} cq ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | ${TSORT} ${TSORTFLAGS}` ${ARADD} .endif ${RANLIB} ${.TARGET} .endif @@ -161,9 +161,9 @@ lib${LIB}_p.a: ${POBJS} @${ECHO} building profiled ${LIB} library @rm -f ${.TARGET} .if !defined(NM) - @${AR} cq ${.TARGET} `lorder ${POBJS} | tsort -q` ${ARADD} + @${AR} cq ${.TARGET} `lorder ${POBJS} | ${TSORT} ${TSORTFLAGS}` ${ARADD} .else - @${AR} cq ${.TARGET} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD} + @${AR} cq ${.TARGET} `NM='${NM}' lorder ${POBJS} | ${TSORT} ${TSORTFLAGS}` ${ARADD} .endif ${RANLIB} ${.TARGET} .endif @@ -185,11 +185,11 @@ ${SHLIB_NAME}: ${SOBJS} .if !defined(NM) @${CC} ${LDFLAGS} ${SSP_CFLAGS} -shared -Wl,-x \ -o ${.TARGET} -Wl,-soname,${SONAME} \ - `lorder ${SOBJS} | tsort -q` ${LDADD} + `lorder ${SOBJS} | ${TSORT} ${TSORTFLAGS}` ${LDADD} .else @${CC} ${LDFLAGS} ${SSP_CFLAGS} -shared -Wl,-x \ -o ${.TARGET} -Wl,-soname,${SONAME} \ - `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD} + `NM='${NM}' lorder ${SOBJS} | ${TSORT} ${TSORTFLAGS}` ${LDADD} .endif @[ -z "${CTFMERGE}" -o -n "${NO_CTF}" ] || ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS} .endif diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 810a83b..96a3093 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -62,9 +62,9 @@ OBJS+= ${SRCS:N*.h:R:S/$/.o/g} ${PROG}: ${OBJS} .if defined(PROG_CXX) - ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} + ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} ${LDADD_APPEND} .else - ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} + ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} ${LDADD_APPEND} .endif @[ -z "${CTFMERGE}" -o -n "${NO_CTF}" ] || ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} @@ -86,9 +86,9 @@ OBJS= ${PROG}.o ${PROG}: ${OBJS} .if defined(PROG_CXX) - ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} + ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} ${LDADD_APPEND} .else - ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} + ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} ${LDADD_APPEND} .endif @[ -z "${CTFMERGE}" -o -n "${NO_CTF}" ] || ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} .endif diff --git a/share/mk/sys.mk b/share/mk/sys.mk index ac77b25..c51a78f 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -77,6 +77,10 @@ CTFFLAGS += -g #CFLAGS += -g .endif +# For Cross building +CFLAGS += ${CFLAGS_APPEND} +LDFLAGS += ${LDFLAGS_APPEND} + CXX ?= c++ CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition} PO_CXXFLAGS ?= ${CXXFLAGS} @@ -138,6 +142,9 @@ RFLAGS ?= SHELL ?= sh +TSORT ?= tsort +TSORTFLAGS ?= -q + YACC ?= yacc .if defined(%POSIX) YFLAGS ?= diff --git a/tools/compat/Makefile b/tools/compat/Makefile new file mode 100644 index 0000000..21a4db6 --- /dev/null +++ b/tools/compat/Makefile @@ -0,0 +1,5 @@ +# $FreeBSD$ + +SUBDIR= libcompat libdb + +.include diff --git a/tools/compat/libcompat/Makefile b/tools/compat/libcompat/Makefile new file mode 100644 index 0000000..88a9ee9 --- /dev/null +++ b/tools/compat/libcompat/Makefile @@ -0,0 +1,21 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../../include +.PATH: ${.CURDIR}/../../../lib/libc/gen +.PATH: ${.CURDIR}/../../../lib/libc/net +.PATH: ${.CURDIR}/../../../lib/libc/stdlib +.PATH: ${.CURDIR}/../../../lib/libc/string + +LIB= compat +MAN= +SRCS= freebsd_compat.c endian.c err.c fgetln.c issetugid.c +INCS= freebsd_compat.h namespace.h un-namespace.h + +# External files +SRCS+= base64.c reallocf.c setmode.c strlcat.c strlcpy.c stringlist.c \ + unvis.c vis.c +INCS+= _ctype.h db.h stringlist.h vis.h + +MKDEP_CFLAGS+= -I${.CURDIR}/../../../lib/libc/include + +.include diff --git a/tools/compat/libcompat/endian.c b/tools/compat/libcompat/endian.c new file mode 100644 index 0000000..65345b7 --- /dev/null +++ b/tools/compat/libcompat/endian.c @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2002 Thomas Moestl + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Based on sys/sys/endian.h for non FreeBSD systems + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +uint32_t +be32dec(const void *pp) +{ + unsigned char const *p = (unsigned char const *)pp; + + return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); +} + +void +be32enc(void *pp, uint32_t u) +{ + unsigned char *p = (unsigned char *)pp; + + p[0] = (u >> 24) & 0xff; + p[1] = (u >> 16) & 0xff; + p[2] = (u >> 8) & 0xff; + p[3] = u & 0xff; +} + diff --git a/tools/compat/libcompat/err.c b/tools/compat/libcompat/err.c new file mode 100644 index 0000000..956dceb --- /dev/null +++ b/tools/compat/libcompat/err.c @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2010 Andrew Turner + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +void +errc(int eval, int code, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + errno = code; + verr(eval, fmt, ap); + va_end(ap); +} + +void +warnc(int code, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + errno = code; + vwarn(fmt, ap); + va_end(ap); +} + diff --git a/tools/compat/libcompat/fgetln.c b/tools/compat/libcompat/fgetln.c new file mode 100644 index 0000000..cbabed7 --- /dev/null +++ b/tools/compat/libcompat/fgetln.c @@ -0,0 +1,62 @@ +/* fgetln.c - a replacement for FreeBSD's fgetln(3) in Linux */ +/*- + * Copyright (c) 2003 Nick Leuta + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#define _GNU_SOURCE +#include +#include + +/* This implementation of fgetln(3) returns pointer to data, which may be + * modified by later calls. Unlike original FreeBSD implementation, the + * allocated (with help of malloc()/realloc()) memory isn't automatically + * free()'d when the stream is fclose()'d. The returned pointer may be free()'d + * by the application at any time, but in some cases this function itself frees + * the memory. + */ + +/* Emulation of FreeBSD's style of the implementation of streams */ +char *__fgetln_int_buf = NULL; +/* Size of the allocated memory */ +size_t __fgetln_int_len = 0; + +char * +fgetln(FILE *fp, size_t *lenp) +{ + /* SKYNICK: Implementation note: "== -1" isn't equal to "< 0"... May be + * getline(3) page will have more notes/examples in future... */ + if(((*lenp) = getline (&__fgetln_int_buf, &__fgetln_int_len, fp)) == -1) { + if (__fgetln_int_buf != NULL) { + free(__fgetln_int_buf); + } + __fgetln_int_buf = NULL; + __fgetln_int_len = 0; + (*lenp) = 0; + } + + return __fgetln_int_buf; +} diff --git a/tools/compat/libcompat/freebsd_compat.c b/tools/compat/libcompat/freebsd_compat.c new file mode 100644 index 0000000..bcbbb51 --- /dev/null +++ b/tools/compat/libcompat/freebsd_compat.c @@ -0,0 +1,63 @@ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* Misc simple functions */ + +#define _GNU_SOURCE +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +const char * +getprogname(void) +{ + return program_invocation_name; +} + +char * +fflagstostr(unsigned long flags) +{ + /* + * Linux doesn't support flags so return + * a null terminated 0 length string. + */ + return calloc(1, 1); +} + +int +strtofflags(char **stringp, unsigned long *setp, unsigned long *clrp) +{ + /* Linux doesn't have filesystem flags */ + return 0; +} + diff --git a/tools/compat/libcompat/freebsd_compat.h b/tools/compat/libcompat/freebsd_compat.h new file mode 100644 index 0000000..ae07299 --- /dev/null +++ b/tools/compat/libcompat/freebsd_compat.h @@ -0,0 +1,41 @@ +/* TODO: License */ + +#ifndef FREEBSD_COMPAT_H +#define FREEBSD_COMPAT_H + +#ifndef __dead2 +#define __dead2 +#endif + +#ifndef __printflike +#define __printflike(a, b) +#endif + +#ifndef __printf0like +#define __printf0like(a, b) +#endif + +#ifndef __unused +#define __unused +#endif + +#ifndef MAXBSIZE +#define MAXBSIZE 65536 +#endif + +#ifndef EFTYPE +#define EFTYPE EINVAL +#endif + +#define arc4random() random() + +void errc(int, int, const char *, ...); +const char *getprogname(void); +mode_t getmode(const void *, mode_t); +void *setmode(const char *); + +#define STAT_NO_ST_FLAGS +char *fflagstostr(unsigned long); +int strtofflags(char **, unsigned long *, unsigned long *); + +#endif diff --git a/tools/compat/libcompat/issetugid.c b/tools/compat/libcompat/issetugid.c new file mode 100644 index 0000000..437e898 --- /dev/null +++ b/tools/compat/libcompat/issetugid.c @@ -0,0 +1,34 @@ +/* + * Copyright (C) - 2007 Robert Connolly + * + * Permission to reproduce, copy, delete, distribute, transmit, use, modify, + * build upon or otherwise exploit this software, in any form, for any + * purpose, in any way, and by anyone, including by methods that have not + * yet been invented or conceived, is hereby granted. + */ + +#include + +extern int __libc_enable_secure; + +int issetugid(void) +{ + if (__libc_enable_secure) + { + return 1; + } + + if (getuid() != geteuid()) + { + return 1; + } + + if (getgid() != getegid()) + { + return 1; + } + + /* Else */ + return 0; +} + diff --git a/tools/compat/libcompat/namespace.h b/tools/compat/libcompat/namespace.h new file mode 100644 index 0000000..88a3c72 --- /dev/null +++ b/tools/compat/libcompat/namespace.h @@ -0,0 +1,35 @@ +/*- + * Copyright (c) 2010 Andrew Turner + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _NAMESPACE_H_ +#define _NAMESPACE_H_ + +/* Unused */ +/* TODO: Auto generate an empty version from the Makefile */ + +#endif /* _NAMESPACE_H_ */ diff --git a/tools/compat/libcompat/un-namespace.h b/tools/compat/libcompat/un-namespace.h new file mode 100644 index 0000000..7e6d4ee --- /dev/null +++ b/tools/compat/libcompat/un-namespace.h @@ -0,0 +1,44 @@ +/*- + * Copyright (c) 2010 Andrew Turner + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _UN_NAMESPACE_H_ +#define _UN_NAMESPACE_H_ + +/* Define the internal libc names as we don't have them outside of FreeBSD */ +#define _open open +#define _close close +#define _read read +#define _write write +#define _writev writev +#define _fcntl fcntl +#define _fstat fstat +#define _fsync fsync +#define _sigprocmask sigprocmask + +#endif /* _UN_NAMESPACE_H_ */ + diff --git a/tools/compat/libdb/Makefile b/tools/compat/libdb/Makefile new file mode 100644 index 0000000..2151f61 --- /dev/null +++ b/tools/compat/libdb/Makefile @@ -0,0 +1,22 @@ + +.PATH: ${.CURDIR}/../../../include +.PATH: ${.CURDIR}/../../../lib/libc/db/db +.PATH: ${.CURDIR}/../../../lib/libc/db/btree +.PATH: ${.CURDIR}/../../../lib/libc/db/hash +.PATH: ${.CURDIR}/../../../lib/libc/db/recno +.PATH: ${.CURDIR}/../../../lib/libc/db/mpool + +LIB= db + +SRCS+= db.c +SRCS+= mpool.c +INCS= db.h mpool.h ndbm.h +.include "${.CURDIR}/../../../lib/libc/db/btree/Makefile.inc" +.include "${.CURDIR}/../../../lib/libc/db/hash/Makefile.inc" +.include "${.CURDIR}/../../../lib/libc/db/recno/Makefile.inc" + +CFLAGS+= -D__DBINTERFACE_PRIVATE -DO_EXLOCK=0 -DO_SHLOCK=0 + +MAN= + +.include diff --git a/usr.bin/lorder/lorder.sh b/usr.bin/lorder/lorder.sh index 958e95d..c3b1a20 100644 --- a/usr.bin/lorder/lorder.sh +++ b/usr.bin/lorder/lorder.sh @@ -77,8 +77,16 @@ ${NM} -go $* | sed " d " +# detect if we should use [[:>:]] or \b for word boundaries +expr "test.a bar" : ".*\.a[[:>:]]" > /dev/null 2>&1 +if [ $? -eq 0 ] ; then + BOUND="[[:>:]]" +else + BOUND="\b" +fi + # eliminate references that can be resolved by the same library. -if [ $(expr "$*" : '.*\.a[[:>:]]') -ne 0 ]; then +if [ $(expr "$*" : ".*\.a${BOUND}") -ne 0 ]; then sort -u -o $S $S sort -u -o $R $R T=$(mktemp -t _temp_) diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c index 847a372..d7a4c87 100644 --- a/usr.bin/m4/main.c +++ b/usr.bin/m4/main.c @@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/usr.bin/make/Makefile.dist b/usr.bin/make/Makefile.dist index 8823d74..eb57e6c 100644 --- a/usr.bin/make/Makefile.dist +++ b/usr.bin/make/Makefile.dist @@ -1,10 +1,28 @@ # $FreeBSD$ # a simple makefile to help builds on !FreeBSD systems -pmake: + +SRCS= arch.c buf.c cond.c dir.c for.c hash.c hash_tables.c job.c \ + lst.c main.c make.c parse.c proc.c shell.c str.c suff.c targ.c \ + util.c var.c +# External files needed to build on some systems +SRCS+= err.c strlcpy.c + +OBJS= $(SRCS:.c=.o) + +pmake: $(OBJS) + echo $(OBJS) @echo 'make started.' - cc -D__dead2="" -D__unused="" -Darc4random=random -D__FBSDID="static const char *id=" -DDEFSHELLNAME=\"sh\" -I. -c *.c cc *.o -o pmake @echo 'make completed.' clean: @rm -f *.o pmake + +err.o: ${CURDIR}/../../tools/compat/libcompat/err.c + cc -D__FBSDID="static const char *id=" -c -o $@ $< + +strlcpy.o: ${CURDIR}/../../lib/libc/string/strlcpy.c + cc -D__FBSDID="static const char *id=" -c -o $@ $< + +%.o: %.c + cc -D__dead2="" -D__unused="" -Darc4random=random -D__FBSDID="static const char *id=" -DDEFSHELLNAME=\"sh\" -I. -c -o $@ $< diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c index 6e7a094..e4ce2c0 100644 --- a/usr.bin/make/cond.c +++ b/usr.bin/make/cond.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "buf.h" #include "cond.h" diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index 7cee3d4..f193662 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -91,6 +91,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index f2eccce..9e084f6 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include #include diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 3b091fd..8c8ccad 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -48,6 +48,11 @@ static char copyright[] = #include __FBSDID("$FreeBSD$"); +#if !defined(__FreeBSD__) && defined(__unused) +/* Linux used __unused in */ +#undef __unused +#endif + /* * main.c * The main file for this entire program. Exit routines etc @@ -71,6 +76,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -372,7 +378,9 @@ MainParseArgs(int argc, char **argv) rearg: optind = 1; /* since we're called more than once */ +#if !defined(__linux__) optreset = 1; +#endif #define OPTFLAGS "ABC:D:d:E:ef:I:ij:km:nPpQqrSstV:vXx:" for (;;) { if ((optind < argc) && strcmp(argv[optind], "--") == 0) { @@ -932,6 +940,8 @@ main(int argc, char **argv) } #endif + machine = getenv("MACHINE"); +#if defined(__FreeBSD__) /* * Prior to 7.0, FreeBSD/pc98 kernel used to set the * utsname.machine to "i386", and MACHINE was defined as @@ -941,7 +951,7 @@ main(int argc, char **argv) * to compile new make binary on old FreeBSD/pc98 systems, and * have the MACHINE variable set properly. */ - if ((machine = getenv("MACHINE")) == NULL) { + if (machine == NULL) { int ispc98; size_t len; @@ -951,6 +961,7 @@ main(int argc, char **argv) machine = "pc98"; } } +#endif /* * Get the name of this type of MACHINE from utsname diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index 3e6cb42..fb15937 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -72,6 +72,8 @@ __FBSDID("$FreeBSD$"); * and perform the .USE actions if so. */ +#include + #include "arch.h" #include "config.h" #include "dir.h" diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 134d905..14b1253 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index bed6c7a..f3f5c83 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -93,6 +93,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "arch.h" diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c index 75ced89..53c0cb7 100644 --- a/usr.bin/make/targ.c +++ b/usr.bin/make/targ.c @@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$"); * suffixes, too, but... */ +#include #include #include "dir.h" diff --git a/usr.bin/make/util.c b/usr.bin/make/util.c index 3a27b0a..ce7f4fe 100644 --- a/usr.bin/make/util.c +++ b/usr.bin/make/util.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 534abca..2582e48 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include #include #include diff --git a/usr.bin/makewhatis/makewhatis.c b/usr.bin/makewhatis/makewhatis.c index f2ae370..8d1e15d 100644 --- a/usr.bin/makewhatis/makewhatis.c +++ b/usr.bin/makewhatis/makewhatis.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/usr.bin/mklocale/lex.l b/usr.bin/mklocale/lex.l index 34ff627..02cc610 100644 --- a/usr.bin/mklocale/lex.l +++ b/usr.bin/mklocale/lex.l @@ -45,6 +45,7 @@ static char sccsid[] = "@(#)lex.l 8.1 (Berkeley) 6/6/93"; __FBSDID("$FreeBSD$"); #include +#include #include #include diff --git a/usr.bin/uudecode/uudecode.c b/usr.bin/uudecode/uudecode.c index 093af7d..a087ee0 100644 --- a/usr.bin/uudecode/uudecode.c +++ b/usr.bin/uudecode/uudecode.c @@ -303,7 +303,7 @@ decode2(void) } static int -getline(char *buf, size_t size) +_getline(char *buf, size_t size) { if (fgets(buf, size, infp) != NULL) return (2); @@ -340,7 +340,7 @@ uu_decode(void) /* for each input line */ for (;;) { - switch (getline(buf, sizeof(buf))) { + switch (_getline(buf, sizeof(buf))) { case 0: return (0); case 1: return (1); } @@ -398,7 +398,7 @@ uu_decode(void) } } } - switch (getline(buf, sizeof(buf))) { + switch (_getline(buf, sizeof(buf))) { case 0: return (0); case 1: return (1); default: return (checkend(buf, "end", "no \"end\" line")); @@ -413,7 +413,7 @@ base64_decode(void) unsigned char outbuf[MAXPATHLEN * 4]; for (;;) { - switch (getline(inbuf, sizeof(inbuf))) { + switch (_getline(inbuf, sizeof(inbuf))) { case 0: return (0); case 1: return (1); } diff --git a/usr.bin/xlint/lint1/cgram.y b/usr.bin/xlint/lint1/cgram.y index 8791a2d..14c2578 100644 --- a/usr.bin/xlint/lint1/cgram.y +++ b/usr.bin/xlint/lint1/cgram.y @@ -39,6 +39,7 @@ __RCSID("$NetBSD: cgram.y,v 1.23 2002/01/31 19:36:53 tv Exp $"); #endif __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/usr.bin/xlint/lint1/decl.c b/usr.bin/xlint/lint1/decl.c index 41492cf..0b066b6 100644 --- a/usr.bin/xlint/lint1/decl.c +++ b/usr.bin/xlint/lint1/decl.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include diff --git a/usr.bin/xlint/lint1/emit.c b/usr.bin/xlint/lint1/emit.c index a770e5a..c8dbd2f 100644 --- a/usr.bin/xlint/lint1/emit.c +++ b/usr.bin/xlint/lint1/emit.c @@ -38,6 +38,7 @@ static char rcsid[] = "$NetBSD: emit.c,v 1.2 1995/07/03 21:24:00 cgd Exp $"; #endif #include +#include #include #include #include diff --git a/usr.bin/xlint/lint1/emit1.c b/usr.bin/xlint/lint1/emit1.c index e62549c..e91bef1 100644 --- a/usr.bin/xlint/lint1/emit1.c +++ b/usr.bin/xlint/lint1/emit1.c @@ -39,6 +39,7 @@ __RCSID("$NetBSD: emit1.c,v 1.11 2002/01/31 19:36:54 tv Exp $"); __FBSDID("$FreeBSD$"); #include +#include #include "lint1.h" diff --git a/usr.bin/xlint/lint1/err.c b/usr.bin/xlint/lint1/err.c index 5c56638..d711939 100644 --- a/usr.bin/xlint/lint1/err.c +++ b/usr.bin/xlint/lint1/err.c @@ -38,6 +38,7 @@ __RCSID("$NetBSD: err.c,v 1.17 2002/01/31 19:36:54 tv Exp $"); __FBSDID("$FreeBSD$"); #include +#include #include #include diff --git a/usr.bin/xlint/lint1/func.c b/usr.bin/xlint/lint1/func.c index 68ade02..a71eec0 100644 --- a/usr.bin/xlint/lint1/func.c +++ b/usr.bin/xlint/lint1/func.c @@ -38,6 +38,7 @@ __RCSID("$NetBSD: func.c,v 1.16 2002/01/03 04:25:15 thorpej Exp $"); __FBSDID("$FreeBSD$"); #include +#include #include #include "lint1.h" diff --git a/usr.bin/xlint/lint1/init.c b/usr.bin/xlint/lint1/init.c index cf4cbdd..2a19b18 100644 --- a/usr.bin/xlint/lint1/init.c +++ b/usr.bin/xlint/lint1/init.c @@ -37,6 +37,7 @@ __RCSID("$NetBSD: init.c,v 1.9 2001/09/18 18:15:54 wiz Exp $"); #endif __FBSDID("$FreeBSD$"); +#include #include #include "lint1.h" diff --git a/usr.bin/xlint/lint1/main1.c b/usr.bin/xlint/lint1/main1.c index 29c872f..0adebaa 100644 --- a/usr.bin/xlint/lint1/main1.c +++ b/usr.bin/xlint/lint1/main1.c @@ -38,6 +38,7 @@ __RCSID("$NetBSD: main1.c,v 1.11 2002/01/29 02:43:38 tv Exp $"); __FBSDID("$FreeBSD$"); #include +#include #include #include #include diff --git a/usr.bin/xlint/lint1/mem1.c b/usr.bin/xlint/lint1/mem1.c index 280a63c..1a19113 100644 --- a/usr.bin/xlint/lint1/mem1.c +++ b/usr.bin/xlint/lint1/mem1.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/usr.bin/xlint/lint1/scan.l b/usr.bin/xlint/lint1/scan.l index 05f4ed7..03d8b2b 100644 --- a/usr.bin/xlint/lint1/scan.l +++ b/usr.bin/xlint/lint1/scan.l @@ -39,6 +39,7 @@ __RCSID("$NetBSD: scan.l,v 1.26 2002/01/31 22:30:21 tv Exp $"); #endif __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/usr.bin/xlint/lint1/tree.c b/usr.bin/xlint/lint1/tree.c index 2a65d80..84f5550 100644 --- a/usr.bin/xlint/lint1/tree.c +++ b/usr.bin/xlint/lint1/tree.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index e63e6ab..8dfbb08 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -41,6 +41,8 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#include + #include #include #include diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c index fdd3767..530d42b 100644 --- a/usr.sbin/mtree/compare.c +++ b/usr.sbin/mtree/compare.c @@ -64,6 +64,10 @@ __FBSDID("$FreeBSD$"); #include "mtree.h" #include "extern.h" +#ifdef CROSS_BUILDING +#include +#endif + #define INDENTNAMELEN 8 #define LABEL \ if (!label++) { \ @@ -80,7 +84,9 @@ compare(char *name __unused, NODE *s, FTSENT *p) off_t len; char *cp; const char *tab = ""; +#ifndef STAT_NO_ST_FLAGS char *fflags; +#endif label = 0; switch(s->type) { @@ -181,13 +187,23 @@ typeerr: LABEL; * Catches nano-second differences, but doesn't display them. */ if ((s->flags & F_TIME) && +#ifdef __FreeBSD__ ((s->st_mtimespec.tv_sec != p->fts_statp->st_mtim.tv_sec) || - (s->st_mtimespec.tv_nsec != p->fts_statp->st_mtim.tv_nsec))) { + (s->st_mtimespec.tv_nsec != p->fts_statp->st_mtim.tv_nsec)) +#else + ((s->st_mtimespec.tv_sec != p->fts_statp->st_mtime)) +#endif + ) { LABEL; (void)printf("%smodification time expected %.24s ", tab, ctime(&s->st_mtimespec.tv_sec)); (void)printf("found %.24s", - ctime(&p->fts_statp->st_mtim.tv_sec)); +#ifdef __FreeBSD__ + ctime(&p->fts_statp->st_mtim.tv_sec) +#else + ctime(&p->fts_statp->st_mtime) +#endif + ); if (uflag) { tv[0].tv_sec = s->st_mtimespec.tv_sec; tv[0].tv_usec = s->st_mtimespec.tv_nsec / 1000; @@ -223,6 +239,7 @@ typeerr: LABEL; } } } +#ifndef STAT_NO_ST_FLAGS if ((s->flags & F_FLAGS) && s->st_flags != p->fts_statp->st_flags) { LABEL; fflags = flags_to_string(s->st_flags); @@ -243,6 +260,7 @@ typeerr: LABEL; (void)printf("\n"); tab = "\t"; } +#endif #ifdef MD5 if (s->flags & F_MD5) { char *new_digest, buf[33]; diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c index da72fc6..368d973 100644 --- a/usr.sbin/mtree/create.c +++ b/usr.sbin/mtree/create.c @@ -64,6 +64,10 @@ __FBSDID("$FreeBSD$"); #include "mtree.h" #include "extern.h" +#ifdef CROSS_BUILDING +#include +#endif + #define INDENTNAMELEN 15 #define MAXLINELEN 80 @@ -213,8 +217,13 @@ statf(int indent, FTSENT *p) (intmax_t)p->fts_statp->st_size); if (keys & F_TIME) output(indent, &offset, "time=%ld.%09ld", +#ifdef __FreeBSD__ (long)p->fts_statp->st_mtim.tv_sec, - p->fts_statp->st_mtim.tv_nsec); + p->fts_statp->st_mtim.tv_nsec +#else + (long)p->fts_statp->st_mtime, 0 +#endif + ); if (keys & F_CKSUM && S_ISREG(p->fts_statp->st_mode)) { if ((fd = open(p->fts_accpath, O_RDONLY, 0)) < 0 || crc(fd, &val, &len)) @@ -265,11 +274,13 @@ statf(int indent, FTSENT *p) if (keys & F_SLINK && (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) output(indent, &offset, "link=%s", rlink(p->fts_accpath)); +#ifndef STAT_NO_ST_FLAGS if (keys & F_FLAGS && p->fts_statp->st_flags != flags) { fflags = flags_to_string(p->fts_statp->st_flags); output(indent, &offset, "flags=%s", fflags); free(fflags); } +#endif (void)putchar('\n'); } @@ -335,7 +346,11 @@ statd(FTS *t, FTSENT *parent, uid_t *puid, gid_t *pgid, mode_t *pmode, u_long *p * half word of the flags */ #define FLAGS2IDX(f) ((f & 0xf) | ((f >> 12) & 0xf0)) +#ifndef STAT_NO_ST_FLAGS sflags = p->fts_statp->st_flags; +#else + sflags = 0; +#endif if (FLAGS2IDX(sflags) < MAXFLAGS && ++f[FLAGS2IDX(sflags)] > maxflags) { saveflags = sflags; diff --git a/usr.sbin/mtree/excludes.c b/usr.sbin/mtree/excludes.c index 21a49b0..8c34e77 100644 --- a/usr.sbin/mtree/excludes.c +++ b/usr.sbin/mtree/excludes.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include diff --git a/usr.sbin/mtree/extern.h b/usr.sbin/mtree/extern.h index 4b6fb3c..28e77d0 100644 --- a/usr.sbin/mtree/extern.h +++ b/usr.sbin/mtree/extern.h @@ -31,7 +31,7 @@ */ extern uint32_t crc_total; -#ifdef _FTS_H_ +#if defined(_FTS_H_) || defined(_FTS_H) int compare(char *, NODE *, FTSENT *); #endif int crc(int, uint32_t *, off_t *); diff --git a/usr.sbin/mtree/misc.c b/usr.sbin/mtree/misc.c index 65667d6..eee09d7 100644 --- a/usr.sbin/mtree/misc.c +++ b/usr.sbin/mtree/misc.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include "mtree.h" diff --git a/usr.sbin/mtree/mtree.c b/usr.sbin/mtree/mtree.c index 49e3e6b..dcb7ac5 100644 --- a/usr.sbin/mtree/mtree.c +++ b/usr.sbin/mtree/mtree.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include "mtree.h" diff --git a/usr.sbin/mtree/spec.c b/usr.sbin/mtree/spec.c index c7c6460..4ead116 100644 --- a/usr.sbin/mtree/spec.c +++ b/usr.sbin/mtree/spec.c @@ -41,8 +41,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #include #include #include diff --git a/usr.sbin/mtree/specspec.c b/usr.sbin/mtree/specspec.c index f85882e..9d35e68 100644 --- a/usr.sbin/mtree/specspec.c +++ b/usr.sbin/mtree/specspec.c @@ -27,6 +27,9 @@ #include __FBSDID("$FreeBSD$"); +/* For asprintf */ +#define _GNU_SOURCE + #include #include #include diff --git a/usr.sbin/mtree/verify.c b/usr.sbin/mtree/verify.c index b7c4fd9..6e455ed 100644 --- a/usr.sbin/mtree/verify.c +++ b/usr.sbin/mtree/verify.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include "mtree.h"