[DGD] DGD For MSys, mark 2

Jared Maddox absinthdraco at gmail.com
Fri Jan 4 12:12:36 CET 2013


This patch applies the same way as the other does. Please bear in mind
that this patch DEPENDS on the previous one, so if you're applying
this one you must first apply the other. And here's the new-new patch:

diff -rNu dgd-master/README dgd-msys/README
--- dgd-master/README	2013-01-02 03:20:40 -0600
+++ dgd-msys/README	2013-01-04 03:29:15 -0600
@@ -1,7 +1,9 @@
 WARNING:
-  This is a modified and UNTESTED VERSION of DGD. It was altered on Januray
-  2nd, 2013, by Jared Maddox, to add support for the MSys environment. If you
-  want a known-good version, then look to the sources described below.
+  This is a modified and UNTESTED VERSION of DGD. It was altered on January
+  4th, 2013, by Jared Maddox, to add support for the MSys environment.
+  Specifically, it is a further modification of a similar alteration that
+  was done on January 2nd, 2013. If you want a known-good version, then
+  look to the sources described below.

   KNOWN BUGS:
     For some reason, "make clean" didn't clean:
diff -rNu dgd-master/src/Makefile dgd-msys/src/Makefile
--- dgd-master/src/Makefile	2013-01-02 02:56:34 -0600
+++ dgd-msys/src/Makefile	2013-01-04 04:19:59 -0600
@@ -16,22 +16,25 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
+
+# Added by Jared Maddox on Jan 4, 2013.
+# If you're having a bug while compiling this, it's likely my fault.
+# Removed the warning messages from my previous patch.
+#
+include makeheader.win
+
 OS=$(shell uname -s)

-  # Added by Jared Maddox on Jan 2, 2013.
-  # If you're running into a bug while compiling this, it's likely my
-  # fault.
-  #
-  # In addition to the other changes that I've made, I replaced all
-  # instances of "a.out" with $(EXECUTABLE). This localizes the executable
-  # name up here, near the top of the file. I'm not very savy on Make, but
-  # I think it also allows the executable name to be overridden from the
-  # command line, which isn't necessary, but is nice.
-  #
 PLATFORM_DEFINES=
 EXECUTABLE= a.out
-ifeq ($(OS),MINGW32_NT-5.1)
-  HOST=WIN32
+
+  # Thanks to Eli, LRN, and Earnie from the MinGW/MSys list for suggesting
+  # the MSYSTEM variable. It also provides information on e.g. whether the
+  # executable is being compiled FOR MSys or not. At present, that's
+  # ignored, but it might make sense TO SOMEONE ELSE to add some logic to
+  # deal with it.
+ifdef MSYSTEM
+  HOST=MSys
   PLATFORM_DEFINES= -D_WIN32_WINNT=0x501
   EXECUTABLE= a.exe
 endif
@@ -54,6 +57,17 @@
 ifeq ($(OS),SunOS)
   HOST=SOLARIS
 endif
+
+  # I added this in response to some people pointing out that there may be
+  # platforms and sub-platforms on Windows that I'm not taking into
+  # consideration. For example, I can tell you right here and now that I'm
+  # not taking Cygwin into consideration. With this the user can override
+  # any such disregard. Which is not, of course, the same as saying that
+  # this makefile will work correctly.
+ifdef HOST_OVERRIDE
+  HOST=$(HOST_OVERRIDE)
+endif
+
 ifndef HOST
   $(error HOST is undefined)
 endif
@@ -77,10 +91,7 @@
   LIBS+=-lsocket -lnsl
 endif

-  # Basically transfered from my old port. Not certain HOW much of this is
-  # required, but likely more than you'd think.
-  #
-ifeq ($(OS),MINGW32_NT-5.1)
+ifeq ($(HOST),MSys)
  LIBS= -lws2_32 -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
 endif

diff -rNu dgd-master/src/host/Makefile dgd-msys/src/host/Makefile
--- dgd-master/src/host/Makefile	2013-01-02 02:44:53 -0600
+++ dgd-msys/src/host/Makefile	2013-01-04 04:19:25 -0600
@@ -37,15 +37,11 @@
   SYSV_STYLE=1
 endif

-# Added by Jared Maddox, Jan 2, 2013
-# Note: This was basically just copied from my old DGD-for-MSys version,
-# expect untested bugs.
-#
-ifneq ($(HOST),WIN32)
-  # This was just indented from what was already in this file, so it
-  # should be fine.
+  # Modified by Jared Maddox on January 4th, 2013.
+  # I changed ($(HOST),WIN32) to ($(HOST),MSys) to support the changes
+  # that I made in the root makefile.
   #
-
+ifneq ($(HOST),MSys)
   SRC=	local.c dirent.c dload.c time.c connect.c xfloat.c
   SUBOBJ=	local.o dirent.o dload.o time.o crypt.o xfloat.o asn.o
   ifdef SYSV_STYLE
