1 # New Makefile for SIMH 3.8
6 ################################################################################
8 # Find out something about the system we build for.
9 # This process is ugly and should be revisited!
17 ifneq (,$(findstring solaris,$(OSTYPE)))
21 ifneq (,$(findstring darwin,$(OSTYPE)))
26 ################################################################################
28 # Set build options according to what we found out.
32 LDFLAGS = -lm -lwsock32 -lwinmm
33 CFLAGS=-std=c99 -U__STRICT_ANSI__ -O2 -I. -Wall
37 ifeq ($(BUILD),solaris)
40 LDFLAGS=-lm -lsocket -lnsl -lrt -lpthread
43 ifeq ($(BUILD),darwin)
45 CFLAGS = -D_GNU_SOURCE
51 CFLAGS = -D_GNU_SOURCE -std=c99 -U__STRICT_ANSI__ -g
56 ################################################################################
58 # Add network definitions if desired
60 ifneq ($(USE_NETWORK),)
62 LDFLAGS+=-lwpcap -lpacket
66 ################################################################################
68 # Other stuff to add to CFLAGS and LDFLAGS
74 ################################################################################
76 # Target directory where the executables go to.
77 # The directory is automatically created if it doesn't exist.
80 # This makes the target directory go away with "make clean":
81 CLEANSTUFF+=$(TARGET_DIR)
84 ################################################################################
85 ################################################################################
87 # This is the main section containing all the simulator dependent information.
92 # Global stuff. The special executable "nothing" will not be built.
97 COMMON_MODULES=scp sim_console sim_fio sim_timer sim_sock sim_tmxr sim_ether sim_tape
102 ################################################################################
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
114 ################################################################################
116 # Data General Eclipse
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.
128 ECLIPSE_OBJ_DIR=eclipse
129 CLEANSTUFF+=$(ECLIPSE_OBJ_DIR)
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
136 ################################################################################
144 PDP1_MODULES = pdp1_lp pdp1_cpu pdp1_stddev pdp1_sys pdp1_dt pdp1_drm \
148 ################################################################################
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
162 CLEANSTUFF+=$(PDP4_OBJ_DIR)
163 PDP4_MODULES=$(PDP18_MODULES)
170 CLEANSTUFF+=$(PDP7_OBJ_DIR)
171 PDP7_MODULES=$(PDP18_MODULES)
178 CLEANSTUFF+=$(PDP9_OBJ_DIR)
179 PDP9_MODULES=$(PDP18_MODULES)
186 CLEANSTUFF+=$(PDP15_OBJ_DIR)
187 PDP15_MODULES=$(PDP18_MODULES)
191 ################################################################################
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 \
212 PDP11_CFLAGS=-DVM_PDP11
214 ################################################################################
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
228 PDP10_CFLAGS=-DVM_PDP10 -DUSE_INT64 -I $(PDP11_DIR)
232 ################################################################################
235 # Honeywell DDP-516/H316
239 H316_MODULES = h316_stddev h316_lp h316_cpu h316_sys h316_mt h316_fhd h316_dp
245 PDP1_MODULES = pdp1_lp pdp1_cpu pdp1_stddev pdp1_sys pdp1_dt pdp1_drm \
248 ################################################################################
249 ################################################################################
251 # Here comes the weird generic stuff. Should be altered VERY carefully only.
257 #################################
259 # The object file build rule template
262 define OBJECT_TEMPLATE
264 # If no ..._OBJ_DIR is specified, use ..._DIR
266 ifeq (,$$($(1)_OBJ_DIR))
267 $(1)_OBJ_DIR=$$($(1)_DIR)
270 # If no ..._SRC_DIR is specified, use ..._DIR
272 ifeq (,$$($(1)_SRC_DIR))
273 $(1)_SRC_DIR=$$($(1)_DIR)
277 # Generate object file names with path (for example h316/h316_cpu.o)
279 $(1)_OBJS=$$(foreach obj, $$($(1)_MODULES), $$($(1)_OBJ_DIR)/$$(obj).o)
281 # Add the object files to the CLEANSTUFF list
283 CLEANSTUFF+=$$($(1)_OBJS)
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.
289 $$($(1)_OBJS) : $$($(1)_OBJ_DIR)/%.o : $$($(1)_SRC_DIR)/%.c $$($(1)_SRC_DIR)/*.h $$(COMMON_DIR)/*.h
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
295 $$(CC) -c -o $$@ -I $$($(1)_DIR) $$(CFLAGS) $$($(1)_CFLAGS) $$<
298 @$$(CC) -c -o $$@ -I $$($(1)_DIR) $$(CFLAGS) $$($(1)_CFLAGS) $$<
303 #################################
305 # The executable file build rule template
308 define PROGRAM_TEMPLATE
310 # Add the executable to the CLEANSTUFF list
312 CLEANSTUFF+=$$(TARGET_DIR)/$$($(1)_EXEC)$$(EXEC_SUFFIX)
314 # We won't build or mention the executable named "noting"!
315 ifneq (nothing,$$($(1)_EXEC))
316 EXEC_TARGETS+=$$($(1)_EXEC)
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".
323 $$($(1)_EXEC): $$(TARGET_DIR)/$$($(1)_EXEC)$$(EXEC_SUFFIX)
325 .PHONY: $$($(1)_EXEC)
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
332 $$(CC) -o$$@ $$(LDFLAGS) $$($(1)_LDFLAGS) $$^
335 @$$(CC) -o$$@ $$(LDFLAGS) $$($(1)_LDFLAGS) $$^
340 #################################
342 # Use the template with SIM_NAMES
345 $(foreach sn, $(SIM_NAMES),$(eval $(call OBJECT_TEMPLATE,$(sn))))
346 $(foreach sn, $(SIM_NAMES),$(eval $(call PROGRAM_TEMPLATE,$(sn))))
349 #################################
357 #################################
359 # Output a little help
363 @echo Available targets:
365 @echo "all - Build all simulators"
366 @echo "clean - Delete all generated files and directories"
368 @echo Simulators can explicitely built by the following targets:
370 @echo $(EXEC_TARGETS)
374 @echo The actual CC calls can be made visible with specifying VERBOSE=something.
378 #################################
385 @rm -rf $(CLEANSTUFF)
388 #################################
390 # Specify phony targets
393 .PHONY: clean help all default
396 ################################################################################
398 # This is the end of the game :-)
400 ################################################################################