1#
2# This GNU make makefile has been tested on:
3#   Linux (x86 & Sparc)
4#   OS X
5#   Solaris (x86 & Sparc)
6#   OpenBSD
7#   NetBSD
8#   FreeBSD
9#   Windows (MinGW & cygwin)
10#   Linux x86 targeting Android (using agcc script)
11#
12# Android targeted builds should invoke GNU make with GCC=agcc on
13# the command line.
14#
15# In general, the logic below will detect and build with the available
16# features which the host build environment provides.
17#
18# Dynamic loading of libpcap is the default behavior if pcap.h is
19# available at build time.  Direct calls to libpcap can be enabled
20# if GNU make is invoked with USE_NETWORK=1 on the command line.
21#
22# The default build will build compiler optimized binaries.
23# If debugging is desired, then GNU make can be invoked with
24# DEBUG=1 on the command line.
25#
26# For linting (or other code analyzers) make may be invoked similar to:
27#
28#   make GCC=cppcheck CC_OUTSPEC= LDFLAGS= CFLAGS_G="--enable=all --template=gcc" CC_STD=--std=c99
29#
30# CC Command (and platform available options).  (Poor man's autoconf)
31#
32# building the pdp11, or any vax simulator could use networking support
33# No Asynch I/O support for now.
34NOASYNCH = 1
35BUILD_SINGLE := $(MAKECMDGOALS) $(BLANK_PREFIX)
36ifneq (,$(or $(findstring pdp11,$(MAKECMDGOALS)),$(findstring vax,$(MAKECMDGOALS)),$(findstring all,$(MAKECMDGOALS))))
37  NETWORK_USEFUL = true
38  ifneq (,$(findstring all,$(MAKECMDGOALS))$(word 2,$(MAKECMDGOALS)))
39    BUILD_MULTIPLE = s
40  endif
41else
42  ifeq ($(MAKECMDGOALS),)
43    # default target is all
44    NETWORK_USEFUL = true
45    BUILD_MULTIPLE = s
46    BUILD_SINGLE := all $(BLANK_PREFIX)
47  endif
48endif
49ifeq ($(WIN32),)  #*nix Environments (&& cygwin)
50  ifeq ($(GCC),)
51    GCC = gcc
52  endif
53  OSTYPE = $(shell uname)
54  # OSNAME is used in messages to indicate the source of libpcap components
55  OSNAME = $(OSTYPE)
56  ifeq (SunOS,$(OSTYPE))
57    TEST = /bin/test
58  else
59    TEST = test
60  endif
61  ifeq (CYGWIN,$(findstring CYGWIN,$(OSTYPE))) # uname returns CYGWIN_NT-n.n-ver
62    OSTYPE = cygwin
63    OSNAME = windows-build
64  endif
65  GCC_VERSION = $(shell $(GCC) -v /dev/null 2>&1 | grep 'gcc version' | awk '{ print $$3 }')
66  LTO_EXCLUDE_VERSIONS =
67  PCAPLIB = pcap
68  ifeq (agcc,$(findstring agcc,$(GCC))) # Android target build?
69    OS_CCDEFS = -D_GNU_SOURCE
70    ifeq (,$(NOASYNCH))
71      OS_CCDEFS += -DSIM_ASYNCH_IO
72    endif
73    OS_LDFLAGS = -lm
74  else # Non-Android Builds
75    INCPATH:=/usr/include
76    LIBPATH:=/usr/lib
77    OS_CCDEFS = -D_GNU_SOURCE
78    GCC_OPTIMIZERS_CMD = $(GCC) -v --help 2>&1
79    GCC_WARNINGS_CMD = $(GCC) -v --help 2>&1
80    ifeq (Darwin,$(OSTYPE))
81      OSNAME = OSX
82      LIBEXT = dylib
83      # OSX's XCode gcc doesn't support LTO, but gcc built to explicitly enable it will work
84      ifeq (,$(shell $(GCC) -v /dev/null 2>&1 | grep '\-\-enable-lto'))
85        LTO_EXCLUDE_VERSIONS += $(GCC_VERSION)
86      endif
87    else
88      ifeq (Linux,$(OSTYPE))
89        LIBPATH := $(sort $(foreach lib,$(shell /sbin/ldconfig -p | grep ' => /' | sed 's/^.* => //'),$(dir $(lib))))
90        LIBEXT = so
91      else
92        ifeq (SunOS,$(OSTYPE))
93          OSNAME = Solaris
94          LIBPATH := $(shell crle | grep 'Default Library Path' | awk '{ print $$5 }' | sed 's/:/ /g')
95          LIBEXT = so
96          OS_LDFLAGS += -lsocket -lnsl
97          ifeq (incsfw,$(shell if $(TEST) -d /opt/sfw/include; then echo incsfw; fi))
98            INCPATH += /opt/sfw/include
99            OS_CCDEFS += -I/opt/sfw/include
100          endif
101          ifeq (libsfw,$(shell if $(TEST) -d /opt/sfw/lib; then echo libsfw; fi))
102            LIBPATH += /opt/sfw/lib
103            OS_LDFLAGS += -L/opt/sfw/lib -R/opt/sfw/lib
104          endif
105        else
106          ifeq (cygwin,$(OSTYPE))
107            # use 0readme_ethernet.txt documented Windows pcap build components
108            INCPATH += ../windows-build/winpcap/WpdPack/include
109            LIBPATH += ../windows-build/winpcap/WpdPack/lib
110            PCAPLIB = wpcap
111            LIBEXT = a
112          else
113############            LDSEARCH :=$(shell ldconfig -r | grep 'search directories' | awk '{print $$3}' | sed 's/:/ /g')
114            ifneq (,$(LDSEARCH))
115              LIBPATH := $(LDSEARCH)
116            endif
117            ifeq (usrpkglib,$(shell if $(TEST) -d /usr/pkg/lib; then echo usrpkglib; fi))
118              LIBPATH += /usr/pkg/lib
119              OS_LDFLAGS += -L/usr/pkg/lib -R/usr/pkg/lib
120            endif
121            ifneq (,$(findstring NetBSD,$(OSTYPE))$(findstring FreeBSD,$(OSTYPE)))
122              LIBEXT = so
123            else
124              LIBEXT = a
125            endif
126          endif
127        endif
128      endif
129    endif
130  endif
131  $(info lib paths are: $(LIBPATH))
132  find_lib = $(strip $(firstword $(foreach dir,$(strip $(LIBPATH)),$(wildcard $(dir)/lib$(1).$(LIBEXT)))))
133  find_include = $(strip $(firstword $(foreach dir,$(strip $(INCPATH)),$(wildcard $(dir)/$(1).h))))
134  ifneq (,$(call find_lib,m))
135    OS_LDFLAGS += -lm
136    $(info using libm: $(call find_lib,m))
137  endif
138  ifneq (,$(call find_lib,rt))
139    OS_LDFLAGS += -lrt
140    $(info using librt: $(call find_lib,rt))
141  endif
142  ifneq (,$(call find_lib,pthread))
143    ifneq (,$(call find_include,pthread))
144      OS_CCDEFS += -DUSE_READER_THREAD
145      ifeq (,$(NOASYNCH))
146        OS_CCDEFS += -DSIM_ASYNCH_IO
147      endif
148      OS_LDFLAGS += -lpthread
149      $(info using libpthread: $(call find_lib,pthread) $(call find_include,pthread))
150    endif
151  endif
152  ifneq (,$(call find_include,dlfcn))
153    ifneq (,$(call find_lib,dl))
154      OS_CCDEFS += -DHAVE_DLOPEN=$(LIBEXT)
155      OS_LDFLAGS += -ldl
156      $(info using libdl: $(call find_lib,dl) $(call find_include,dlfcn))
157    else
158      ifeq (BSD,$(findstring BSD,$(OSTYPE)))
159        OS_CCDEFS += -DHAVE_DLOPEN=so
160        $(info using libdl: $(call find_include,dlfcn))
161      endif
162    endif
163  endif
164  ifneq (,$(NETWORK_USEFUL))
165    ifneq (,$(call find_include,pcap))
166      ifneq (,$(call find_lib,$(PCAPLIB)))
167        ifneq ($(USE_NETWORK),) # Network support specified on the GNU make command line
168          NETWORK_CCDEFS = -DUSE_NETWORK -I$(dir $(call find_include,pcap))
169          ifeq (cygwin,$(OSTYPE))
170            # cygwin has no ldconfig so explicitly specify pcap object library
171            NETWORK_LDFLAGS = -L$(dir $(call find_lib,$(PCAPLIB))) -Wl,-R,$(dir $(call find_lib,$(PCAPLIB))) -l$(PCAPLIB)
172          else
173            NETWORK_LDFLAGS = -l$(PCAPLIB)
174          endif
175          $(info using libpcap: $(call find_lib,$(PCAPLIB)) $(call find_include,pcap))
176          NETWORK_FEATURES = - static networking support using $(OSNAME) provided libpcap components
177        else # default build uses dynamic libpcap
178          NETWORK_CCDEFS = -DUSE_SHARED -I$(dir $(call find_include,pcap))
179          $(info using libpcap: $(call find_include,pcap))
180          NETWORK_FEATURES = - dynamic networking support using $(OSNAME) provided libpcap components
181        endif
182      else
183        NETWORK_CCDEFS = -DUSE_SHARED -I$(dir $(call find_include,pcap))
184        NETWORK_FEATURES = - dynamic networking support using $(OSNAME) provided libpcap components
185        $(info using libpcap: $(call find_include,pcap))
186      endif
187    else
188      # Look for package built from tcpdump.org sources with default install target (or cygwin winpcap)
189      LIBPATH += /usr/local/lib
190      INCPATH += /usr/local/include
191      LIBEXTSAVE := $(LIBEXT)
192      LIBEXT = a
193      ifneq (,$(call find_lib,$(PCAPLIB)))
194        ifneq (,$(call find_include,pcap))
195          $(info using libpcap: $(call find_lib,$(PCAPLIB)) $(call find_include,pcap))
196          ifeq (cygwin,$(OSTYPE))
197            NETWORK_CCDEFS = -DUSE_NETWORK -I$(dir $(call find_include,pcap))
198            NETWORK_LDFLAGS = -L$(dir $(call find_lib,$(PCAPLIB))) -Wl,-R,$(dir $(call find_lib,$(PCAPLIB))) -l$(PCAPLIB)
199            NETWORK_FEATURES = - static networking support using libpcap components located in the cygwin directories
200          else
201            NETWORK_CCDEFS := -DUSE_NETWORK -isystem $(dir $(call find_include,pcap)) $(call find_lib,$(PCAPLIB))
202            NETWORK_FEATURES = - networking support using libpcap components from www.tcpdump.org
203            $(info *** Warning ***)
204            $(info *** Warning *** $(BUILD_SINGLE)Simulator$(BUILD_MULTIPLE) being built with networking support using)
205            $(info *** Warning *** libpcap components from www.tcpdump.org.)
206            $(info *** Warning *** Some users have had problems using the www.tcpdump.org libpcap)
207            $(info *** Warning *** components for simh networking.  For best results, with)
208            $(info *** Warning *** simh networking, it is recommended that you install the)
209            $(info *** Warning *** libpcap-dev package from your $(OSTYPE) distribution)
210            $(info *** Warning ***)
211          endif
212        else
213          $(error using libpcap: $(call find_lib,$(PCAPLIB)) missing pcap.h)
214        endif
215      endif
216      LIBEXT = $(LIBEXTSAVE)
217    endif
218    ifneq (,$(findstring USE_NETWORK,$(NETWORK_CCDEFS))$(findstring USE_SHARED,$(NETWORK_CCDEFS)))
219	  # Given we have libpcap components, consider other network connections as well
220      ifneq (,$(call find_lib,vdeplug))
221        # libvdeplug requires the use of the OS provided libpcap
222		ifeq (,$(findstring usr/local,$(NETWORK_CCDEFS)))
223          ifneq (,$(call find_include,libvdeplug))
224            # Provide support for vde networking
225            NETWORK_CCDEFS += -DUSE_VDE_NETWORK
226            NETWORK_LDFLAGS += -lvdeplug
227            $(info using libvdeplug: $(call find_lib,vdeplug) $(call find_include,libvdeplug))
228          endif
229        endif
230      endif
231      ifneq (,$(call find_include,linux/if_tun))
232        # Provide support for Tap networking on Linux
233        NETWORK_CCDEFS += -DUSE_TAP_NETWORK
234      endif
235      ifeq (bsdtuntap,$(shell if $(TEST) -e /usr/include/net/if_tun.h -o -e /Library/Extensions/tap.kext; then echo bsdtuntap; fi))
236        # Provide support for Tap networking on BSD platforms (including OS X)
237        NETWORK_CCDEFS += -DUSE_TAP_NETWORK -DUSE_BSDTUNTAP
238      endif
239    else
240      NETWORK_FEATURES = - WITHOUT networking support
241      $(info *** Warning ***)
242      $(info *** Warning *** $(BUILD_SINGLE)Simulator$(BUILD_MULTIPLE) are being built WITHOUT networking support)
243      $(info *** Warning ***)
244      $(info *** Warning *** To build simulator(s) with networking support you should read)
245      $(info *** Warning *** 0readme_ethernet.txt and follow the instructions regarding the)
246      $(info *** Warning *** needed libpcap components for your $(OSTYPE) platform)
247      $(info *** Warning ***)
248    endif
249    NETWORK_OPT = $(NETWORK_CCDEFS)
250  endif
251  ifneq (binexists,$(shell if $(TEST) -e BIN; then echo binexists; fi))
252    MKDIRBIN = if $(TEST) ! -e BIN; then mkdir BIN; fi
253  endif
254else
255  #Win32 Environments (via MinGW32)
256  GCC = gcc
257  GCC_Path := $(dir $(shell where gcc.exe))
258  GCC_VERSION = $(word 3,$(shell $(GCC) --version))
259  LTO_EXCLUDE_VERSIONS = 4.5.2
260  ifeq (pthreads,$(shell if exist ..\windows-build\pthreads\Pre-built.2\include\pthread.h echo pthreads))
261    PTHREADS_CCDEFS = -DUSE_READER_THREAD -DPTW32_STATIC_LIB -I../windows-build/pthreads/Pre-built.2/include
262    ifeq (,$(NOASYNCH))
263      PTHREADS_CCDEFS += -DSIM_ASYNCH_IO
264    endif
265    PTHREADS_LDFLAGS = -lpthreadGC2 -L..\windows-build\pthreads\Pre-built.2\lib
266  else
267    ifeq (pthreads,$(shell if exist $(dir $(GCC_Path))..\include\pthread.h echo pthreads))
268      PTHREADS_CCDEFS = -DUSE_READER_THREAD
269      ifeq (,$(NOASYNCH))
270        PTHREADS_CCDEFS += -DSIM_ASYNCH_IO
271      endif
272      PTHREADS_LDFLAGS = -lpthread
273    endif
274  endif
275  ifeq (pcap,$(shell if exist ..\windows-build\winpcap\Wpdpack\include\pcap.h echo pcap))
276    PCAP_CCDEFS = -I../windows-build/winpcap/Wpdpack/include -I$(GCC_Path)..\include\ddk -DUSE_SHARED
277    NETWORK_LDFLAGS =
278    NETWORK_OPT = -DUSE_SHARED
279    NETWORK_FEATURES = - dynamic networking support using windows-build provided libpcap components
280  else
281    ifeq (pcap,$(shell if exist $(dir $(GCC_Path))..\include\pcap.h echo pcap))
282      PCAP_CCDEFS = -DUSE_SHARED -I$(GCC_Path)..\include\ddk
283      NETWORK_LDFLAGS =
284      NETWORK_OPT = -DUSE_SHARED
285      NETWORK_FEATURES = - dynamic networking support using libpcap components found in the MinGW directories
286    endif
287  endif
288  OS_CCDEFS =  -fms-extensions $(PTHREADS_CCDEFS) $(PCAP_CCDEFS)
289  OS_LDFLAGS = -lm -lwsock32 -lwinmm $(PTHREADS_LDFLAGS)
290  EXE = .exe
291  ifneq (binexists,$(shell if exist BIN echo binexists))
292    MKDIRBIN = if not exist BIN mkdir BIN
293  endif
294  ifneq ($(USE_NETWORK),)
295    NETWORK_OPT = -DUSE_SHARED
296  endif
297endif
298ifneq ($(DEBUG),)
299  CFLAGS_G = -g -ggdb -g3
300  CFLAGS_O = -O0
301  BUILD_FEATURES = - debugging support
302else
303  CFLAGS_O ?= -O2
304  LDFLAGS_O =
305  GCC_MAJOR_VERSION = $(firstword $(subst  ., ,$(GCC_VERSION)))
306  ifneq (3,$(GCC_MAJOR_VERSION))
307    ifeq (,$(GCC_OPTIMIZERS_CMD))
308      GCC_OPTIMIZERS_CMD = $(GCC) --help=optimizers
309    endif
310    GCC_OPTIMIZERS = $(shell $(GCC_OPTIMIZERS_CMD))
311  endif
312#  ifneq (,$(findstring $(GCC_VERSION),$(LTO_EXCLUDE_VERSIONS)))
313#    NO_LTO = 1
314#  endif
315  ifneq (,$(findstring -finline-functions,$(GCC_OPTIMIZERS)))
316    CFLAGS_O += -finline-functions
317  endif
318  ifneq (,$(findstring -fgcse-after-reload,$(GCC_OPTIMIZERS)))
319    CFLAGS_O += -fgcse-after-reload
320  endif
321  ifneq (,$(findstring -fpredictive-commoning,$(GCC_OPTIMIZERS)))
322    CFLAGS_O += -fpredictive-commoning
323  endif
324  ifneq (,$(findstring -fipa-cp-clone,$(GCC_OPTIMIZERS)))
325    CFLAGS_O += -fipa-cp-clone
326  endif
327  ifneq (,$(findstring -funsafe-loop-optimizations,$(GCC_OPTIMIZERS)))
328    CFLAGS_O += -fno-unsafe-loop-optimizations
329  endif
330  ifneq (,$(findstring -fstrict-overflow,$(GCC_OPTIMIZERS)))
331    CFLAGS_O += -fno-strict-overflow
332  endif
333#  ifeq (,$(NO_LTO))
334#    ifneq (,$(findstring -flto,$(GCC_OPTIMIZERS)))
335#      ifneq (,$(findstring -fwhole-program,$(GCC_OPTIMIZERS)))
336#        CFLAGS_O += -flto -fwhole-program
337#        LDFLAGS_O += -flto -fwhole-program
338#      endif
339#    endif
340#  endif
341  BUILD_FEATURES = - compiler optimizations and no debugging support
342endif
343ifneq (3,$(GCC_MAJOR_VERSION))
344  ifeq (,$(GCC_WARNINGS_CMD))
345    GCC_WARNINGS_CMD = $(GCC) --help=warnings
346  endif
347  ifneq (,$(findstring -Wunused-result,$(shell $(GCC_WARNINGS_CMD))))
348    CFLAGS_O += -Wno-unused-result
349  endif
350endif
351ifneq (clean,$(MAKECMDGOALS))
352  BUILD_FEATURES := $(BUILD_FEATURES). GCC Version: $(GCC_VERSION)
353  $(info ***)
354  $(info *** $(BUILD_SINGLE)Simulator$(BUILD_MULTIPLE) being built with:)
355  $(info *** $(BUILD_FEATURES).)
356  ifneq (,$(NETWORK_FEATURES))
357    $(info *** $(NETWORK_FEATURES).)
358  endif
359  $(info ***)
360endif
361ifneq ($(DONT_USE_READER_THREAD),)
362  NETWORK_OPT += -DDONT_USE_READER_THREAD
363endif
364
365CC_STD = -std=c99
366CC_OUTSPEC = -o $@
367CC = $(GCC) $(CC_STD) -U__STRICT_ANSI__ $(CFLAGS_G) $(CFLAGS_O) -I . $(OS_CCDEFS) $(ROMS_OPT)
368LDFLAGS = $(OS_LDFLAGS) $(NETWORK_LDFLAGS) $(LDFLAGS_O)
369
370#
371# Common Libraries
372#
373BIN = BIN/
374SIM = scp.c sim_console.c sim_fio.c sim_timer.c sim_sock.c \
375	sim_tmxr.c sim_ether.c sim_tape.c
376
377
378#
379# Emulator source files and compile time options
380#
381PDP1D = PDP1
382PDP1 = ${PDP1D}/pdp1_lp.c ${PDP1D}/pdp1_cpu.c ${PDP1D}/pdp1_stddev.c \
383	${PDP1D}/pdp1_sys.c ${PDP1D}/pdp1_dt.c ${PDP1D}/pdp1_drm.c \
384	${PDP1D}/pdp1_clk.c ${PDP1D}/pdp1_dcs.c
385PDP1_OPT = -I ${PDP1D}
386
387
388NOVAD = NOVA
389NOVA = ${NOVAD}/nova_sys.c ${NOVAD}/nova_cpu.c ${NOVAD}/nova_dkp.c \
390	${NOVAD}/nova_dsk.c ${NOVAD}/nova_lp.c ${NOVAD}/nova_mta.c \
391	${NOVAD}/nova_plt.c ${NOVAD}/nova_pt.c ${NOVAD}/nova_clk.c \
392	${NOVAD}/nova_tt.c ${NOVAD}/nova_tt1.c ${NOVAD}/nova_qty.c
393NOVA_OPT = -I ${NOVAD}
394
395
396ECLIPSE = ${NOVAD}/eclipse_cpu.c ${NOVAD}/eclipse_tt.c ${NOVAD}/nova_sys.c \
397	${NOVAD}/nova_dkp.c ${NOVAD}/nova_dsk.c ${NOVAD}/nova_lp.c \
398	${NOVAD}/nova_mta.c ${NOVAD}/nova_plt.c ${NOVAD}/nova_pt.c \
399	${NOVAD}/nova_clk.c ${NOVAD}/nova_tt1.c ${NOVAD}/nova_qty.c
400ECLIPSE_OPT = -I ${NOVAD} -DECLIPSE
401
402
403PDP18BD = PDP18B
404PDP18B = ${PDP18BD}/pdp18b_dt.c ${PDP18BD}/pdp18b_drm.c ${PDP18BD}/pdp18b_cpu.c \
405	${PDP18BD}/pdp18b_lp.c ${PDP18BD}/pdp18b_mt.c ${PDP18BD}/pdp18b_rf.c \
406	${PDP18BD}/pdp18b_rp.c ${PDP18BD}/pdp18b_stddev.c ${PDP18BD}/pdp18b_sys.c \
407	${PDP18BD}/pdp18b_rb.c ${PDP18BD}/pdp18b_tt1.c ${PDP18BD}/pdp18b_fpp.c
408PDP4_OPT = -DPDP4 -I ${PDP18BD}
409PDP7_OPT = -DPDP7 -I ${PDP18BD}
410PDP9_OPT = -DPDP9 -I ${PDP18BD}
411PDP15_OPT = -DPDP15 -I ${PDP18BD}
412
413
414PDP11D = PDP11
415PDP11 = ${PDP11D}/pdp11_fp.c ${PDP11D}/pdp11_cpu.c ${PDP11D}/pdp11_dz.c \
416	${PDP11D}/pdp11_cis.c ${PDP11D}/pdp11_lp.c ${PDP11D}/pdp11_rk.c \
417	${PDP11D}/pdp11_rl.c ${PDP11D}/pdp11_rp.c ${PDP11D}/pdp11_rx.c \
418	${PDP11D}/pdp11_stddev.c ${PDP11D}/pdp11_sys.c ${PDP11D}/pdp11_tc.c \
419	${PDP11D}/pdp11_tm.c ${PDP11D}/pdp11_ts.c ${PDP11D}/pdp11_io.c \
420	${PDP11D}/pdp11_rq.c ${PDP11D}/pdp11_tq.c ${PDP11D}/pdp11_pclk.c \
421	${PDP11D}/pdp11_ry.c ${PDP11D}/pdp11_pt.c ${PDP11D}/pdp11_hk.c \
422	${PDP11D}/pdp11_xq.c ${PDP11D}/pdp11_xu.c ${PDP11D}/pdp11_vh.c \
423	${PDP11D}/pdp11_rh.c ${PDP11D}/pdp11_tu.c ${PDP11D}/pdp11_cpumod.c \
424	${PDP11D}/pdp11_cr.c ${PDP11D}/pdp11_rf.c ${PDP11D}/pdp11_dl.c \
425	${PDP11D}/pdp11_ta.c ${PDP11D}/pdp11_rc.c ${PDP11D}/pdp11_kg.c \
426	${PDP11D}/pdp11_ke.c ${PDP11D}/pdp11_dc.c ${PDP11D}/pdp11_io_lib.c
427PDP11_OPT = -DVM_PDP11 -I ${PDP11D} ${NETWORK_OPT}
428
429
430VAXD = VAX
431VAX = ${VAXD}/vax_cpu.c ${VAXD}/vax_cpu1.c ${VAXD}/vax_fpa.c ${VAXD}/vax_io.c \
432	${VAXD}/vax_cis.c ${VAXD}/vax_octa.c  ${VAXD}/vax_cmode.c \
433	${VAXD}/vax_mmu.c ${VAXD}/vax_stddev.c ${VAXD}/vax_sysdev.c \
434	${VAXD}/vax_sys.c  ${VAXD}/vax_syscm.c ${VAXD}/vax_syslist.c \
435	${PDP11D}/pdp11_rl.c ${PDP11D}/pdp11_rq.c ${PDP11D}/pdp11_ts.c \
436	${PDP11D}/pdp11_dz.c ${PDP11D}/pdp11_lp.c ${PDP11D}/pdp11_tq.c \
437	${PDP11D}/pdp11_xq.c ${PDP11D}/pdp11_ry.c ${PDP11D}/pdp11_vh.c \
438	${PDP11D}/pdp11_cr.c ${PDP11D}/pdp11_io_lib.c
439VAX_OPT = -DVM_VAX -DUSE_INT64 -DUSE_ADDR64 -I ${VAXD} -I ${PDP11D} ${NETWORK_OPT}
440
441
442VAX780 = ${VAXD}/vax_cpu.c ${VAXD}/vax_cpu1.c ${VAXD}/vax_fpa.c \
443	${VAXD}/vax_cis.c ${VAXD}/vax_octa.c  ${VAXD}/vax_cmode.c \
444	${VAXD}/vax_mmu.c ${VAXD}/vax_sys.c  ${VAXD}/vax_syscm.c \
445	${VAXD}/vax780_stddev.c ${VAXD}/vax780_sbi.c \
446	${VAXD}/vax780_mem.c ${VAXD}/vax780_uba.c ${VAXD}/vax780_mba.c \
447	${VAXD}/vax780_fload.c ${VAXD}/vax780_syslist.c \
448	${PDP11D}/pdp11_rl.c ${PDP11D}/pdp11_rq.c ${PDP11D}/pdp11_ts.c \
449	${PDP11D}/pdp11_dz.c ${PDP11D}/pdp11_lp.c ${PDP11D}/pdp11_tq.c \
450	${PDP11D}/pdp11_xu.c ${PDP11D}/pdp11_ry.c ${PDP11D}/pdp11_cr.c \
451	${PDP11D}/pdp11_rp.c ${PDP11D}/pdp11_tu.c ${PDP11D}/pdp11_hk.c \
452	${PDP11D}/pdp11_io_lib.c
453VAX780_OPT = -DVM_VAX -DVAX_780 -DUSE_INT64 -DUSE_ADDR64 -I VAX -I ${PDP11D} ${NETWORK_OPT}
454
455
456PDP10D = PDP10
457PDP10 = ${PDP10D}/pdp10_fe.c ${PDP11D}/pdp11_dz.c ${PDP10D}/pdp10_cpu.c \
458	${PDP10D}/pdp10_ksio.c ${PDP10D}/pdp10_lp20.c ${PDP10D}/pdp10_mdfp.c \
459	${PDP10D}/pdp10_pag.c ${PDP10D}/pdp10_rp.c ${PDP10D}/pdp10_sys.c \
460	${PDP10D}/pdp10_tim.c ${PDP10D}/pdp10_tu.c ${PDP10D}/pdp10_xtnd.c \
461	${PDP11D}/pdp11_pt.c ${PDP11D}/pdp11_ry.c \
462	${PDP11D}/pdp11_cr.c
463PDP10_OPT = -DVM_PDP10 -DUSE_INT64 -I ${PDP10D} -I ${PDP11D}
464
465
466
467PDP8D = PDP8
468PDP8 = ${PDP8D}/pdp8_cpu.c ${PDP8D}/pdp8_clk.c ${PDP8D}/pdp8_df.c \
469	${PDP8D}/pdp8_dt.c ${PDP8D}/pdp8_lp.c ${PDP8D}/pdp8_mt.c \
470	${PDP8D}/pdp8_pt.c ${PDP8D}/pdp8_rf.c ${PDP8D}/pdp8_rk.c \
471	${PDP8D}/pdp8_rx.c ${PDP8D}/pdp8_sys.c ${PDP8D}/pdp8_tt.c \
472	${PDP8D}/pdp8_ttx.c ${PDP8D}/pdp8_rl.c ${PDP8D}/pdp8_tsc.c \
473	${PDP8D}/pdp8_td.c ${PDP8D}/pdp8_ct.c ${PDP8D}/pdp8_fpp.c
474PDP8_OPT = -I ${PDP8D}
475
476
477H316D = H316
478H316 = ${H316D}/h316_stddev.c ${H316D}/h316_lp.c ${H316D}/h316_cpu.c \
479	${H316D}/h316_sys.c ${H316D}/h316_mt.c ${H316D}/h316_fhd.c \
480	${H316D}/h316_dp.c
481H316_OPT = -I ${H316D}
482
483
484HP2100D = HP2100
485HP2100 = ${HP2100D}/hp2100_stddev.c ${HP2100D}/hp2100_dp.c ${HP2100D}/hp2100_dq.c \
486	${HP2100D}/hp2100_dr.c ${HP2100D}/hp2100_lps.c ${HP2100D}/hp2100_ms.c \
487	${HP2100D}/hp2100_mt.c ${HP2100D}/hp2100_mux.c ${HP2100D}/hp2100_cpu.c \
488	${HP2100D}/hp2100_fp.c ${HP2100D}/hp2100_sys.c ${HP2100D}/hp2100_lpt.c \
489	${HP2100D}/hp2100_ipl.c ${HP2100D}/hp2100_ds.c ${HP2100D}/hp2100_cpu0.c \
490	${HP2100D}/hp2100_cpu1.c ${HP2100D}/hp2100_cpu2.c ${HP2100D}/hp2100_cpu3.c \
491	${HP2100D}/hp2100_cpu4.c ${HP2100D}/hp2100_cpu5.c ${HP2100D}/hp2100_cpu6.c \
492	${HP2100D}/hp2100_cpu7.c ${HP2100D}/hp2100_fp1.c ${HP2100D}/hp2100_baci.c \
493	${HP2100D}/hp2100_mpx.c ${HP2100D}/hp2100_pif.c ${HP2100D}/hp2100_di.c \
494	${HP2100D}/hp2100_di_da.c ${HP2100D}/hp_disclib.c
495HP2100_OPT = -DHAVE_INT64 -I ${HP2100D}
496
497
498I1401D = I1401
499I1401 = ${I1401D}/i1401_lp.c ${I1401D}/i1401_cpu.c ${I1401D}/i1401_iq.c \
500	${I1401D}/i1401_cd.c ${I1401D}/i1401_mt.c ${I1401D}/i1401_dp.c \
501	${I1401D}/i1401_sys.c
502I1401_OPT = -I ${I1401D}
503
504
505I1620D = I1620
506I1620 = ${I1620D}/i1620_cd.c ${I1620D}/i1620_dp.c ${I1620D}/i1620_pt.c \
507	${I1620D}/i1620_tty.c ${I1620D}/i1620_cpu.c ${I1620D}/i1620_lp.c \
508	${I1620D}/i1620_fp.c ${I1620D}/i1620_sys.c
509I1620_OPT = -I ${I1620D}
510
511
512I7094D = I7094
513I7094 = ${I7094D}/i7094_cpu.c ${I7094D}/i7094_cpu1.c ${I7094D}/i7094_io.c \
514	${I7094D}/i7094_cd.c ${I7094D}/i7094_clk.c ${I7094D}/i7094_com.c \
515	${I7094D}/i7094_drm.c ${I7094D}/i7094_dsk.c ${I7094D}/i7094_sys.c \
516	${I7094D}/i7094_lp.c ${I7094D}/i7094_mt.c ${I7094D}/i7094_binloader.c
517I7094_OPT = -DUSE_INT64 -I ${I7094D}
518
519
520IBM1130D = Ibm1130
521IBM1130 = ${IBM1130D}/ibm1130_cpu.c ${IBM1130D}/ibm1130_cr.c \
522	${IBM1130D}/ibm1130_disk.c ${IBM1130D}/ibm1130_stddev.c \
523	${IBM1130D}/ibm1130_sys.c ${IBM1130D}/ibm1130_gdu.c \
524	${IBM1130D}/ibm1130_gui.c ${IBM1130D}/ibm1130_prt.c \
525	${IBM1130D}/ibm1130_fmt.c ${IBM1130D}/ibm1130_ptrp.c \
526	${IBM1130D}/ibm1130_plot.c ${IBM1130D}/ibm1130_sca.c \
527	${IBM1130D}/ibm1130_t2741.c
528IBM1130_OPT = -I ${IBM1130D} -D HAVE_VM_INIT
529
530
531ID16D = Interdata
532ID16 = ${ID16D}/id16_cpu.c ${ID16D}/id16_sys.c ${ID16D}/id_dp.c \
533	${ID16D}/id_fd.c ${ID16D}/id_fp.c ${ID16D}/id_idc.c ${ID16D}/id_io.c \
534	${ID16D}/id_lp.c ${ID16D}/id_mt.c ${ID16D}/id_pas.c ${ID16D}/id_pt.c \
535	${ID16D}/id_tt.c ${ID16D}/id_uvc.c ${ID16D}/id16_dboot.c ${ID16D}/id_ttp.c
536ID16_OPT = -I ${ID16D}
537
538
539ID32D = Interdata
540ID32 = ${ID32D}/id32_cpu.c ${ID32D}/id32_sys.c ${ID32D}/id_dp.c \
541	${ID32D}/id_fd.c ${ID32D}/id_fp.c ${ID32D}/id_idc.c ${ID32D}/id_io.c \
542	${ID32D}/id_lp.c ${ID32D}/id_mt.c ${ID32D}/id_pas.c ${ID32D}/id_pt.c \
543	${ID32D}/id_tt.c ${ID32D}/id_uvc.c ${ID32D}/id32_dboot.c ${ID32D}/id_ttp.c
544ID32_OPT = -I ${ID32D}
545
546
547S3D = S3
548S3 = ${S3D}/s3_cd.c ${S3D}/s3_cpu.c ${S3D}/s3_disk.c ${S3D}/s3_lp.c \
549	${S3D}/s3_pkb.c ${S3D}/s3_sys.c
550S3_OPT = -I ${S3D}
551
552
553ALTAIRD = ALTAIR
554ALTAIR = ${ALTAIRD}/altair_sio.c ${ALTAIRD}/altair_cpu.c ${ALTAIRD}/altair_dsk.c \
555	${ALTAIRD}/altair_sys.c
556ALTAIR_OPT = -I ${ALTAIRD}
557
558
559ALTAIRZ80D = AltairZ80
560ALTAIRZ80 = ${ALTAIRZ80D}/altairz80_cpu.c ${ALTAIRZ80D}/altairz80_cpu_nommu.c \
561	${ALTAIRZ80D}/altairz80_dsk.c ${ALTAIRZ80D}/disasm.c \
562	${ALTAIRZ80D}/altairz80_sio.c ${ALTAIRZ80D}/altairz80_sys.c \
563	${ALTAIRZ80D}/altairz80_hdsk.c ${ALTAIRZ80D}/altairz80_net.c \
564	${ALTAIRZ80D}/flashwriter2.c ${ALTAIRZ80D}/i86_decode.c \
565	${ALTAIRZ80D}/i86_ops.c ${ALTAIRZ80D}/i86_prim_ops.c \
566	${ALTAIRZ80D}/i8272.c ${ALTAIRZ80D}/insnsd.c \
567	${ALTAIRZ80D}/mfdc.c ${ALTAIRZ80D}/n8vem.c ${ALTAIRZ80D}/vfdhd.c \
568	${ALTAIRZ80D}/s100_disk1a.c ${ALTAIRZ80D}/s100_disk2.c ${ALTAIRZ80D}/s100_disk3.c\
569	${ALTAIRZ80D}/s100_fif.c ${ALTAIRZ80D}/s100_mdriveh.c \
570	${ALTAIRZ80D}/s100_mdsad.c ${ALTAIRZ80D}/s100_selchan.c \
571	${ALTAIRZ80D}/s100_ss1.c ${ALTAIRZ80D}/s100_64fdc.c \
572	${ALTAIRZ80D}/s100_scp300f.c ${ALTAIRZ80D}/sim_imd.c \
573	${ALTAIRZ80D}/wd179x.c ${ALTAIRZ80D}/s100_hdc1001.c \
574	${ALTAIRZ80D}/s100_if3.c ${ALTAIRZ80D}/s100_adcs6.c
575ALTAIRZ80_OPT = -I ${ALTAIRZ80D} -D HAVE_VM_INIT
576
577
578GRID = GRI
579GRI = ${GRID}/gri_cpu.c ${GRID}/gri_stddev.c ${GRID}/gri_sys.c
580GRI_OPT = -I ${GRID}
581
582
583LGPD = LGP
584LGP = ${LGPD}/lgp_cpu.c ${LGPD}/lgp_stddev.c ${LGPD}/lgp_sys.c
585LGP_OPT = -I ${LGPD}
586
587
588SDSD = SDS
589SDS = ${SDSD}/sds_cpu.c ${SDSD}/sds_drm.c ${SDSD}/sds_dsk.c ${SDSD}/sds_io.c \
590	${SDSD}/sds_lp.c ${SDSD}/sds_mt.c ${SDSD}/sds_mux.c ${SDSD}/sds_rad.c \
591	${SDSD}/sds_stddev.c ${SDSD}/sds_sys.c
592SDS_OPT = -I ${SDSD}
593
594SWTP6800D = swtp6800/swtp6800
595SWTP6800C = swtp6800/common
596SWTP6800MP-A = ${SWTP6800C}/mp-a.c ${SWTP6800C}/m6800.c ${SWTP6800C}/m6810.c \
597	${SWTP6800C}/bootrom.c ${SWTP6800C}/dc-4.c ${SWTP6800C}/mp-s.c ${SWTP6800D}/mp-a_sys.c \
598	${SWTP6800C}/mp-b2.c ${SWTP6800C}/mp-8m.c
599SWTP6800MP-A2 = ${SWTP6800C}/mp-a2.c ${SWTP6800C}/m6800.c ${SWTP6800C}/m6810.c \
600	${SWTP6800C}/bootrom.c ${SWTP6800C}/dc-4.c ${SWTP6800C}/mp-s.c ${SWTP6800D}/mp-a2_sys.c \
601	${SWTP6800C}/mp-b2.c ${SWTP6800C}/mp-8m.c ${SWTP6800C}/i2716.c
602SWTP6800_OPT = -I ${SWTP6800D}
603
604
605#
606# Build everything
607#
608ALL = pdp1 pdp4 pdp7 pdp8 pdp9 pdp15 pdp11 pdp10 \
609	vax vax780 nova eclipse hp2100 i1401 i1620 s3 \
610	altair altairz80 gri i7094 ibm1130 id16 \
611	id32 sds lgp h316 swtp6800mp-a swtp6800mp-a2
612
613all : ${ALL}
614
615clean :
616ifeq ($(WIN32),)
617	${RM} -r ${BIN}
618else
619	if exist BIN\*.exe del /q BIN\*.exe
620	if exist BIN rmdir BIN
621endif
622
623#
624# Individual builds
625#
626pdp1 : ${BIN}pdp1${EXE}
627
628${BIN}pdp1${EXE} : ${PDP1} ${SIM}
629	${MKDIRBIN}
630	${CC} ${PDP1} ${SIM} ${PDP1_OPT} $(CC_OUTSPEC) ${LDFLAGS}
631
632pdp4 : ${BIN}pdp4${EXE}
633
634${BIN}pdp4${EXE} : ${PDP18B} ${SIM}
635	${MKDIRBIN}
636	${CC} ${PDP18B} ${SIM} ${PDP4_OPT} $(CC_OUTSPEC) ${LDFLAGS}
637
638pdp7 : ${BIN}pdp7${EXE}
639
640${BIN}pdp7${EXE} : ${PDP18B} ${SIM}
641	${MKDIRBIN}
642	${CC} ${PDP18B} ${SIM} ${PDP7_OPT} $(CC_OUTSPEC) ${LDFLAGS}
643
644pdp8 : ${BIN}pdp8${EXE}
645
646${BIN}pdp8${EXE} : ${PDP8} ${SIM}
647	${MKDIRBIN}
648	${CC} ${PDP8} ${SIM} ${PDP8_OPT} $(CC_OUTSPEC) ${LDFLAGS}
649
650pdp9 : ${BIN}pdp9${EXE}
651
652${BIN}pdp9${EXE} : ${PDP18B} ${SIM}
653	${MKDIRBIN}
654	${CC} ${PDP18B} ${SIM} ${PDP9_OPT} $(CC_OUTSPEC) ${LDFLAGS}
655
656pdp15 : ${BIN}pdp15${EXE}
657
658${BIN}pdp15${EXE} : ${PDP18B} ${SIM}
659	${MKDIRBIN}
660	${CC} ${PDP18B} ${SIM} ${PDP15_OPT} $(CC_OUTSPEC) ${LDFLAGS}
661
662pdp10 : ${BIN}pdp10${EXE}
663
664${BIN}pdp10${EXE} : ${PDP10} ${SIM}
665	${MKDIRBIN}
666	${CC} ${PDP10} ${SIM} ${PDP10_OPT} $(CC_OUTSPEC) ${LDFLAGS}
667
668pdp11 : ${BIN}pdp11${EXE}
669
670${BIN}pdp11${EXE} : ${PDP11} ${SIM}
671	${MKDIRBIN}
672	${CC} ${PDP11} ${SIM} ${PDP11_OPT} $(CC_OUTSPEC) ${LDFLAGS}
673
674vax : ${BIN}vax${EXE}
675
676${BIN}vax${EXE} : ${VAX} ${SIM}
677	${MKDIRBIN}
678	${CC} ${VAX} ${SIM} ${VAX_OPT} $(CC_OUTSPEC) ${LDFLAGS}
679
680vax780 : ${BIN}vax780${EXE}
681
682${BIN}vax780${EXE} : ${VAX780} ${SIM}
683	${MKDIRBIN}
684	${CC} ${VAX780} ${SIM} ${VAX780_OPT} $(CC_OUTSPEC) ${LDFLAGS}
685
686nova : ${BIN}nova${EXE}
687
688${BIN}nova${EXE} : ${NOVA} ${SIM}
689	${MKDIRBIN}
690	${CC} ${NOVA} ${SIM} ${NOVA_OPT} $(CC_OUTSPEC) ${LDFLAGS}
691
692eclipse : ${BIN}eclipse${EXE}
693
694${BIN}eclipse${EXE} : ${ECLIPSE} ${SIM}
695	${MKDIRBIN}
696	${CC} ${ECLIPSE} ${SIM} ${ECLIPSE_OPT} $(CC_OUTSPEC) ${LDFLAGS}
697
698h316 : ${BIN}h316${EXE}
699
700${BIN}h316${EXE} : ${H316} ${SIM}
701	${MKDIRBIN}
702	${CC} ${H316} ${SIM} ${H316_OPT} $(CC_OUTSPEC) ${LDFLAGS}
703
704hp2100 : ${BIN}hp2100${EXE}
705
706${BIN}hp2100${EXE} : ${HP2100} ${SIM}
707	${MKDIRBIN}
708	${CC} ${HP2100} ${SIM} ${HP2100_OPT} $(CC_OUTSPEC) ${LDFLAGS}
709
710i1401 : ${BIN}i1401${EXE}
711
712${BIN}i1401${EXE} : ${I1401} ${SIM}
713	${MKDIRBIN}
714	${CC} ${I1401} ${SIM} ${I1401_OPT} $(CC_OUTSPEC) ${LDFLAGS}
715
716i1620 : ${BIN}i1620${EXE}
717
718${BIN}i1620${EXE} : ${I1620} ${SIM}
719	${MKDIRBIN}
720	${CC} ${I1620} ${SIM} ${I1620_OPT} $(CC_OUTSPEC) ${LDFLAGS}
721
722i7094 : ${BIN}i7094${EXE}
723
724${BIN}i7094${EXE} : ${I7094} ${SIM}
725	${MKDIRBIN}
726	${CC} ${I7094} ${SIM} ${I7094_OPT} $(CC_OUTSPEC) ${LDFLAGS}
727
728ibm1130 : ${BIN}ibm1130${EXE}
729
730${BIN}ibm1130${EXE} : ${IBM1130}
731	${MKDIRBIN}
732	${CC} ${IBM1130} ${SIM} ${IBM1130_OPT} $(CC_OUTSPEC) ${LDFLAGS}
733
734s3 : ${BIN}s3${EXE}
735
736${BIN}s3${EXE} : ${S3} ${SIM}
737	${MKDIRBIN}
738	${CC} ${S3} ${SIM} ${S3_OPT} $(CC_OUTSPEC) ${LDFLAGS}
739
740altair : ${BIN}altair${EXE}
741
742${BIN}altair${EXE} : ${ALTAIR} ${SIM}
743	${MKDIRBIN}
744	${CC} ${ALTAIR} ${SIM} ${ALTAIR_OPT} $(CC_OUTSPEC) ${LDFLAGS}
745
746altairz80 : ${BIN}altairz80${EXE}
747
748${BIN}altairz80${EXE} : ${ALTAIRZ80} ${SIM}
749	${MKDIRBIN}
750	${CC} ${ALTAIRZ80} ${SIM} ${ALTAIRZ80_OPT} $(CC_OUTSPEC) ${LDFLAGS}
751
752gri : ${BIN}gri${EXE}
753
754${BIN}gri${EXE} : ${GRI} ${SIM}
755	${MKDIRBIN}
756	${CC} ${GRI} ${SIM} ${GRI_OPT} $(CC_OUTSPEC) ${LDFLAGS}
757
758lgp : ${BIN}lgp${EXE}
759
760${BIN}lgp${EXE} : ${LGP} ${SIM}
761	${MKDIRBIN}
762	${CC} ${LGP} ${SIM} ${LGP_OPT} $(CC_OUTSPEC) ${LDFLAGS}
763
764id16 : ${BIN}id16${EXE}
765
766${BIN}id16${EXE} : ${ID16} ${SIM}
767	${MKDIRBIN}
768	${CC} ${ID16} ${SIM} ${ID16_OPT} $(CC_OUTSPEC) ${LDFLAGS}
769
770id32 : ${BIN}id32${EXE}
771
772${BIN}id32${EXE} : ${ID32} ${SIM}
773	${MKDIRBIN}
774	${CC} ${ID32} ${SIM} ${ID32_OPT} $(CC_OUTSPEC) ${LDFLAGS}
775
776sds : ${BIN}sds${EXE}
777
778${BIN}sds${EXE} : ${SDS} ${SIM}
779	${MKDIRBIN}
780	${CC} ${SDS} ${SIM} ${SDS_OPT} $(CC_OUTSPEC) ${LDFLAGS}
781
782swtp6800mp-a : ${BIN}swtp6800mp-a${EXE}
783
784${BIN}swtp6800mp-a${EXE} : ${SWTP6800MP-A} ${SIM}
785	${MKDIRBIN}
786	${CC} ${SWTP6800MP-A} ${SIM} ${SWTP6800_OPT} $(CC_OUTSPEC) ${LDFLAGS}
787
788swtp6800mp-a2 : ${BIN}swtp6800mp-a2${EXE}
789
790${BIN}swtp6800mp-a2${EXE} : ${SWTP6800MP-A2} ${SIM}
791	${MKDIRBIN}
792	${CC} ${SWTP6800MP-A2} ${SIM} ${SWTP6800_OPT} $(CC_OUTSPEC) ${LDFLAGS}
793