Brief description of the attached patch ======================================== This patch allows GNUmake to be built using mingw32 compiler on Win32 or another cross hosted environment (e.g., linux-mingw32). This patch has been tested successfully on: o Win2k, mingw32-3.2: build, run o debian-sarge, debian-sid, mingw32-cross compilers: build Requirements for the patch: o mingw32 o Previous version of GNUmake Using the new mingw32 makefile ============================== * Win32 systems: Assuming that gcc is available via PATH, try: make -f Makefile.mingw32 For debug build, try: make -f Makefile.mingw32 DEBUG=1 * Debian GNU/Linux (sid or sarge): Install the mingw32 cross compiler toolchain. And then: make -f Makefile.mingw32 CROSS=1 or, make -f Makefile.mingw32 CROSS=1 DEBUG=1 * Other Unixish systems (with suitable cross hosted env): Install mingw32 cross compiler toolchain. And then, make -f Makefile.mingw32 CROSS=/full/path/to/cross-compiler Description of each file touched in the patch ============================================== Makefile.mingw32: New GNUmakefile for using the mingw32 compiler toolchain. w32/subproc/misc.c: File deleted due to name clash with an identically named file in the topdir. w32/subproc/miscw32.c: The previous file renamed to miscw32.c. Contact Details =============== Sudhi Herle diff -rH -N -u1 make-3.80/Makefile.mingw32 make-mingw32/Makefile.mingw32 --- make-3.80/Makefile.mingw32 1969-12-31 18:00:00.000000000 -0600 +++ make-mingw32/Makefile.mingw32 2004-09-16 16:36:21.000000000 -0500 @@ -0,0 +1,208 @@ +# +# GNUMakefile to build GNUmake with the mingw32 cross compilers on +# Win32 or a suitably mingw32 cross compiler. +# +# To build natively on win32, try: +# make -f Makefile.mingw32 +# +# To build using a cross compiler try: +# make -f Makefile.mingw32 CROSS=1 +# +# Sudhi Herle +# +# +# Copyright (C) 1988,89,91,92,93,94,95,96,97 Free Software Foundation, Inc. +# This file is part of GNU Make. +# +# GNU Make is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Make is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Make; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + + +ifneq ($(CROSS),) + # Check for debian cross compiler + have_mingw = $(shell if i586-mingw32msvc-gcc -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "yes"; else echo "no"; fi;) + cross_usable = $(shell if $(CROSS) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "yes"; else echo "no"; fi;) + + #junk := $(shell echo "MINGW=$(check_mingw)" 1>&2) + + ifeq ($(have_mingw),yes) + CROSSPATH = i586-mingw32msvc- + else + + ifeq ($(cross_usable),yes) + CROSSPATH = $(CROSS) + else + $(error ** MINGW32 Cross compiler is not available!) + endif + + endif +endif + + +# Tools we need +AR = $(CROSSPATH)ar +CC = $(CROSSPATH)gcc +CXX = $(CROSSPATH)g++ +LD = $(CC) + +CFLAGS = -Wall $(EXTRA_INCS) $(EXTRA_DEFS) +ARFLAGS = rv + +EXTRA_INCS = -I. -Iw32/include -I glob +EXTRA_DEFS = -D_WINDOWS -DWINDOWS32 -DWIN32 -D_CONSOLE -DHAVE_CONFIG_H + +# Search for files in this specific order! +VPATH = w32/compat w32 w32/subproc glob . + + +# XXX Can use better optimization on newer CPUs +ifeq ($(DEBUG),1) + CFLAGS += -g -DDEBUG + STRIP = -g +else + CFLAGS += -O4 -fexpensive-optimizations + STRIP = -Wl,-s +endif + +CXXFLAGS = $(CFLAGS) +LDFLAGS = $(STRIP) + + +MAKEFILE = Makefile.mingw32 + +OUTDIR = . +SUBPROC_MAKEFILE = $(MAKEFILE) + +SUBPROC_OBJS = \ + $(OUTDIR)/miscw32.o \ + $(OUTDIR)/w32err.o \ + $(OUTDIR)/sub_proc.o + +OBJS = \ + $(OUTDIR)/ar.o \ + $(OUTDIR)/arscan.o \ + $(OUTDIR)/commands.o \ + $(OUTDIR)/default.o \ + $(OUTDIR)/dir.o \ + $(OUTDIR)/expand.o \ + $(OUTDIR)/file.o \ + $(OUTDIR)/function.o \ + $(OUTDIR)/getloadavg.o \ + $(OUTDIR)/getopt.o \ + $(OUTDIR)/getopt1.o \ + $(OUTDIR)/implicit.o \ + $(OUTDIR)/hash.o \ + $(OUTDIR)/job.o \ + $(OUTDIR)/main.o \ + $(OUTDIR)/misc.o \ + $(OUTDIR)/read.o \ + $(OUTDIR)/remake.o \ + $(OUTDIR)/remote-stub.o \ + $(OUTDIR)/rule.o \ + $(OUTDIR)/signame.o \ + $(OUTDIR)/variable.o \ + $(OUTDIR)/version.o \ + $(OUTDIR)/vpath.o \ + $(OUTDIR)/glob.o \ + $(OUTDIR)/fnmatch.o \ + $(OUTDIR)/dirent.o \ + $(OUTDIR)/pathstuff.o \ + $(SUBPROC_OBJS) + + + +target = make.exe + + +all: $(target) + + +$(target): $(OBJS) + $(LD) $(LDFLAGS) -o $@ $(OBJS) $(libs) + + +config.h: config.h.W32 + cp $? $@ + + +clean: phony + rm -f $(OBJS) $(libs) $(target) + +realclean: clean + rm -f config.h + +phony: + +depend: $(OBJS:.o=.c) + $(CC) -MM $(CFLAGS) $^ + +$(SUBPROC_OBJS): EXTRA_INCS += -Iw32/subproc + +# --- DEPENDENCIES --- +# XXX These were created by running $(MAKE) depend above + +ar.o: ar.c make.h config.h gettext.h filedef.h hash.h dep.h \ + glob/fnmatch.h +arscan.o: arscan.c make.h config.h gettext.h +commands.o: commands.c make.h config.h gettext.h dep.h filedef.h hash.h \ + variable.h job.h commands.h +default.o: default.c make.h config.h gettext.h rule.h dep.h filedef.h \ + hash.h job.h commands.h variable.h +dir.o: dir.c make.h config.h gettext.h hash.h w32/include/dirent.h \ + w32/include/pathstuff.h glob/glob.h +expand.o: expand.c make.h config.h gettext.h filedef.h hash.h job.h \ + commands.h variable.h rule.h +file.o: file.c make.h config.h gettext.h dep.h filedef.h hash.h job.h \ + commands.h variable.h debug.h +function.o: function.c make.h config.h gettext.h filedef.h hash.h \ + variable.h dep.h job.h commands.h debug.h w32/include/sub_proc.h +getloadavg.o: getloadavg.c config.h +getopt.o: getopt.c config.h gettext.h getopt.h +getopt1.o: getopt1.c config.h getopt.h +implicit.o: implicit.c make.h config.h gettext.h rule.h dep.h filedef.h \ + hash.h debug.h +hash.o: hash.c make.h config.h gettext.h hash.h +job.o: job.c make.h config.h gettext.h job.h debug.h filedef.h hash.h \ + commands.h variable.h w32/include/sub_proc.h w32/include/w32err.h \ + w32/include/pathstuff.h +main.o: main.c make.h config.h gettext.h dep.h filedef.h hash.h \ + variable.h job.h commands.h rule.h debug.h getopt.h \ + w32/include/pathstuff.h +misc.o: misc.c make.h config.h gettext.h dep.h debug.h +read.o: read.c make.h config.h gettext.h glob/glob.h dep.h filedef.h \ + hash.h job.h commands.h variable.h rule.h debug.h +remake.o: remake.c make.h config.h gettext.h filedef.h hash.h job.h \ + commands.h dep.h variable.h debug.h +remote-stub.o: remote-stub.c make.h config.h gettext.h filedef.h hash.h \ + job.h commands.h +rule.o: rule.c make.h config.h gettext.h dep.h filedef.h hash.h job.h \ + commands.h variable.h rule.h +signame.o: signame.c make.h config.h gettext.h +variable.o: variable.c make.h config.h gettext.h dep.h filedef.h hash.h \ + job.h commands.h variable.h rule.h w32/include/pathstuff.h +version.o: version.c config.h +vpath.o: vpath.c make.h config.h gettext.h filedef.h hash.h variable.h \ + w32/include/pathstuff.h +glob.o: glob/glob.c config.h w32/include/dirent.h glob/fnmatch.h \ + glob/glob.h +fnmatch.o: glob/fnmatch.c config.h glob/fnmatch.h +dirent.o: w32/compat/dirent.c w32/include/dirent.h +pathstuff.o: w32/pathstuff.c make.h config.h gettext.h \ + w32/include/pathstuff.h +miscw32.o: w32/subproc/miscw32.c w32/subproc/proc.h +w32err.o: w32/subproc/w32err.c w32/include/w32err.h +sub_proc.o: w32/subproc/sub_proc.c w32/include/sub_proc.h \ + w32/subproc/proc.h w32/include/w32err.h config.h debug.h + diff -rH -N -u1 make-3.80/w32/subproc/misc.c make-mingw32/w32/subproc/misc.c --- make-3.80/w32/subproc/misc.c 1999-12-08 14:14:06.000000000 -0600 +++ make-mingw32/w32/subproc/misc.c 1969-12-31 18:00:00.000000000 -0600 @@ -1,65 +0,0 @@ -#include -#include -#include -#include -#include "proc.h" - - -/* - * Description: Convert a NULL string terminated UNIX environment block to - * an environment block suitable for a windows32 system call - * - * Returns: TRUE= success, FALSE=fail - * - * Notes/Dependencies: the environment block is sorted in case-insensitive - * order, is double-null terminated, and is a char *, not a char ** - */ -int _cdecl compare(const void *a1, const void *a2) -{ - return _stricoll(*((char**)a1),*((char**)a2)); -} -bool_t -arr2envblk(char **arr, char **envblk_out) -{ - char **tmp; - int size_needed; - int arrcnt; - char *ptr; - - arrcnt = 0; - while (arr[arrcnt]) { - arrcnt++; - } - - tmp = (char**) calloc(arrcnt + 1, sizeof(char *)); - if (!tmp) { - return FALSE; - } - - arrcnt = 0; - size_needed = 0; - while (arr[arrcnt]) { - tmp[arrcnt] = arr[arrcnt]; - size_needed += strlen(arr[arrcnt]) + 1; - arrcnt++; - } - size_needed++; - - qsort((void *) tmp, (size_t) arrcnt, sizeof (char*), compare); - - ptr = *envblk_out = calloc(size_needed, 1); - if (!ptr) { - free(tmp); - return FALSE; - } - - arrcnt = 0; - while (tmp[arrcnt]) { - strcpy(ptr, tmp[arrcnt]); - ptr += strlen(tmp[arrcnt]) + 1; - arrcnt++; - } - - free(tmp); - return TRUE; -} diff -rH -N -u1 make-3.80/w32/subproc/miscw32.c make-mingw32/w32/subproc/miscw32.c --- make-3.80/w32/subproc/miscw32.c 1969-12-31 18:00:00.000000000 -0600 +++ make-mingw32/w32/subproc/miscw32.c 2004-09-16 15:11:50.000000000 -0500 @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include "proc.h" + + +/* + * Description: Convert a NULL string terminated UNIX environment block to + * an environment block suitable for a windows32 system call + * + * Returns: TRUE= success, FALSE=fail + * + * Notes/Dependencies: the environment block is sorted in case-insensitive + * order, is double-null terminated, and is a char *, not a char ** + */ +int _cdecl compare(const void *a1, const void *a2) +{ + return _stricoll(*((char**)a1),*((char**)a2)); +} +bool_t +arr2envblk(char **arr, char **envblk_out) +{ + char **tmp; + int size_needed; + int arrcnt; + char *ptr; + + arrcnt = 0; + while (arr[arrcnt]) { + arrcnt++; + } + + tmp = (char**) calloc(arrcnt + 1, sizeof(char *)); + if (!tmp) { + return FALSE; + } + + arrcnt = 0; + size_needed = 0; + while (arr[arrcnt]) { + tmp[arrcnt] = arr[arrcnt]; + size_needed += strlen(arr[arrcnt]) + 1; + arrcnt++; + } + size_needed++; + + qsort((void *) tmp, (size_t) arrcnt, sizeof (char*), compare); + + ptr = *envblk_out = calloc(size_needed, 1); + if (!ptr) { + free(tmp); + return FALSE; + } + + arrcnt = 0; + while (tmp[arrcnt]) { + strcpy(ptr, tmp[arrcnt]); + ptr += strlen(tmp[arrcnt]) + 1; + arrcnt++; + } + + free(tmp); + return TRUE; +}