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.
90 # Names used by the template mechanism.
91 # They are used as part of the corresponding variable names
92 # like "NOVA" in "NOVA_CFLAGS".
93 # You will have to add a name for every new simulator or build
96 SIM_NAMES=COMMON H316 NOVA ECLIPSE
99 # Global stuff. The special executable "nothing" will not be built.
102 COMMON_MODULES=scp sim_console sim_fio sim_timer sim_sock sim_tmxr sim_ether sim_tape
107 ################################################################################
113 NOVA_MODULES= nova_sys nova_cpu nova_dkp nova_dsk nova_lp nova_mta \
114 nova_plt nova_pt nova_clk nova_tt nova_tt1 nova_qty
117 ################################################################################
119 # Data General Eclipse
122 # Note: Here you see we define a ..._SRC_DIR and ..._OBJ_DIR. This is
123 # done because Nova and Eclipse have the same modules compiled
124 # with different CFLAGS.
125 # This is handled automatically by the generic rule template for
126 # object files. But if the OBJ_DIR should be deleted
127 # by "make clean", it must be added manually to the CLEANSTUFF list.
130 ECLIPSE_OBJ_DIR=eclipse
131 CLEANSTUFF+=$(ECLIPSE_OBJ_DIR)
134 ECLIPSE_MODULES=eclipse_cpu eclipse_tt nova_sys nova_dkp nova_dsk nova_lp \
135 nova_mta nova_plt nova_pt nova_clk nova_tt1 nova_qty
136 ECLIPSE_CFLAGS=-DECLIPSE -DUSE_INT64
139 ################################################################################
142 # Honeywell DDP-516/H316
146 H316_MODULES = h316_stddev h316_lp h316_cpu h316_sys h316_mt h316_fhd h316_dp
149 ################################################################################
150 ################################################################################
152 # Here comes the weird generic stuff. Should be altered VERY carefully only.
158 #################################
160 # The object file build rule template
163 define OBJECT_TEMPLATE
165 # If no ..._OBJ_DIR is specified, use ..._DIR
167 ifeq (,$$($(1)_OBJ_DIR))
168 $(1)_OBJ_DIR=$$($(1)_DIR)
171 # If no ..._SRC_DIR is specified, use ..._DIR
173 ifeq (,$$($(1)_SRC_DIR))
174 $(1)_SRC_DIR=$$($(1)_DIR)
177 # Generate object file names with path (for example h316/h316_cpu.o)
179 $(1)_OBJS=$$(foreach obj, $$($(1)_MODULES), $$($(1)_OBJ_DIR)/$$(obj).o)
181 # Add the object files to the CLEANSTUFF list
183 CLEANSTUFF+=$$($(1)_OBJS)
186 # At the moment, header file changes might cause too many files to be rebuilt. But
187 # that seems to be acceptable for the moment.
189 $$($(1)_OBJS) : $$($(1)_OBJ_DIR)/%.o : $$($(1)_SRC_DIR)/%.c $$($(1)_SRC_DIR)/*.h $$(COMMON_DIR)/*.h
192 # Create output directory if it doesn't exist yet.
194 @if [ ! -d $$($(1)_OBJ_DIR) ]; then echo "MKDIR $$($(1)_OBJ_DIR)"; mkdir $$($(1)_OBJ_DIR); fi
197 @echo $$(CC) -c -o $$@ -I $$($(1)_DIR) $$(CFLAGS) $$($(1)_CFLAGS) $$<
200 @$$(CC) -c -o $$@ -I $$($(1)_DIR) $$(CFLAGS) $$($(1)_CFLAGS) $$<
205 #################################
207 # The executable file build rule template
210 define PROGRAM_TEMPLATE
212 # Add the executable to the CLEANSTUFF list
214 CLEANSTUFF+=$$(TARGET_DIR)/$$($(1)_EXEC)$$(EXEC_SUFFIX)
216 # We won't build or mention the executable named "noting"!
217 ifneq (nothing,$$($(1)_EXEC))
218 EXEC_TARGETS+=$$($(1)_EXEC)
221 # Generate a phony target with the simulator's name.
222 # Enables things like "make h316".
223 # On Windows this WILL NOT be "make h316.exe".
225 $$($(1)_EXEC): $$(TARGET_DIR)/$$($(1)_EXEC)$$(EXEC_SUFFIX)
227 .PHONY: $$($(1)_EXEC)
229 $$(TARGET_DIR)/$$($(1)_EXEC)$$(EXEC_SUFFIX): $$($(1)_OBJS) $$(COMMON_OBJS)
230 @if [ ! -d $$(TARGET_DIR) ]; then echo "MKDIR $$(TARGET_DIR)";mkdir $$(TARGET_DIR);fi
233 @echo $$(CC) -o$$@ $$(LDFLAGS) $$($(1)_LDFLAGS) $$^
235 @$$(CC) -o$$@ $$(LDFLAGS) $$($(1)_LDFLAGS) $$^
239 #################################
241 # Use the template with SIM_NAMES
244 $(foreach sn, $(SIM_NAMES),$(eval $(call OBJECT_TEMPLATE,$(sn))))
245 $(foreach sn, $(SIM_NAMES),$(eval $(call PROGRAM_TEMPLATE,$(sn))))
248 #################################
256 #################################
258 # Output a little help
262 @echo Available targets:
264 @echo "all - Build all simulators"
265 @echo "clean - Delete all generated files and directories"
267 @echo Simulators can explicitely built by the following targets:
269 @echo $(EXEC_TARGETS)
273 @echo The actual CC calls can be made visible with specifying VERBOSE=something.
277 #################################
284 @rm -rf $(CLEANSTUFF)
287 #################################
289 # Specify phony targets
292 .PHONY: clean help all default
295 ################################################################################
297 # This is the end of the game :-)
299 ################################################################################