<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
The makefile subject comes up all the time, especially after Bob pushes
out a new version.<br>
<br>
I've attached the makefile I use to build for Linux (Slackware, various
ports), Solaris-10 and OS/X.<br>
<br>
It is far from ideal, but there are a few points interest. I'll quote
the relevent snipet for discussion:<br>
<blockquote><tt>ifeq ($(WIN32),)</tt><br>
  <tt>  #Unix Environments</tt><br>
  <tt>  ifneq (,$(findstring solaris,$(OSTYPE)))</tt><br>
  <tt>    OS_CCDEFS = -lm -lsocket -lnsl -lrt -lpthread -D_GNU_SOURCE</tt><br>
  <tt>  else</tt><br>
  <tt>    ifneq (,$(findstring darwin,$(OSTYPE)))</tt><br>
  <tt>      OS_CCDEFS = -D_GNU_SOURCE</tt><br>
  <tt>    else</tt><br>
  <tt>      OS_CCDEFS = -lrt -lm -D_GNU_SOURCE</tt><br>
  <tt>    endif</tt><br>
  <tt>  endif</tt><br>
  <tt>  CC = gcc -std=c99 -U__STRICT_ANSI__ -g $(OS_CCDEFS) -I .</tt><br>
  <tt>  ifeq ($(USE_NETWORK),)</tt><br>
  <tt>  else</tt><br>
  <tt>    NETWORK_OPT = -DUSE_NETWORK -isystem /usr/local/include
/usr/local/lib/libpcap.a</tt><br>
  <tt>  endif</tt><br>
  <tt>else</tt><br>
  <tt>  #Win32 Environments</tt><br>
  <tt>  LDFLAGS = -lm -lwsock32 -lwinmm</tt><br>
  <tt>  CC = gcc -std=c99 -U__STRICT_ANSI__ -O0 -I.</tt><br>
  <tt>  EXE = .exe</tt><br>
  <tt>  ifeq ($(USE_NETWORK),)</tt><br>
  <tt>  else</tt><br>
  <tt>    NETWORK_OPT = -DUSE_NETWORK -lwpcap -lpacket</tt><br>
  <tt>  endif</tt><br>
  <tt>endif<br>
  <br>
  </tt></blockquote>
<ol>
  <li>OSTYPE isn't universally set, it may be a bash-ism. It doesn't
get set by the default Bourne shell on Solaris, for example. This
doesn't bother me much, I always run bash if available anyway. There
was at least one fellow on the simh-dev list who compiles simh for VMS
and thinks running bash on VMS is an abomination.<br>
  </li>
  <li>OSTYPE isn't exported by bash by default. Many people export it
in their .profile, you can export it manually, or you can set it on the
make command line.</li>
  <li>bash on both my OS/X and Solaris systems include version numbers
in the OSTYPE, thus the findstring in the above conditionals.</li>
  <li>Solaris 10 ships with no fewer than three versions of make. Only
gmake (GNU make) works for this makefile. The other two spit out
cryptic errors I'm insuficiently motivated to decode.</li>
  <li>The above snipit shows my linux bias - the default for other os
not detected is the linux option. I should detect linux and the not
found branch should have no libraries specified, like the default in
the stock makefile.</li>
  <li>I don't think I did anything to break the windows build, but I
don't know that for a fact.</li>
  <li>Note that bash on OS/X sets OSTYPE to darwin, not macos.</li>
  <li>I really want to build for one of the BSDs.  I think I've got
somthing arround here that should run one of the BSDs. I think one of
the solaris versions of make that doesn't work (see 4 above) is a BSD
make. </li>
  <li>I don't build with the optional networking support, the emulator
I am most interested in (id32) does not use it.<br>
  </li>
</ol>
<br>
</body>
</html>