@@ -57,10 +53,6 @@
   endif
   OBJ=	$(SUBOBJ) connect.o
 else
- # This, in comparison, was copied from my previous implementation. Don't
- # depend on it being bug-free.
- #
-
  SRC= local.c dload.c time.c connect.c xfloat.c dosfile.c windgd.c
  OBJ= $(SUBOBJ) connect.o dosfile.o windgd.o
  SUBOBJ= local.o dload.o time.o crypt.o xfloat.o asn.o
@@ -78,12 +70,9 @@
 clean:
 	rm -f dgd sub $(SRC) $(OBJ)

-# Next, we have the copy rules.
-#
-ifneq ($(HOST),WIN32)
-  # These are the versions that already existed here, but wrapped to
-  # control their use.
-  #
+
+ifneq ($(HOST),MSys)
+

 local.c: unix/local.c
 	cp unix/$@ $@
@@ -106,10 +95,9 @@
 connect.c: unix/connect.c
 	cp unix/$@ $@

+
 else
-  # And here we have the forms that I've copied from my old
-  # implementation.
-  #
+

 connect.c: win32/connect.c
 	cp win32/$@ $@
@@ -129,9 +117,8 @@
 windgd.c: win32/windgd.c
 	cp win32/$@ $@

+
 endif
-  # Finally, we go on to what we can count on for both versions.
-  #


 xfloat.c: simfloat.c
diff -rNu dgd-master/src/makeheader.win dgd-msys/src/makeheader.win
--- dgd-master/src/makeheader.win	1969-12-31 18:00:00 -0600
+++ dgd-msys/src/makeheader.win	2013-01-04 04:13:01 -0600
@@ -0,0 +1,74 @@
+#
+# This file is part of DGD, https://github.com/dworkin/dgd
+# Copyright (C) 1993-2010 Dworkin B.V.
+# Copyright (C) 2010-2012 DGD Authors (see the commit log for details)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+# Created by Jared Maddox on Jan 4, 2013.
+# If you're having a bug while compiling DGD, it's likely my fault.
+#
+
+# This jumps through some hoops to figure out if we're on a Windows
+# platform. Among other things, this is important because Windows is
+# almost guaranteed to not have uname, or any of the other utility
+# programs that this (and the various related) makefile needs.
+
+# These two variables define make-function macros. They help to make the
+# following tests much more compact, and to some extent more
+# understandable.
+  # When used in the call make-function, uses it's first argument as a
+  # make-function, using each of the whitespace-separated values in it's
+  # second argument individually as arguments to that "inner"
+  # make-function. This allows a make-function that only accepts one
+  # argument to be adapted to many. Found in the documentation for GNU
+  # make.
+MAP=$(foreach VAR,$(2),$(call $(1),$(VAR)))
+STRIPING_FILTER=$(strip $(filter-out $(1), $(2)))
+  # Filters the value "undefined" from it's input, and then strips out any
+  # whitespace that isn't needed to retain the separation of individual
+  # values. If all values are removed by the filter stage, then the result
+  # will always evaluate as empty.
+STRIP_NOTDEFED=$(call STRIPING_FILTER, undefined, $(1))
+VAR_HAS_VAL=$(if $(call STRIP_NOTDEFED, $(flavor $(1))), $(call
STRIPING_FILTER, $(2), $(1)))
+
+  # If you want this makefile to support a particular build platform on
+  # Windows, then you should place an informative variable name in the
+  # WIN_SUBPLATFORMS variable. Note that these are inserted as their text
+  # forms, instead of treated as variable references. We don't want these
+  # to be expanded, since we're using the actual name to test for whether
+  # that specific variable is defined or not.
+WIN_PLATFORMS=Windows_NT
+WIN_SUBPLATFORMS=MSYSTEM HOST_OVERRIDE
+
+  # If OS is defined AND equals an entry in WIN_PLATFORMS, then run the
+  # enclosed tests.
+ifneq ($(call VAR_HAS_VAL, $(OS), $(WIN_PLATFORMS)),'')
+
+    # Check each of the variables NAMED in WIN_SUBPLATFORMS for it's
+    # flavor. If the flavor is 'undefined', then filter-out that flavor.
+    # Finally, strip all whitespace to the bare minimium, and test the
+    # result against an empty string. If there's nothing left in the
+    # string (meaning that all of the flavors had been filtered out) then
+    # print appropriate messages & error out.
+  ifeq ($(call STRIP_NOTDEFED, $(call MAP,flavor,$(WIN_SUBPLATFORMS))),)
+
+    $(warning DGD's makefile requires a nix-like environment.)
+    $(warning On Windows, only MSys is currently recognized.)
+    $(warning To force compilation, set HOST_OVERRIDE to your host
environment.)
+    $(warning WARNING! Forcing compilation may damage your computer!)
+    $(error WARNING! Be very certain of the risks before forcing compilation!)
+  endif
+endif



More information about the DGD mailing list