From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 4 05:42:52 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BFCB8106566B for ; Tue, 4 Mar 2008 05:42:52 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 7F1788FC19 for ; Tue, 4 Mar 2008 05:42:52 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id m245gSnG058318 for ; Mon, 3 Mar 2008 22:42:28 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Mon, 03 Mar 2008 22:42:56 -0700 (MST) Message-Id: <20080303.224256.635730757.imp@bsdimp.com> To: hackers@freebsd.org From: "M. Warner Losh" X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: Subject: Comments on pmake diffs for building on Linux X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Mar 2008 05:42:53 -0000 Greetings, here's a set of diffs that will allow FreeBSD's usr.bin/make to build on Linux. I'm sure they are gross, and I don't plan to commit them (at least not all of them), but I thought I'd post them here to see what people think. I think that the extra config.h includes, the errc -> errx patches and the Makefile.dist patches may be good for the tree. The rest may not meet FreeBSD's source tree policies. Comments? Warner diff -ur pmake.orig/config.h pmake/config.h --- pmake.orig/config.h 2005-02-01 03:50:35.000000000 -0700 +++ pmake/config.h 2008-03-03 22:24:16.745493000 -0700 @@ -108,4 +108,27 @@ # endif #endif +#ifndef TAILQ_HEAD_INITIALIZER +#define TAILQ_HEAD_INITIALIZER(head) { NULL, &(head).tqh_first } +#endif + +#ifndef TAILQ_FOREACH +#define TAILQ_FOREACH(var, head, field) \ + for ((var) = TAILQ_FIRST((head)); \ + (var); \ + (var) = TAILQ_NEXT((var), field)) +#endif + +#ifndef TAILQ_FIRST +#define TAILQ_FIRST(head) ((head)->tqh_first) +#endif + +#ifndef TAILQ_NEXT +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#endif + +#ifndef TAILQ_EMPTY +#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) +#endif + #endif /* config_h_efe0765e */ diff -ur pmake.orig/dir.c pmake/dir.c --- pmake.orig/dir.c 2005-03-23 05:56:15.000000000 -0700 +++ pmake/dir.c 2008-03-03 22:22:36.072235000 -0700 @@ -93,6 +93,7 @@ #include #include "arch.h" +#include "config.h" #include "dir.h" #include "globals.h" #include "GNode.h" Only in pmake: log diff -ur pmake.orig/main.c pmake/main.c --- pmake.orig/main.c 2007-12-18 15:58:14.000000000 -0700 +++ pmake/main.c 2008-03-03 22:25:47.543349000 -0700 @@ -63,7 +63,9 @@ #include #include +#ifdef __FreeBSD__ #include +#endif #include #include #include @@ -366,7 +368,9 @@ rearg: optind = 1; /* since we're called more than once */ +#ifndef linux optreset = 1; +#endif #define OPTFLAGS "ABC:D:E:I:PSV:Xd:ef:ij:km:nqrstvx:" for (;;) { if ((optind < argc) && strcmp(argv[optind], "--") == 0) { @@ -660,11 +664,9 @@ int level = (value == NULL) ? 0 : atoi(value); if (level < 0) { - errc(2, EAGAIN, "Invalid value for recursion level (%d).", - level); + errx(2, "Invalid value for recursion level (%d).", level); } else if (level > MKLVL_MAXVAL) { - errc(2, EAGAIN, "Max recursion level (%d) exceeded.", - MKLVL_MAXVAL); + errx(2, "Max recursion level (%d) exceeded.", MKLVL_MAXVAL); } else { char new_value[32]; sprintf(new_value, "%d", level + 1); @@ -931,6 +933,7 @@ } #endif +#ifdef __FreeBSD__ /* * FreeBSD/pc98 kernel used to set the utsname.machine to * "i386", and MACHINE was defined as "i386", so it could @@ -951,6 +954,7 @@ machine = "pc98"; } } +#endif /* * Get the name of this type of MACHINE from utsname diff -ur pmake.orig/Makefile.dist pmake/Makefile.dist --- pmake.orig/Makefile.dist 2007-12-18 15:58:14.000000000 -0700 +++ pmake/Makefile.dist 2008-03-03 22:27:31.711240000 -0700 @@ -2,7 +2,7 @@ # a simple makefile to help builds on !FreeBSD systems pmake: @echo 'make started.' - cc -D__FBSDID="static const char *id=" -DDEFSHELLNAME=\"sh\" -I. -c *.c + 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.' diff -ur pmake.orig/shell.c pmake/shell.c --- pmake.orig/shell.c 2005-05-24 09:30:03.000000000 -0600 +++ pmake/shell.c 2008-03-03 22:20:08.597377000 -0700 @@ -45,6 +45,7 @@ #include #include +#include "config.h" #include "parse.h" #include "pathnames.h" #include "shell.h"