# BUG: sim_serial gets strict warnings for 4.x. # BUG: with just HP3000d.exe in cygwin, "make clean" does: # EXECPATS = HP3000 HP3000-32 HP3000-64 HP3000d HP3000d-32 HP3000d-64 # EXECFILES = HP3000 Tracing.txt HP3000d.exe HP3000 Work Remaining.txt HP3000 Work Completed.txt HP3000.pjt # DELFILES = ./HP3000 ./HP3000 ./HP3000 # if [ -n "./HP3000 ./HP3000 ./HP3000" ]; then rm ./HP3000 ./HP3000 ./HP3000; fi # rm: cannot remove './HP3000': No such file or directory # Makefile for the SIMH simulator (multiplatform/multicompiler version) # # This makefile will compile and link all .c files in the SCP directory and # any subdirectories thereof. It has been tested under these environments: # # - Windows / gcc (mingw) # - Windows / gcc (msys) # - Windows / gcc (Cygwin) # - Windows / Visual C++ 2008 # - Windows / clang (llvm 3.7.1) # # Goals: # # (none) -- make using last debug/release option # debug -- make using debug options # release -- make using release options # check -- make using release options and the strictest warnings # dist -- make using release options and the SIMH distribution warnings # all -- make debug and release versions of all simulators # -- compile to assembler source using the release options # list -- list the default values of overrideable variables # clean -- remove all made files # # Adding "-32" to the "debug", "release", "check", or "dist" goals will make # the files without 64-bit math. Adding "-64" will make the files with large # address support. Adding "-32" or "-64" to "list" will show the variables as # set for the indicated support level. # # If the make target is not specified, the target used for the last compilation # is used. If there is no "last compilation" (e.g., because this is the first # compilation or a "make clean" has been done), the "release" target is used. # # Explicitly specifying the same debug/release target as the previous build will # remake only the executable. # # If there is only one MACHINE subdirectory, it is used. Otherwise, the # MACHINE value specified for the last compilation is used. If there is no # "last compilation," then a message is printed that MACHINE must be specified. # # The target is useful to examine the generated code for a file. The # name specified is the base name of a C source file located in either the SCP # or the MACHINE subdirectories. # # If the VCINSTALLDIR environment variable exists, a VC++ build is performed; # otherwise, a gcc build is done unless CC is overridden on the make command # line or in the environment to use clang. If the SHELL environment variable # value contains ".exe", a Windows build platform is assumed; otherwise, a Unix # platform is assumed. # # It may be helpful to redefine one or more of the following variables on the # command line: # # MACHINE - the simulator target machine directory # OPTIMIZE - the list of optimization options for the compiler # DEBUG - the list of debug options for the compiler # WARNINGS - the list of user-specified warning options for the compiler # CFLAGS - the list of user-specified options for the compiler # LDFLAGS - the list of user-specified options for the linker # LIBS - the list of libraries to be searched while linking # UNUSED - the list of source files to omit from the build # # Doing "make list" will list the default values of the above variables, plus # a bunch of additional variables. # # # # 2023-08-24 Added "-Wno-error=unused-const-variable" to HP debug builds. # 2023-05-29 Suppress warnings 4255 and 4668 for VC++ check builds. # 2023-05-26 Added exceptions "-Wno-error=unused-macros" and # "-Wno-error=unused-variable" to HP debug builds. # 2022-04-05 Changed HAVE_DLOPEN to SIM_HAVE_DLOPEN for new SCP flag. # 2021-05-07 Added -fno-common to flag tentative global definition use. # Added -Wno-error to Cygwin check builds and -Wno-pedantic to # Cygwin SCP compilations. # 2021-02-15 Changed the PHONY list to add "scp" and remove "asmb". # 2021-02-10 Added "hp3000_cpu_apl.c" to the set of UNUSED files. # 2021-01-31 Unsuppress "warning 4244: possible loss of data". # 2020-10-29 Suppress "warning C4738: storing 32-bit float result in memory". # 2020-06-04 Added USE_VM_INIT definition to invoke "sim_vm_init" routine. # 2019-12-09 Removed the HAVE_EXTENSION definition (no longer needed). # 2019-07-18 Improved SCP 3.x vs. 4.x detection. # Compiiled "sim_extension" and "sim_serial" with the HP warning set. # 2019-05-19 Added "-D HAVE_DLOPEN=so" for SCP3 Unix compiles also. # 2019-05-16 Added test for "-Wimplicit-fallthrough" support the compiler. # 2019-04-17 Added "all" target; changed OS to OPSYS for recursive make. # 2019-04-15 Defines HAVE_EXTENSION if "sim_extension.h" is present. # 2019-03-12 Renamed SIMH subdirectory to SCP. # 2019-01-22 Moved "-Werror" from DEBUG to MAX_/HP_WARNINGS, as some of the # newer warnings are speculative and cause SCP noise. # 2018-12-27 Added "-Wimplicit-fallthrough=2" to accept proper grammar for gcc 7. # 2018-05-21 Added "-D HAVE_SEMAPHORE" to compile the Unix section of hp2100_ipl.c. # 2017-12-31 Added "-D HAVE_NTDDDISK_H" to compile 4.x sim_disk.c. # 2017-04-26 Removed -Wpadded from MAX_WARNINGS because sim_defs.h generates # these for every HP module. # 2016-09-20 "make clean" now keeps "makefile.in" to avoid having to respecify # MACHINE=target. Clang detected explicitly rather than as "not gcc". # Compiling with g++ uses "-std=c++11" instead of "-std=c99" and # skips using "-Wmissing-prototypes". # 2016-03-10 Added LASTMACHINE to "makefile.in" to save the last machine built. # 2016-01-30 Added VC++ deprecation suppression definitions to DIST_WARNINGS. # 2015-12-21 Added the target to compile to an assembler source. # 2015-12-18 "clean" now deletes only the executables it can create. # Improved the method of determining the MACHINE name. # 2015-09-14 Removed warning -Wno-unused-but-set-variable from clang # compilations; is unknown as of version 3.6.2. # 2015-08-19 Removed -Wconversion from the "check" warning list for too much # noise (objects to x = x + 1 if x is short). # 2015-07-27 Changed method of MACHINE determination for Unix. # Added option detection for -Wlogical-op and -Wdouble-promotion. # 2015-07-14 Added the "dist" target to make with SIMH distribution warnings. # Verifies that MACHDIR contains source files. # 2015-07-05 Added sim_frontpanel.c (4.0) to UNUSED, as it requires pthreads. # 2015-06-18 Use -Wno-pedantic-ms-format only for Windows compilations; # added -Wno-unused-variable and -Wno-unused-but-set-variable to the # SCP4_WARNINGS list, plus "-D HAVE_DLOPEN=so" for Cygwin compiles # 2015-06-16 Cygwin requires -Wno-char-subscripts for the SCP directory. # 2015-01-03 Changed "-64" to include 64-bit math as well as 64-bit addressing. # Allowed CC to be set in the environment to "clang". # 2015-01-02 SCP 4.0 produces a number of warnings that 3.9 does not, so use # separate SCP4_WARNINGS and SCP3_WARNINGS, depending on the # containing directory name. # 2014-12-16 Added the "check" option back, but now it does a release build # with the most verbose warning set. This presents all of the # warnings that the compiler can generate, except for those # explicitly suppressed in the source file(s). # 2014-12-23 Removed the "check" option (use C89 standard), reduced warnings # are now used for the machine sundirectory if it starts with "HP", # added -Wno-pedantic-ms-format for gcc builds # 2014-12-17 Reduced warnings are used for SIMH subdirectory if directory starts # with "simh-" to get clean build with released files # 2014-06-02 Changed default target if no makefile.in from "debug" to "release" # 2013-09-22 Derive machine from first SIMH subdirectory name; # separate host OS from host shell # 2013-04-09 Generate dependencies files only if using gcc # 2013-04-01 Support CC=clang and CC=cc for clang/llvm # 2013-03-29 Suppress "warning C4554: check operator precedence for possible error" # 2013-03-04 Fixed support for general Unix variants, warnings for Cygwin # 2013-02-05 "sim_ether.c" is unused only if SIMH version < 4.0 # 2012-12-17 Avoided making compilation dependencies during "make list" # 2012-12-12 Added "advapi32.lib" for registry support for SerialMux branch # 2012-05-09 Removed -Wno-comment and -Wno-char-subscripts from WARNINGS # 2012-04-11 "sim_BuildROMs.c" is unused # 2012-02-23 Added -Werror to gcc debug builds (SIMH should build cleanly) # 2011-03-24 Added arch = prescott (Pentium D), tune = core2. # 2010-01-05 Merged gcc and msvc versions. # 2008-11-14 Reverted warning level from /W4 to /W3 to match Bob Supnik's system # 2008-08-13 Added "-32" and "-check" suffixes to allow control over language # environment. # 2008-04-21 Added more warnings. # Added goals debug-32, release-32 to build 32-bit-only versions. # 2007-06-18 Simplified generation of .d files. # 2007-02-01 Suppresses "warning C4996: 'strcpy' [et. al] was declared deprecated" # 2007-01-04 Now creates $(OBJDIR) rather than hard-coded names # Internal CFLAGS renamed to CCFLAGS to allow redefinition # 2006-05-31 Debug version creates d.exe, e.g., hp2100d.exe # 2006-06-01 Now builds all files found in machine directory # 2006-07-06 Dependency goals now have correct subdirectories # Set up the default simulation directories. EXEDIR := . SCPDIR := SCP # Determine the host operating system. ifeq ($(findstring Windows,$(OS)),Windows) OPSYS := Win EXEEXT := .exe else OPSYS := Unix EXEEXT := endif # Determine the shell type. ifeq ($(findstring .exe, $(SHELL)),.exe) SH := cmd else SH := sh endif # Include the previous definitions of LASTBUILD and LASTMACHINE, if any, as the # default goal and machine. # # Note that the variables must be stripped before use, as they may have # trailing blanks. -include makefile.in # Determine the machine subdirectory. # # If the MACHINE variable is set, use it as the subdirectory name. Otherwise, # gather the names of the subdirectories under the SCP subdirectory that hold # C source files. If there's only one name, use it. If there are no names, or # there is more than one name and the LASTMACHINE variable is not set, report an # error. ifeq ($(MACHINE),) MACHINES := $(patsubst $(SCPDIR)/%/,%,$(sort $(dir $(wildcard $(SCPDIR)/*/*.c)))) ifeq ($(MACHINES),) $(error There is no target machine subdirectory under $(SCPDIR)) else ifeq ($(words $(MACHINES)), 1) MACHINE := $(MACHINES) else ifneq ($(LASTMACHINE),) MACHINE := $(strip $(LASTMACHINE)) else $(error Must specify the MACHINE subdirectory to use) endif endif MACHDIR := $(SCPDIR)/$(MACHINE) # Create the list of executable file names that this makefile can create. If # the "clean" target is specified, determine which executables exist that are # in the list of names that can be created. This list will then be used to # delete those files. # # We do this rather than deleting only the target executable so that "clean" # will clean up all possible build files and not just those of the last build. # We do this rather than deleting all executables that start with the machine # name to avoid deleting saved copies that have been renamed to preserve them # across builds (e.g., "HP3000.old.exe"). # Enumerate the possible executable suffixes (not extensions). SUFFIXES := -32 -64 d d-32 d-64 # If the "clean" target is specified, then create a list of executables that # can be created (EXECPATS), a list of existing executable files (EXECFILES), # and the intersection of the two lists (DELFILES) with the executable # directory prefixed. ifneq ($(findstring clean,$(MAKECMDGOALS)),) EXECPATS := $(addsuffix $(EXEEXT), $(MACHINE) $(addprefix $(MACHINE), $(SUFFIXES))) EXECFILES := $(notdir $(wildcard $(EXEDIR)/$(MACHINE)*$(EXEEXT))) DELFILES := $(addprefix $(EXEDIR)/, $(filter $(EXECPATS), $(EXECFILES))) endif # Set the compilation variables, depending on compiler selected. ifneq ($(VCINSTALLDIR),) # Set the options for MSVC++ # # The strictest set of warnings has several that are pure noise. These # are: # # 4100 - 'identifier' : unreferenced formal parameter # 4114 - same type qualifier used more than once -- [legal per C99] # 4127 - conditional expression is constant -- [e.g., while (TRUE)] # 4711 - function 'identifier' selected for automatic inline expansion # 4738 - storing 32-bit float result in memory, possible loss of performance # 4820 - 'identifier' : 'count' bytes padding added after data member 'identifier' # 4996 - 'identifier': was declared deprecated [e.g., strcat] # # ...while these warnings occur in the Windows include files a few zillion # times and are unlikely to appear in the simulator code: # # 4255 - 'function' : no function prototype given: converting '()' to '(void)' # 4668 - 'symbol' is not defined as a preprocessor macro, replacing with '0' for directives # # For HP simulator code, we use level 4 and suppress the following largely # extraneous warnings: # # 4100 - 'identifier' : unreferenced formal parameter # 4114 - same type qualifier used more than once # 4127 - conditional expression is constant # 4554 - 'op' : check operator precedence for possible error; use parentheses to clarify precedence # 4820 - 'identifier' : 'count' bytes padding added after data member 'identifier' # 4996 - 'function': was declared deprecated # # In addition to these, we suppress the following warnings for existing # SCP/simulator code: # # 4206 - nonstandard extension used : translation unit is empty # 4210 - nonstandard extension used : function given file scope # 4701 - potentially uninitialized local variable 'var' used # 4706 - assignment within conditional expression # # ...and this one for SCP 4.0: # # 4389 - 'op' : signed/unsigned mismatch MAX_WARNINGS := /Wall /wd4100 /wd4114 /wd4127 /wd4255 /wd4668 /wd4711 \ /wd4738 /wd4820 /wd4996 HP_WARNINGS := /W4 /wd4100 /wd4114 /wd4127 /wd4554 /wd4820 /wd4996 HP_EXCEPTIONS := SCP3_WARNINGS := $(HP_WARNINGS) /wd4206 /wd4210 /wd4701 /wd4706 SCP4_WARNINGS := $(HP_WARNINGS) /wd4206 /wd4210 /wd4701 /wd4706 /wd4389 DIST_WARNINGS := /W3 /D_CRT_NONSTDC_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS \ /D_WINSOCK_DEPRECATED_NO_WARNINGS CC := cl LD := $(CC) INCLUDES := /I$(SCPDIR) /I$(MACHDIR) OBJEXT := .obj ASSEMBLE := /c /w /FAs /Fonul COMPILE := /nologo /c COMPOUT := /Fo LINK := /nologo LINKOUT := /Fe OPTIMIZE := /Ox LDOPT := /MD DEBUG := /Zi /RTC1 LDDEBUG := /MDd /Zi /RTC1 INIT := /DUSE_VM_INIT MATH64 := /DHAVE_INT64 ADDR64 := /DUSE_INT64 /DUSE_ADDR64 STDC := LIBS := advapi32.lib wsock32.lib winmm.lib else # Set the options for gcc/clang. # # The CC variable may be set to "clang" in the environment. The "origin" # test is necessary to allow that setting to be used in lieu of the # internal setting (which has priority unless "make -e" is specified). # # The removal of the __STRICT_ANSI__ definition is necessary to obtain a # declaration for the "_fileno" function in , which is used by the # sim_ttrun and sim_tt_cmd functions in sim_console.c. It would seem that a # better place to put this would be within the WIN32 section of sim_console.c # (as an #undef), but I don't know what other systems might require this. ifeq ($(origin CC),default) CC := gcc endif LD := $(CC) INCLUDES := -U __STRICT_ANSI__ -I $(SCPDIR) -I $(MACHDIR) OBJEXT := .o # The COMPOUT and LINKOUT variables specify the command-line switches # required to set the compiler and linker output filenames. The tricky bit # is that gcc requires a space between "-o" and the filename, and VC++ # requires no space between its equivalent and the filename. We solve that # by appending blanks to the gcc switches and then concatenating the # switches and filenames in the invocations. NULL is used to generate the # trailing blank, which is actually the delimiter between the two words. NULL := ASSEMBLE := -S -g -w COMPILE := -c COMPOUT := -o $(NULL) LINK := LINKOUT := -o $(NULL) OPTIMIZE := -O2 LDOPT := -s DEBUG := -g LDDEBUG := -g INIT := -D USE_VM_INIT MATH64 := -D HAVE_INT64 ADDR64 := -D USE_INT64 -D USE_ADDR64 ifeq ($(CC),g++) STDC := -std=c++11 -fno-common else STDC := -std=c99 -fno-common endif LIBS := # A few values are OS-dependent. If we're running on Windows, we add # Intel-specific optimizations and Windows-specific libraries. Unix does # not need any additional library specifications. ifeq ($(OPSYS),Win) OPTIMIZE := $(OPTIMIZE) -march=prescott -mtune=core2 LIBS := -ladvapi32 -lwsock32 -lwinmm endif # Set the compiler warnings. A few values are specific to gcc vs. clang. # Separate warnings are used for SCP 3.x and 4.x because the latter is in # worse shape. MAX_WARNINGS := -Werror -Wpedantic -Wall -Wextra \ -Wno-parentheses -Wno-unused-parameter \ -Wno-missing-field-initializers \ -Wredundant-decls \ -Wmissing-declarations -Wcast-qual HP_WARNINGS := -Werror -Wpedantic -Wall -Wextra \ -Wno-parentheses -Wno-unused-parameter \ -Wno-missing-field-initializers \ -Wredundant-decls \ -Wmissing-declarations -Wcast-qual HP_EXCEPTIONS := -Wno-error=unused-macros -Wno-error=unused-variable \ -Wno-error=unused-const-variable SCP3_WARNINGS := -Wpedantic -Wall -Wextra \ -Wno-parentheses -Wno-unused-parameter \ -Wno-missing-field-initializers SCP4_WARNINGS := -Wall -Wextra \ -Wno-parentheses -Wno-unused-parameter \ -Wno-unused-variable \ -Wno-missing-field-initializers \ -Wno-address -Wno-unused-function -Wno-sign-compare DIST_WARNINGS := -Wno-unused-result ifeq ($(OPSYS),Win) SCP4_WARNINGS := -D HAVE_NTDDDISK_H $(SCP4_WARNINGS) DIST_WARNINGS := -D HAVE_NTDDDISK_H $(DIST_WARNINGS) else ifeq ($(OPSYS),Unix) HP_WARNINGS := -D HAVE_SEMAPHORE $(HP_WARNINGS) -Wno-pointer-sign SCP4_WARNINGS := -D HAVE_SEMAPHORE -D SIM_HAVE_DLOPEN=so $(SCP4_WARNINGS) SCP3_WARNINGS := -D HAVE_SEMAPHORE -D SIM_HAVE_DLOPEN=so $(SCP3_WARNINGS) ifeq (CYGWIN,$(findstring CYGWIN,$(shell uname))) MAX_WARNINGS := $(MAX_WARNINGS) -Wno-error HP_WARNINGS := $(HP_WARNINGS) -Wno-error SCP3_WARNINGS := $(SCP3_WARNINGS) -Wno-char-subscripts -Wno-pedantic SCP4_WARNINGS := $(SCP4_WARNINGS) -Wno-char-subscripts endif endif # Add clang-only warnings. ifeq ($(CC),clang) MAX_WARNINGS := $(MAX_WARNINGS) -Wno-unused-const-variable \ -fno-caret-diagnostics -fno-color-diagnostics \ -fmessage-length=0 HP_WARNINGS := $(HP_WARNINGS) -Wno-unused-const-variable \ -fno-caret-diagnostics -fno-color-diagnostics \ -fmessage-length=0 # Otherwise add (assumed) gcc-only warnings. else ifneq ($(CC),g++) MAX_WARNINGS := $(MAX_WARNINGS) -Wmissing-prototypes HP_WARNINGS := $(HP_WARNINGS) -Wmissing-prototypes endif ifeq ($(OPSYS),Win) MAX_WARNINGS := $(MAX_WARNINGS) -Wno-pedantic-ms-format HP_WARNINGS := $(HP_WARNINGS) -Wno-pedantic-ms-format SCP4_WARNINGS := $(SCP4_WARNINGS) -Wno-pedantic-ms-format endif # Check for warning options that are present only in relatively new versions. WARNING_SET := $(filter -W%,$(shell $(CC) -v --help 2>&1)) ifneq ($(findstring -Wlogical-op,$(WARNING_SET)),) NEW_HP_WARNINGS := $(NEW_HP_WARNINGS) -Wlogical-op endif ifneq ($(findstring -Wdouble-promotion,$(WARNING_SET)),) NEW_HP_WARNINGS := $(NEW_HP_WARNINGS) -Wdouble-promotion endif ifneq ($(findstring -Wimplicit-fallthrough,$(WARNING_SET)),) NEW_HP_WARNINGS := $(NEW_HP_WARNINGS) -Wimplicit-fallthrough=2 NEW_SCP_WARNINGS := $(NEW_SCP_WARNINGS) -Wimplicit-fallthrough=2 endif MAX_WARNINGS := $(MAX_WARNINGS) $(NEW_HP_WARNINGS) HP_WARNINGS := $(HP_WARNINGS) $(NEW_HP_WARNINGS) SCP3_WARNINGS := $(SCP3_WARNINGS) $(NEW_SCP_WARNINGS) SCP4_WARNINGS := $(SCP4_WARNINGS) -Wno-maybe-uninitialized -Wno-clobbered \ -Wno-unused-but-set-variable $(NEW_SCP_WARNINGS) endif endif # Set up the compilation variables, based on the build to perform. The build # is "debug" or "release" if that is the current goal. If the goal is "check" # or "dist", then the build is "release". If the goal is anything else, # including an empty goal, then the build is the previous build specified by # LASTBUILD, or if if LASTBUILD is empty, then the build is "release". # # ACTION is used to force a rebuild of the executable if a goal is specified, # even if it is the same goal as the last build. ifneq ($(or $(findstring debug,$(MAKECMDGOALS)), $(findstring release,$(MAKECMDGOALS))),) BUILD := $(MAKECMDGOALS) ACTION := rebuild else ifneq ($(or $(findstring check,$(MAKECMDGOALS)), $(findstring dist,$(MAKECMDGOALS))),) BUILD := release ACTION := else ifneq ($(LASTBUILD),) BUILD := $(strip $(LASTBUILD)) ACTION := else BUILD := release ACTION := rebuild endif # The goal to build the simulator must be either "debug" or "release". It may # optionally have suffixes "-32" to use 32-bit (vs. 64-bit) arithmetic, or "-64" # to enable large address support. HP debug builds apply error exceptions for # unused macros and variables, as these may be temporary conditions. ifneq ($(findstring release,$(BUILD)),) OBJDIR := Release CCFLAGS := $(OPTIMIZE) $(STDC) $(INIT) LLFLAGS := $(LDOPT) EXENAME := $(MACHINE) else ifneq ($(findstring debug,$(BUILD)),) OBJDIR := Debug CCFLAGS := $(DEBUG) $(STDC) $(INIT) LLFLAGS := $(LDDEBUG) EXENAME := $(MACHINE)d HP_WARNINGS := $(HP_WARNINGS) $(HP_EXCEPTIONS) endif ifneq ($(or $(findstring -32,$(BUILD)), $(findstring -32,$(MAKECMDGOALS))),) OBJDIR := $(OBJDIR)-32 EXENAME := $(EXENAME)-32 else ifneq ($(or $(findstring -64,$(BUILD)), $(findstring -64,$(MAKECMDGOALS))),) OBJDIR := $(OBJDIR)-64 EXENAME := $(EXENAME)-64 CCFLAGS := $(CCFLAGS) $(MATH64) $(ADDR64) else CCFLAGS := $(CCFLAGS) $(MATH64) endif # The SIMH distribution makefile builds with essentially no warnings requested. # Invoking this makefile with the "dist" target will use the distribution # warning set to confirm that the simulator will build cleanly. ifneq ($(findstring dist,$(MAKECMDGOALS)),) SCP4_WARNINGS := $(DIST_WARNINGS) ifeq ($(CC),cl) HP_WARNINGS := $(DIST_WARNINGS) else HP_WARNINGS := endif endif # We must compile the SCP files with a looser set of warnings enabled (because # there are a bunch of them). If the SCP directory contains the file # "scp_help.h", then assume that we're compiling a 4.x simh-master checkout, # which means that we must compile the SCP files with an even looser set of # warnings enabled. ifneq ($(wildcard $(SCPDIR)/scp_help.h),) SIMH_CFLAGS := $(CCFLAGS) $(CFLAGS) $(SCP4_WARNINGS) $(WARNINGS) $(INCLUDES) else SIMH_CFLAGS := $(CCFLAGS) $(CFLAGS) $(SCP3_WARNINGS) $(WARNINGS) $(INCLUDES) endif # If the name of the machine subdirectory contains "HP", then we can use a # stricter set of warnings, unless the goal is "check," in which case we use # the strictest set of warnings. Otherwise, use the same loose set as we use # for SCP. ifneq ($(findstring HP,$(MACHINE)),) ifneq ($(findstring check,$(MAKECMDGOALS)),) SCPX_CFLAGS := $(CCFLAGS) $(CFLAGS) $(MAX_WARNINGS) $(WARNINGS) $(INCLUDES) else SCPX_CFLAGS := $(CCFLAGS) $(CFLAGS) $(HP_WARNINGS) $(WARNINGS) $(INCLUDES) endif MACH_CFLAGS := $(SCPX_CFLAGS) else SCPX_CFLAGS := $(SIMH_CFLAGS) MACH_CFLAGS := $(SIMH_CFLAGS) endif ALL_LDFLAGS := $(LLFLAGS) $(LDFLAGS) # Set the shell support commands, depending on the shell used. ifeq ($(SH),sh) Q := ' NULLCMD := eval VPATH := $(OBJDIR):$(SCPDIR):$(MACHDIR) else ifeq ($(SH),cmd) Q := " NULLCMD := rem VPATH := $(OBJDIR);$(SCPDIR);$(MACHDIR) endif # SCP and machine files. # # SIMH versions < 4.0 do not require "sim_ether.c". Later versions require # it but must exclude the standalone program "sim_BuildROMs.c". In either # version, the standalone program "txt2cbn.c" must be excluded. # # The existence of "scp_help.h" indicates version 4.0 or later. ifneq ($(wildcard $(SCPDIR)/scp_help.h),) UNUSED := $(SCPDIR)/sim_BuildROMs.c $(SCPDIR)/sim_frontpanel.c $(SCPDIR)/PDP11/txt2cbn.c else UNUSED := $(SCPDIR)/sim_ether.c $(SCPDIR)/PDP11/txt2cbn.c $(SCPDIR)/HP3000/hp3000_cpu_apl.c endif SRCFILES := $(filter-out $(UNUSED),$(wildcard $(SCPDIR)/*.c) $(wildcard $(MACHDIR)/*.c)) OBJFILES := $(addprefix $(OBJDIR)/,$(notdir $(SRCFILES:.c=$(OBJEXT)))) DEPFILES := $(SRCFILES:.c=.d) ## $(info SRCFILES is $(SRCFILES)) ## $(error Stopping...) # If a C source file base name was specified as the target, the ASMFILE # variable will be set to the path name of the file. Otherwise, it will be # null. ASMFILE := $(strip $(filter $(SCPDIR)/$(MAKECMDGOALS).c, $(SRCFILES)) \ $(filter $(MACHDIR)/$(MAKECMDGOALS).c, $(SRCFILES))) # Build targets. # # The ASMFILE name is not listed as a phony target so that make will report "No # rule to make..." if the specified target is not a source filename. Listing # it as a phony target would report "Nothing to be done for..." instead. # # "scp" must be present for "make scp" to compile scp.c into an assembler file. # This is because SCP is a subdirectory name and so is always up to date. .PHONY : debug debug-32 debug-64 \ release release-32 release-64 \ check check-32 check-64 \ dist dist-32 dist-64 \ list list-32 list-64 list-check list-dist \ clean buildsim rebuild all \ scp debug debug-32 debug-64 release release-32 release-64 \ check check-32 check-64 dist dist-32 dist-64: makedir buildsim # List the variable definitions. The null command is needed to suppress a # "Nothing to be done for 'list'" warning. It must be placed before the "info" # calls, or a "recipe commences before first target" error occurs. list list-32 list-64 list-check list-dist: @$(NULLCMD) ifneq ($(findstring list,$(MAKECMDGOALS)),) $(info ) $(info SCP3_WARNINGS = $(SCP3_WARNINGS)) $(info ) $(info SCP4_WARNINGS = $(SCP4_WARNINGS)) $(info ) $(info HP_WARNINGS = $(HP_WARNINGS)) $(info ) $(info SIMH_CFLAGS = $(SIMH_CFLAGS)) $(info ) $(info SCPX_CFLAGS = $(SCPX_CFLAGS)) $(info ) $(info MACH_CFLAGS = $(MACH_CFLAGS)) $(info ) $(info MACHINE = $(MACHINE)) $(info OPSYS = $(OPSYS)) $(info SH = $(SH)) $(info CC = $(CC)) $(info VPATH = $(VPATH)) $(info OBJDIR = $(OBJDIR)) $(info EXENAME = $(EXENAME)) $(info ) $(info OPTIMIZE = $(OPTIMIZE)) $(info DEBUG = $(DEBUG)) $(info CCFLAGS = $(CCFLAGS)) $(info LLFLAGS = $(LLFLAGS)) $(info WARNINGS = $(WARNINGS)) $(info CFLAGS = $(CFLAGS)) $(info LDFLAGS = $(LDFLAGS)) $(info LIBS = $(LIBS)) $(info UNUSED = $(UNUSED)) endif clean : ifeq ($(SH),cmd) @if not "$(DELFILES)" == "" del $(subst /,\,$(DELFILES)) @for /d %%n in (*) do if exist %%n\*$(OBJEXT) del %%n\*$(OBJEXT) ifeq ($(CC),cl) @if exist $(EXEDIR)\*.ilk del $(EXEDIR)\*.ilk @if exist $(EXEDIR)\*.pdb del $(EXEDIR)\*.pdb else @if exist $(SCPDIR)\*.d del $(SCPDIR)\*.d @if exist $(MACHDIR)\*.d del $(subst /,\,$(MACHDIR)/*.d) endif # We want to remove all object files from all subdirectories, but we seem to # have to specify each directory explicitly. "rm -rf *.o" only removes files # in the current directory and any directories ending with ".o". "ls -dR *" # lists only top-level files and directories. There doesn't seem to be a clean # way to do "del /s *.o" as there is in Windows! else ifeq ($(SH),sh) @if [ -n "$(DELFILES)" ]; then rm $(DELFILES); fi @rm -rf Debug/*.o Debug-32/*.o Debug-64/*.o Release/*.o Release-32/*.o Release-64/*.o @rm -f $(SCPDIR)/*.d @rm -f $(MACHDIR)/*.d endif makedir : ifeq ($(SH),cmd) @if not exist $(OBJDIR)\nul mkdir $(OBJDIR) else ifeq ($(SH),sh) @if [ ! -d $(OBJDIR) ]; then mkdir $(OBJDIR); fi endif rebuild : buildsim : $(EXEDIR)/$(EXENAME)$(EXEEXT) @echo LASTBUILD := $(BUILD) > $(EXEDIR)/makefile.in @echo LASTMACHINE := $(MACHINE) >> $(EXEDIR)/makefile.in all : $(MACHINES) @for %%j in (release debug) do for %%i in ($(MACHINES)) do $(MAKE) %%j MACHINE=%%i # Build rules. $(OBJDIR)/%$(OBJEXT) : $(SCPDIR)/%.c $(CC) $(COMPILE) $(SIMH_CFLAGS) $(COMPOUT)$(OBJDIR)/$(@F) $< $(OBJDIR)/sim_extension.o : $(SCPDIR)/sim_extension.c $(CC) $(COMPILE) $(SCPX_CFLAGS) $(COMPOUT)$(OBJDIR)/$(@F) $< $(OBJDIR)/sim_serial.o : $(SCPDIR)/sim_serial.c $(CC) $(COMPILE) $(SCPX_CFLAGS) $(COMPOUT)$(OBJDIR)/$(@F) $< $(OBJDIR)/%$(OBJEXT) : $(MACHDIR)/%.c $(CC) $(COMPILE) $(MACH_CFLAGS) $(COMPOUT)$(OBJDIR)/$(@F) $< $(EXEDIR)/$(EXENAME)$(EXEEXT) : $(OBJFILES) $(ACTION) $(LD) $(LINK) $(ALL_LDFLAGS) $(LINKOUT)$@ $(OBJFILES) $(TARGLIB) $(LIBS) # Build rule for compiling to assembler source. # # If the target is the base name of a C source file, it is given a rule here, # so that the compiler will be invoked with the proper options. This is # conditional on ASMFILE not being null. Otherwise, a legitimate target, such # as "debug", would wind up with a duplicate rule here. ifneq ($(ASMFILE), ) $(MAKECMDGOALS) : $(CC) $(ASSEMBLE) $(OPTIMIZE) $(INIT) $(MATH64) $(INCLUDES) $(ASMFILE) endif # Dependency generation for gcc only. Do not generate dependencies if the # goal is "clean" or "list." ifeq ($(CC),gcc) %.d: %.c $(CC) -MM -MT $(Q)$$(OBJDIR)/$(basename $(notdir $@))$(OBJEXT) $@$(Q) $(INCLUDES) -MF $@ $< ifeq ($(findstring $(MAKECMDGOALS),clean list),) -include $(DEPFILES) endif endif