First Commit of my working state
[simh.git] / Makefile.tmp
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
11 BUILD=linux
12
13 ifneq ($(WIN32),)
14 BUILD=win32
15 endif
16
17 ifneq (,$(findstring solaris,$(OSTYPE)))
18 BUILD=solaris
19 endif
20
21 ifneq (,$(findstring darwin,$(OSTYPE)))
22 BUILD=darwin
23 endif
24
25
26 ################################################################################
27
28 # Set build options according to what we found out.
29
30 ifeq ($(BUILD),win32)
31 CC = gcc
32 LDFLAGS = -lm -lwsock32 -lwinmm
33 CFLAGS=-std=c99 -U__STRICT_ANSI__ -O2 -I. -Wall
34 EXEC_SUFFIX = .exe
35 endif
36
37 ifeq ($(BUILD),solaris)
38 CC=gcc
39 CFLAGS=-D_GNU_SOURCE
40 LDFLAGS=-lm -lsocket -lnsl -lrt -lpthread
41 endif
42
43 ifeq ($(BUILD),darwin)
44 CC=gcc
45 CFLAGS = -D_GNU_SOURCE
46 LDFLAGS=
47 endif
48
49 ifeq ($(BUILD),linux)
50 CC=gcc
51 CFLAGS = -D_GNU_SOURCE -std=c99 -U__STRICT_ANSI__ -g
52 LDFLAGS= -lrt -lm
53 endif
54
55
56 ################################################################################
57
58 # Add network definitions if desired
59
60 ifneq ($(USE_NETWORK),)
61 CFLAGS+=-DUSE_NETWORK
62 LDFLAGS+=-lwpcap -lpacket
63 endif
64
65
66 ################################################################################
67
68 # Other stuff to add to CFLAGS and LDFLAGS
69
70 CFLAGS+=-I common
71 LDFLAGS+=
72
73
74 ################################################################################
75
76 # Target directory where the executables go to.
77 # The directory is automatically created if it doesn't exist.
78 TARGET_DIR=bin
79
80 # This makes the target directory go away with "make clean":
81 CLEANSTUFF+=$(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
95 SIM_NAMES+=COMMON
96 COMMON_DIR=common
97 COMMON_MODULES=scp sim_console sim_fio sim_timer sim_sock sim_tmxr sim_ether sim_tape
98 COMMON_CFLAGS=
99 COMMON_EXEC=nothing
100
101
102 ################################################################################
103 #
104 # Data General Nova
105 #
106
107 SIM_NAMES+=NOVA
108 NOVA_DIR=nova
109 NOVA_EXEC=nova
110 NOVA_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
126 SIM_NAMES+=ECLIPSE
127 ECLIPSE_SRC_DIR=nova
128 ECLIPSE_OBJ_DIR=eclipse
129 CLEANSTUFF+=$(ECLIPSE_OBJ_DIR)
130 ECLIPSE_EXEC=eclipse
131 ECLIPSE_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
133 ECLIPSE_CFLAGS=-DECLIPSE -DUSE_INT64
134
135
136 ################################################################################
137 #
138 # DEC PDP-1
139 #
140
141 SIM_NAMES+=PDP1
142 PDP1_DIR = pdp1
143 PDP1_EXEC = pdp1
144 PDP1_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
153 PDP18_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
158 SIM_NAMES+=PDP4
159 PDP4_SRC_DIR=pdp18b
160 PDP4_OBJ_DIR=pdp4
161 PDP4_EXEC=pdp4
162 CLEANSTUFF+=$(PDP4_OBJ_DIR)
163 PDP4_MODULES=$(PDP18_MODULES)
164 PDP4_CFLAGS=-DPDP4
165
166 SIM_NAMES+=PDP7
167 PDP7_SRC_DIR=pdp18b
168 PDP7_OBJ_DIR=pdp7
169 PDP7_EXEC=pdp7
170 CLEANSTUFF+=$(PDP7_OBJ_DIR)
171 PDP7_MODULES=$(PDP18_MODULES)
172 PDP7_CFLAGS=-DPDP7
173
174 SIM_NAMES+=PDP9
175 PDP9_SRC_DIR=pdp18b
176 PDP9_OBJ_DIR=pdp9
177 PDP9_EXEC=pdp9
178 CLEANSTUFF+=$(PDP9_OBJ_DIR)
179 PDP9_MODULES=$(PDP18_MODULES)
180 PDP9_CFLAGS=-DPDP9
181
182 SIM_NAMES+=PDP15
183 PDP15_SRC_DIR=pdp18b
184 PDP15_OBJ_DIR=pdp15
185 PDP15_EXEC=pdp15
186 CLEANSTUFF+=$(PDP15_OBJ_DIR)
187 PDP15_MODULES=$(PDP18_MODULES)
188 PDP15_CFLAGS=-DPDP15
189
190
191 ################################################################################
192 #
193 # DEC PDP-11
194 #
195
196 SIM_NAMES+=PDP11
197 PDP11_DIR=pdp11
198 PDP11_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
211 PDP11_EXEC=pdp11
212 PDP11_CFLAGS=-DVM_PDP11
213
214 ################################################################################
215 #
216 # DEC PDP-10
217 #
218
219 SIM_NAMES+=PDP10
220 PDP10_OBJ_DIR=pdp10
221 PDP10_SRC_DIR=pdp10
222 PDP10_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
227 PDP10_EXEC=pdp10
228 PDP10_CFLAGS=-DVM_PDP10 -DUSE_INT64 -I $(PDP11_DIR)
229
230
231
232 ################################################################################
233
234 #
235 # Honeywell DDP-516/H316
236 #
237 H316_DIR=h316
238 H316_EXEC=h316
239 H316_MODULES = h316_stddev h316_lp h316_cpu h316_sys h316_mt h316_fhd h316_dp
240
241
242
243 PDP1_DIR = pdp1
244 PDP1_EXEC = pdp1
245 PDP1_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
254 default: all
255
256
257 #################################
258 #
259 # The object file build rule template
260 #
261
262 define OBJECT_TEMPLATE
263
264 # If no ..._OBJ_DIR is specified, use ..._DIR
265
266 ifeq (,$$($(1)_OBJ_DIR))
267 $(1)_OBJ_DIR=$$($(1)_DIR)
268 endif
269
270 # If no ..._SRC_DIR is specified, use ..._DIR
271
272 ifeq (,$$($(1)_SRC_DIR))
273 $(1)_SRC_DIR=$$($(1)_DIR)
274 endif
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
283 CLEANSTUFF+=$$($(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
294 ifneq (,$$(VERBOSE))
295 $$(CC) -c -o $$@ -I $$($(1)_DIR) $$(CFLAGS) $$($(1)_CFLAGS) $$<
296 else
297 @echo CC $$@
298 @$$(CC) -c -o $$@ -I $$($(1)_DIR) $$(CFLAGS) $$($(1)_CFLAGS) $$<
299 endif
300 endef
301
302
303 #################################
304 #
305 # The executable file build rule template
306 #
307
308 define PROGRAM_TEMPLATE
309
310 # Add the executable to the CLEANSTUFF list
311
312 CLEANSTUFF+=$$(TARGET_DIR)/$$($(1)_EXEC)$$(EXEC_SUFFIX)
313
314 # We won't build or mention the executable named "noting"!
315 ifneq (nothing,$$($(1)_EXEC))
316 EXEC_TARGETS+=$$($(1)_EXEC)
317 endif
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
331 ifneq (,$$(VERBOSE))
332 $$(CC) -o$$@ $$(LDFLAGS) $$($(1)_LDFLAGS) $$^
333 else
334 @echo LD $$@
335 @$$(CC) -o$$@ $$(LDFLAGS) $$($(1)_LDFLAGS) $$^
336 endif
337 endef
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
354 all: $(EXEC_TARGETS)
355
356
357 #################################
358 #
359 # Output a little help
360 #
361
362 help:
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
383 clean:
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