First Commit of my working state
[simh.git] / Makefile.tmp
CommitLineData
196ba1fc
PH
1# New Makefile for SIMH 3.8
2# Philipp Hachtmann
3#
4
5
6################################################################################
7
8# Find out something about the system we build for.
9# This process is ugly and should be revisited!
10
11BUILD=linux
12
13ifneq ($(WIN32),)
14 BUILD=win32
15endif
16
17ifneq (,$(findstring solaris,$(OSTYPE)))
18 BUILD=solaris
19endif
20
21ifneq (,$(findstring darwin,$(OSTYPE)))
22 BUILD=darwin
23endif
24
25
26################################################################################
27
28# Set build options according to what we found out.
29
30ifeq ($(BUILD),win32)
31 CC = gcc
32 LDFLAGS = -lm -lwsock32 -lwinmm
33 CFLAGS=-std=c99 -U__STRICT_ANSI__ -O2 -I. -Wall
34 EXEC_SUFFIX = .exe
35endif
36
37ifeq ($(BUILD),solaris)
38 CC=gcc
39 CFLAGS=-D_GNU_SOURCE
40 LDFLAGS=-lm -lsocket -lnsl -lrt -lpthread
41endif
42
43ifeq ($(BUILD),darwin)
44 CC=gcc
45 CFLAGS = -D_GNU_SOURCE
46 LDFLAGS=
47endif
48
49ifeq ($(BUILD),linux)
50 CC=gcc
51 CFLAGS = -D_GNU_SOURCE -std=c99 -U__STRICT_ANSI__ -g
52 LDFLAGS= -lrt -lm
53endif
54
55
56################################################################################
57
58# Add network definitions if desired
59
60ifneq ($(USE_NETWORK),)
61 CFLAGS+=-DUSE_NETWORK
62 LDFLAGS+=-lwpcap -lpacket
63endif
64
65
66################################################################################
67
68# Other stuff to add to CFLAGS and LDFLAGS
69
70CFLAGS+=-I common
71LDFLAGS+=
72
73
74################################################################################
75
76# Target directory where the executables go to.
77# The directory is automatically created if it doesn't exist.
78TARGET_DIR=bin
79
80# This makes the target directory go away with "make clean":
81CLEANSTUFF+=$(TARGET_DIR)
82
83
84################################################################################
85################################################################################
86
87# This is the main section containing all the simulator dependent information.
88
89
90
91#
92# Global stuff. The special executable "nothing" will not be built.
93#
94
95SIM_NAMES+=COMMON
96COMMON_DIR=common
97COMMON_MODULES=scp sim_console sim_fio sim_timer sim_sock sim_tmxr sim_ether sim_tape
98COMMON_CFLAGS=
99COMMON_EXEC=nothing
100
101
102################################################################################
103#
104# Data General Nova
105#
106
107SIM_NAMES+=NOVA
108NOVA_DIR=nova
109NOVA_EXEC=nova
110NOVA_MODULES= nova_sys nova_cpu nova_dkp nova_dsk nova_lp nova_mta \
111 nova_plt nova_pt nova_clk nova_tt nova_tt1 nova_qty
112
113
114################################################################################
115#
116# Data General Eclipse
117#
118
119# Note: Here you see we define a ..._SRC_DIR and ..._OBJ_DIR. This is
120# done because Nova and Eclipse have the same modules compiled
121# with different CFLAGS.
122# This is handled automatically by the generic rule template for
123# object files. But if the OBJ_DIR should be deleted
124# by "make clean", it must be added manually to the CLEANSTUFF list.
125
126SIM_NAMES+=ECLIPSE
127ECLIPSE_SRC_DIR=nova
128ECLIPSE_OBJ_DIR=eclipse
129CLEANSTUFF+=$(ECLIPSE_OBJ_DIR)
130ECLIPSE_EXEC=eclipse
131ECLIPSE_MODULES=eclipse_cpu eclipse_tt nova_sys nova_dkp nova_dsk nova_lp \
132 nova_mta nova_plt nova_pt nova_clk nova_tt1 nova_qty
133ECLIPSE_CFLAGS=-DECLIPSE -DUSE_INT64
134
135
136################################################################################
137#
138# DEC PDP-1
139#
140
141SIM_NAMES+=PDP1
142PDP1_DIR = pdp1
143PDP1_EXEC = pdp1
144PDP1_MODULES = pdp1_lp pdp1_cpu pdp1_stddev pdp1_sys pdp1_dt pdp1_drm \
145 pdp1_clk pdp1_dcs
146
147
148################################################################################
149#
150# DEC PDP-4,7,9,15
151#
152
153PDP18_MODULES = pdp18b_dt pdp18b_drm pdp18b_cpu\
154 pdp18b_lp pdp18b_mt pdp18b_rf\
155 pdp18b_rp pdp18b_stddev pdp18b_sys\
156 pdp18b_rb pdp18b_tt1 pdp18b_fpp
157
158SIM_NAMES+=PDP4
159PDP4_SRC_DIR=pdp18b
160PDP4_OBJ_DIR=pdp4
161PDP4_EXEC=pdp4
162CLEANSTUFF+=$(PDP4_OBJ_DIR)
163PDP4_MODULES=$(PDP18_MODULES)
164PDP4_CFLAGS=-DPDP4
165
166SIM_NAMES+=PDP7
167PDP7_SRC_DIR=pdp18b
168PDP7_OBJ_DIR=pdp7
169PDP7_EXEC=pdp7
170CLEANSTUFF+=$(PDP7_OBJ_DIR)
171PDP7_MODULES=$(PDP18_MODULES)
172PDP7_CFLAGS=-DPDP7
173
174SIM_NAMES+=PDP9
175PDP9_SRC_DIR=pdp18b
176PDP9_OBJ_DIR=pdp9
177PDP9_EXEC=pdp9
178CLEANSTUFF+=$(PDP9_OBJ_DIR)
179PDP9_MODULES=$(PDP18_MODULES)
180PDP9_CFLAGS=-DPDP9
181
182SIM_NAMES+=PDP15
183PDP15_SRC_DIR=pdp18b
184PDP15_OBJ_DIR=pdp15
185PDP15_EXEC=pdp15
186CLEANSTUFF+=$(PDP15_OBJ_DIR)
187PDP15_MODULES=$(PDP18_MODULES)
188PDP15_CFLAGS=-DPDP15
189
190
191################################################################################
192#
193# DEC PDP-11
194#
195
196SIM_NAMES+=PDP11
197PDP11_DIR=pdp11
198PDP11_MODULES = pdp11_fp pdp11_cpu pdp11_dz \
199 pdp11_cis pdp11_lp pdp11_rk \
200 pdp11_rl pdp11_rp pdp11_rx \
201 pdp11_stddev pdp11_sys pdp11_tc \
202 pdp11_tm pdp11_ts pdp11_io \
203 pdp11_rq pdp11_tq pdp11_pclk \
204 pdp11_ry pdp11_pt pdp11_hk \
205 pdp11_xq pdp11_xu pdp11_vh \
206 pdp11_rh pdp11_tu pdp11_cpumod \
207 pdp11_cr pdp11_rf pdp11_dl \
208 pdp11_ta pdp11_rc pdp11_kg \
209 pdp11_ke pdp11_dc
210
211PDP11_EXEC=pdp11
212PDP11_CFLAGS=-DVM_PDP11
213
214################################################################################
215#
216# DEC PDP-10
217#
218
219SIM_NAMES+=PDP10
220PDP10_OBJ_DIR=pdp10
221PDP10_SRC_DIR=pdp10
222PDP10_MODULES = pdp10_fe pdp11_dz pdp10_cpu \
223 pdp10_ksio pdp10_lp20 pdp10_mdfp \
224 pdp10_pag pdp10_rp pdp10_sys \
225 pdp10_tim pdp10_tu pdp10_xtnd ../$(PDP11_DIR)/pdp11_pt\
226 ../$(PDP11_DIR)/pdp11_ry ../$(PDP11_DIR)/pdp11_xu
227PDP10_EXEC=pdp10
228PDP10_CFLAGS=-DVM_PDP10 -DUSE_INT64 -I $(PDP11_DIR)
229
230
231
232################################################################################
233
234#
235# Honeywell DDP-516/H316
236#
237H316_DIR=h316
238H316_EXEC=h316
239H316_MODULES = h316_stddev h316_lp h316_cpu h316_sys h316_mt h316_fhd h316_dp
240
241
242
243PDP1_DIR = pdp1
244PDP1_EXEC = pdp1
245PDP1_MODULES = pdp1_lp pdp1_cpu pdp1_stddev pdp1_sys pdp1_dt pdp1_drm \
246 pdp1_clk pdp1_dcs
247
248################################################################################
249################################################################################
250
251# Here comes the weird generic stuff. Should be altered VERY carefully only.
252
253# Default target
254default: all
255
256
257#################################
258#
259# The object file build rule template
260#
261
262define OBJECT_TEMPLATE
263
264# If no ..._OBJ_DIR is specified, use ..._DIR
265
266ifeq (,$$($(1)_OBJ_DIR))
267$(1)_OBJ_DIR=$$($(1)_DIR)
268endif
269
270# If no ..._SRC_DIR is specified, use ..._DIR
271
272ifeq (,$$($(1)_SRC_DIR))
273 $(1)_SRC_DIR=$$($(1)_DIR)
274endif
275
276
277# Generate object file names with path (for example h316/h316_cpu.o)
278
279$(1)_OBJS=$$(foreach obj, $$($(1)_MODULES), $$($(1)_OBJ_DIR)/$$(obj).o)
280
281# Add the object files to the CLEANSTUFF list
282
283CLEANSTUFF+=$$($(1)_OBJS)
284
285# The build rule.
286# At the moment, header file changes might cause too many files to be rebuilt. But
287# that seems to be acceptable for the moment.
288
289$$($(1)_OBJS) : $$($(1)_OBJ_DIR)/%.o : $$($(1)_SRC_DIR)/%.c $$($(1)_SRC_DIR)/*.h $$(COMMON_DIR)/*.h
290
291# Create output directory if it doesn't exist yet.
292 @if [ ! -d $$($(1)_OBJ_DIR) ]; then echo "MKDIR $$($(1)_OBJ_DIR)"; mkdir $$($(1)_OBJ_DIR); fi
293
294ifneq (,$$(VERBOSE))
295 $$(CC) -c -o $$@ -I $$($(1)_DIR) $$(CFLAGS) $$($(1)_CFLAGS) $$<
296else
297 @echo CC $$@
298 @$$(CC) -c -o $$@ -I $$($(1)_DIR) $$(CFLAGS) $$($(1)_CFLAGS) $$<
299endif
300endef
301
302
303#################################
304#
305# The executable file build rule template
306#
307
308define PROGRAM_TEMPLATE
309
310# Add the executable to the CLEANSTUFF list
311
312CLEANSTUFF+=$$(TARGET_DIR)/$$($(1)_EXEC)$$(EXEC_SUFFIX)
313
314# We won't build or mention the executable named "noting"!
315ifneq (nothing,$$($(1)_EXEC))
316EXEC_TARGETS+=$$($(1)_EXEC)
317endif
318
319# Generate a phony target with the simulator's name.
320# Enables things like "make h316".
321# On Windows this WILL NOT be "make h316.exe".
322
323$$($(1)_EXEC): $$(TARGET_DIR)/$$($(1)_EXEC)$$(EXEC_SUFFIX)
324
325.PHONY: $$($(1)_EXEC)
326
327$$(TARGET_DIR)/$$($(1)_EXEC)$$(EXEC_SUFFIX): $$($(1)_OBJS) $$(COMMON_OBJS)
328 @if [ ! -d $$(TARGET_DIR) ]; then echo "MKDIR $$(TARGET_DIR)";mkdir $$(TARGET_DIR);fi
329
330
331ifneq (,$$(VERBOSE))
332 $$(CC) -o$$@ $$(LDFLAGS) $$($(1)_LDFLAGS) $$^
333else
334 @echo LD $$@
335 @$$(CC) -o$$@ $$(LDFLAGS) $$($(1)_LDFLAGS) $$^
336endif
337endef
338
339
340#################################
341#
342# Use the template with SIM_NAMES
343#
344
345$(foreach sn, $(SIM_NAMES),$(eval $(call OBJECT_TEMPLATE,$(sn))))
346$(foreach sn, $(SIM_NAMES),$(eval $(call PROGRAM_TEMPLATE,$(sn))))
347
348
349#################################
350#
351# The all target
352#
353
354all: $(EXEC_TARGETS)
355
356
357#################################
358#
359# Output a little help
360#
361
362help:
363 @echo Available targets:
364 @echo
365 @echo "all - Build all simulators"
366 @echo "clean - Delete all generated files and directories"
367 @echo
368 @echo Simulators can explicitely built by the following targets:
369 @echo
370 @echo $(EXEC_TARGETS)
371 @echo
372 @echo $(CLEANSTUFF)
373 @echo
374 @echo The actual CC calls can be made visible with specifying VERBOSE=something.
375 @echo
376
377
378#################################
379#
380# The clean rule.
381#
382
383clean:
384 @echo CLEAN
385 @rm -rf $(CLEANSTUFF)
386
387
388#################################
389#
390# Specify phony targets
391#
392
393.PHONY: clean help all default
394
395
396################################################################################
397#
398# This is the end of the game :-)
399#
400################################################################################
401
402
403