Sat, 17 Nov 2012 19:18:29 +0000
add HDD support + fixes
Patch-Author: Andrew Warkentin <andreww591!gmail>
Patch-Message-ID: <50A772FC.8020009@gmail.com>
I have added floppy write support, full hard disk emulation, and proper handling of DMA page faults to FreeBee. I also fixed the floppy step commands, changed the "force interrupt" floppy command to generate a type 1 status, and changed the DMA address counter to reset to 3fff when a transfer completes (which is what Unix seems to expect - without it, the kernel says that the floppy isn't ready). The floppy, hard disk, and DMA page fault tests all pass. Initializing hard disks and floppies also works (the geometry for both is still fixed by the size of the image, though, and format commands only appear to succeed, but they don't modify the image). Unix still doesn't run, though (it hangs after reading some sectors from the floppy).
philpem@0 | 1 | # Phil's multiplatform makefile template |
philpem@0 | 2 | # With auto-incrementing build number and automatic version.h generation |
philpem@14 | 3 | # Version 1.9, 2010-02-15 |
philpem@0 | 4 | # |
philpem@0 | 5 | # The latest version of this Makefile can be found at http://www.philpem.me.uk/ |
philpem@0 | 6 | # |
philpem@0 | 7 | # |
philpem@0 | 8 | # Copyright (c) 2010 Philip Pemberton <code@philpem.me.uk> |
philpem@0 | 9 | # |
philpem@0 | 10 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
philpem@0 | 11 | # of this software and associated documentation files (the "Software"), to deal |
philpem@0 | 12 | # in the Software without restriction, including without limitation the rights |
philpem@0 | 13 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
philpem@0 | 14 | # copies of the Software, and to permit persons to whom the Software is |
philpem@0 | 15 | # furnished to do so, subject to the following conditions: |
philpem@0 | 16 | # |
philpem@0 | 17 | # The above copyright notice and this permission notice shall be included in |
philpem@0 | 18 | # all copies or substantial portions of the Software. |
philpem@0 | 19 | # |
philpem@0 | 20 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
philpem@0 | 21 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
philpem@0 | 22 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
philpem@0 | 23 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
philpem@0 | 24 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
philpem@0 | 25 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
philpem@0 | 26 | # THE SOFTWARE. |
philpem@0 | 27 | # |
philpem@0 | 28 | # |
philpem@0 | 29 | # Instructions for use: |
philpem@0 | 30 | # Run 'make init' to create the required directories |
philpem@0 | 31 | # Add your source files to the 'SOURCES' list, and change the TARGET filename |
philpem@0 | 32 | # Set the desired build type and platform in the BUILD_TYPE and PLATFORM |
philpem@0 | 33 | # variables respectively |
philpem@0 | 34 | # Set your project type (C only, or C++) in the SRC_TYPE variable |
philpem@0 | 35 | # Add any libraries you need to link against to the 'LIB' list |
philpem@0 | 36 | # Run 'make' |
philpem@0 | 37 | # |
philpem@0 | 38 | # Object files are created in the 'obj' subdirectory, from source code in the |
philpem@0 | 39 | # 'src' directory. Dependency files are created in the 'dep' directory from |
philpem@0 | 40 | # the same source code the object files are created from. |
philpem@0 | 41 | # |
philpem@0 | 42 | # Supported targets are: |
philpem@0 | 43 | # all Build everything. |
philpem@0 | 44 | # update-revision Increment the build number without building anything. |
philpem@0 | 45 | # clean-versioninfo Delete src/version.h (will be rebuilt on the next |
philpem@0 | 46 | # 'make all'). |
philpem@0 | 47 | # init Initialise the build system for a new project. |
philpem@0 | 48 | # WARNING: overwrites .buildnum and src/version.h.in! |
philpem@0 | 49 | # cleandep Delete all dependency files. |
philpem@0 | 50 | # clean Delete all dependency, intermediate and target files. |
philpem@0 | 51 | # tidy Delete all dependency and intermediate files, leaving |
philpem@0 | 52 | # the target file intact. |
philpem@0 | 53 | # |
philpem@0 | 54 | # If you want to reset the build number to zero, delete '.buildnum'. This |
philpem@0 | 55 | # should be done whenever the major or minor version changes. Excluding |
philpem@0 | 56 | # .buildnum from version control may also be a good idea, depending on how |
philpem@0 | 57 | # you want your build numbers to work. |
philpem@0 | 58 | # |
philpem@0 | 59 | # The BUILD_TYPE variable contains the current build type. There are two |
philpem@0 | 60 | # supported build types: |
philpem@0 | 61 | # debug Debug mode - object files are compiled with debug information |
philpem@0 | 62 | # and the target is left unstripped. |
philpem@0 | 63 | # release Release mode - object files are not compiled with debug info, |
philpem@0 | 64 | # and the target is fed through strip to remove redundant |
philpem@0 | 65 | # data. |
philpem@0 | 66 | # |
philpem@0 | 67 | # The PLATFORM variable contains the current target platform. There are two |
philpem@0 | 68 | # supported platforms: |
philpem@0 | 69 | # linux GNU/Linux with GNU Compiler Collection |
philpem@0 | 70 | # win32 Windows 32-bit with MinGW |
philpem@0 | 71 | # |
philpem@0 | 72 | # The EXTSRC variable is used to specify other files to build. It is typically |
philpem@0 | 73 | # used to specify platform or build-type specific source files, e.g. |
philpem@0 | 74 | # |
philpem@0 | 75 | # ifeq ($(BUILD_TYPE),debug-memwatch) |
philpem@0 | 76 | # CFLAGS += -g -ggdb |
philpem@0 | 77 | # CPPFLAGS += -DMEMWATCH |
philpem@0 | 78 | # INCPATH += ./memwatch |
philpem@0 | 79 | # EXTSRC += memwatch/memwatch.c |
philpem@0 | 80 | # endif |
philpem@0 | 81 | # |
philpem@0 | 82 | # (example taken from one of my projects that allowed the use of Memwatch to |
philpem@0 | 83 | # track down memory allocation/deallocation bugs) |
philpem@0 | 84 | # |
philpem@0 | 85 | # |
philpem@0 | 86 | # Change history: |
philpem@14 | 87 | # 1.9 - Bugfix -- if CFLAGS contained a forward-slash, sed would fall over. |
philpem@14 | 88 | # Also added SDL support and fixed the date/time formats. To use SDL, |
philpem@14 | 89 | # set ENABLE_SDL to "yes". |
philpem@0 | 90 | # 1.8 - Now supports the use of the wxWidgets GUI framework. To turn |
philpem@0 | 91 | # this on, set ENABLE_WX to "yes". |
philpem@0 | 92 | # 1.7 - Now creates a basic Hgignore file and directory keepers for the |
philpem@0 | 93 | # dep and obj directories. |
philpem@0 | 94 | # 1.6 - Added CFLAGS and CXXFLAGS to the command-lines for the dependency |
philpem@0 | 95 | # building commands. This was causing issues with C99 / C++0x mode. |
philpem@0 | 96 | # 1.5 - Added support for Mercurial revision (changeset ID) display |
philpem@0 | 97 | # Fixed a few issues with Subversion support (svn: and version 0 would |
philpem@0 | 98 | # be displayed for exported code) |
philpem@0 | 99 | # |
philpem@0 | 100 | |
philpem@0 | 101 | #### |
philpem@0 | 102 | # Build configuration |
philpem@0 | 103 | #### |
philpem@0 | 104 | |
philpem@0 | 105 | # version information -- major.minor.extra |
philpem@0 | 106 | # note that VER_EXTRA can be overridden on the command line, e.g.: |
philpem@0 | 107 | # make VER_EXTRA=12345 all |
philpem@0 | 108 | VER_MAJOR = 0 |
philpem@0 | 109 | VER_MINOR = 0 |
philpem@0 | 110 | VER_EXTRA ?= |
philpem@0 | 111 | |
philpem@0 | 112 | # build platform: win32 or linux |
philpem@0 | 113 | PLATFORM ?= linux |
philpem@0 | 114 | # build type: release or debug |
philpem@0 | 115 | BUILD_TYPE ?= debug |
philpem@0 | 116 | |
philpem@0 | 117 | # target executable |
philpem@6 | 118 | TARGET = freebee |
philpem@0 | 119 | |
philpem@0 | 120 | # source files that produce object files |
philpem@112 | 121 | SRC = main.c state.c memory.c wd279x.c wd2010.c keyboard.c |
philpem@18 | 122 | SRC += musashi/m68kcpu.c musashi/m68kdasm.c musashi/m68kops.c musashi/m68kopac.c musashi/m68kopdm.c musashi/m68kopnz.c |
philpem@0 | 123 | |
philpem@0 | 124 | # source type - either "c" or "cpp" (C or C++) |
philpem@0 | 125 | SRC_TYPE = c |
philpem@0 | 126 | |
philpem@0 | 127 | # additional object files that don't necessarily include source |
philpem@0 | 128 | EXT_OBJ = |
philpem@0 | 129 | # libraries to link in -- these will be specified as "-l" parameters, the -l |
philpem@0 | 130 | # is prepended automatically |
philpem@3 | 131 | LIB = |
philpem@0 | 132 | # library paths -- where to search for the above libraries |
philpem@3 | 133 | LIBPATH = |
philpem@0 | 134 | # include paths -- where to search for #include files (in addition to the |
philpem@0 | 135 | # standard paths |
philpem@3 | 136 | INCPATH = |
philpem@0 | 137 | # garbage files that should be deleted on a 'make clean' or 'make tidy' |
philpem@0 | 138 | GARBAGE = obj/musashi/m68kmake obj/musashi/m68kmake.exe obj/musashi/m68kmake.o |
philpem@0 | 139 | |
philpem@0 | 140 | # extra dependencies - files that we don't necessarily know how to build, but |
philpem@0 | 141 | # that are required for building the application; e.g. object files or |
philpem@0 | 142 | # libraries in sub or parent directories |
philpem@0 | 143 | EXTDEP = |
philpem@0 | 144 | |
philpem@0 | 145 | # Extra libraries |
philpem@0 | 146 | # wxWidgets: set to "yes" to enable, anything else to disable |
philpem@0 | 147 | ENABLE_WX = no |
philpem@0 | 148 | # wxWidgets: list of wxWidgets libraries to enable |
philpem@0 | 149 | WX_LIBS = std |
philpem@3 | 150 | # SDL: set to "yes" to enable, anything else to disable |
philpem@3 | 151 | ENABLE_SDL = yes |
philpem@0 | 152 | |
philpem@0 | 153 | #### |
philpem@0 | 154 | # Win32 target-specific settings |
philpem@0 | 155 | #### |
philpem@0 | 156 | ifeq ($(strip $(PLATFORM)),win32) |
philpem@0 | 157 | # windows executables have a .exe suffix |
philpem@0 | 158 | TARGET := $(addsuffix .exe,$(TARGET)) |
philpem@0 | 159 | # console mode application |
philpem@0 | 160 | EXT_CFLAGS = -mconsole |
philpem@0 | 161 | endif |
philpem@0 | 162 | |
philpem@0 | 163 | |
philpem@0 | 164 | #### |
philpem@0 | 165 | # Tool setup |
philpem@0 | 166 | #### |
philpem@0 | 167 | MAKE = make |
philpem@0 | 168 | CC = gcc |
philpem@0 | 169 | CXX = g++ |
philpem@0 | 170 | CFLAGS = -Wall -pedantic -std=gnu99 $(EXT_CFLAGS) |
philpem@0 | 171 | CXXFLAGS= -Wall -pedantic -std=gnu++0x $(EXT_CXXFLAGS) |
philpem@0 | 172 | LDFLAGS = $(EXT_LDFLAGS) |
philpem@0 | 173 | RM = rm |
philpem@0 | 174 | STRIP = strip |
philpem@0 | 175 | |
philpem@0 | 176 | ############################################################################### |
philpem@0 | 177 | # You should not need to touch anything below here, unless you're adding a new |
philpem@0 | 178 | # platform or build type (or changing the version string format) |
philpem@0 | 179 | ############################################################################### |
philpem@0 | 180 | |
philpem@0 | 181 | #### |
philpem@0 | 182 | # A quick sanity check on the platform type |
philpem@0 | 183 | #### |
philpem@0 | 184 | ifneq ($(PLATFORM),linux) |
philpem@0 | 185 | ifneq ($(PLATFORM),win32) |
philpem@0 | 186 | $(error Platform '$(PLATFORM)' not supported. Supported platforms are: linux, win32) |
philpem@0 | 187 | endif |
philpem@0 | 188 | endif |
philpem@0 | 189 | |
philpem@0 | 190 | #### |
philpem@0 | 191 | # Version info generation |
philpem@0 | 192 | #### |
philpem@0 | 193 | # get the current build number |
philpem@0 | 194 | VER_BUILDNUM = $(shell cat .buildnum) |
philpem@0 | 195 | |
philpem@0 | 196 | #### --- begin Subversion revision grabber --- |
philpem@0 | 197 | # there are two ways to get the SVN revision - use svnversion, or use svn info |
philpem@0 | 198 | # then pipe through awk. which one you use is up to you. |
philpem@0 | 199 | VER_SVNREV = $(shell LANG=C svn info 2>/dev/null || echo 'Revision: exported' | awk '/^Revision:/ { print$$2 }' ) |
philpem@0 | 200 | #VER_SVNREV = $(shell svnversion .) |
philpem@0 | 201 | |
philpem@0 | 202 | # if the version string is "exported", then the CSD was not checked out of SVN |
philpem@0 | 203 | # note that if the CSD is not an SVN checkout, then @@svnrev@@ will be set to |
philpem@0 | 204 | # zero. |
philpem@0 | 205 | ifeq ($(VER_SVNREV),exported) |
philpem@0 | 206 | VER_VCS = none |
philpem@0 | 207 | VER_VCSREV = 0 |
philpem@0 | 208 | else |
philpem@0 | 209 | VER_VCS = svn |
philpem@0 | 210 | VER_VCSREV = $(VER_SVNREV) |
philpem@0 | 211 | endif |
philpem@0 | 212 | |
philpem@0 | 213 | #### --- begin Mercurial revision grabber --- |
philpem@0 | 214 | # If SVN didn't give us a revision, try Mercurial instead |
philpem@0 | 215 | ifeq ($(VER_VCS),none) |
philpem@0 | 216 | # get the current Mercurial changeset number |
philpem@0 | 217 | VER_HGREV=$(shell ((hg tip --template "{node|short}") || echo "000000000000") 2>/dev/null) |
philpem@0 | 218 | ifneq ($(VER_HGREV),000000000000) |
philpem@0 | 219 | # a non-empty repo |
philpem@0 | 220 | VER_VCS = hg |
philpem@0 | 221 | VER_VCSREV = $(VER_HGREV) |
philpem@0 | 222 | else |
philpem@0 | 223 | # either an empty Hg repo, or no repo at all |
philpem@0 | 224 | VER_VCS = none |
philpem@0 | 225 | VER_VCSREV = 0 |
philpem@0 | 226 | endif |
philpem@0 | 227 | endif |
philpem@0 | 228 | |
philpem@0 | 229 | #### --- end version grabbers --- |
philpem@0 | 230 | |
philpem@0 | 231 | # start creating the revision string |
philpem@0 | 232 | VER_FULLSTR = $(VER_MAJOR).$(VER_MINOR).$(VER_BUILDNUM)$(VER_EXTRA) |
philpem@0 | 233 | |
philpem@0 | 234 | # if this is a VCS release, include the SVN revision in the version string |
philpem@0 | 235 | # also create a revision string that is either "svn:12345", "hg:12345" or |
philpem@0 | 236 | # blank |
philpem@0 | 237 | ifneq ($(VER_VCS),none) |
philpem@0 | 238 | VER_FULLSTR += ($(VER_VCS) $(VER_VCSREV)) |
philpem@0 | 239 | VER_VCSSTR = $(VER_VCS):$(VER_VCSREV) |
philpem@0 | 240 | else |
philpem@0 | 241 | VER_VCSSTR = |
philpem@0 | 242 | endif |
philpem@0 | 243 | |
philpem@0 | 244 | |
philpem@0 | 245 | #### |
philpem@0 | 246 | # Build-type specific configuration |
philpem@0 | 247 | #### |
philpem@0 | 248 | ifeq ($(BUILD_TYPE),debug) |
philpem@0 | 249 | CFLAGS += -g -ggdb -DDEBUG |
philpem@0 | 250 | CXXFLAGS += -g -ggdb -DDEBUG |
philpem@0 | 251 | else |
philpem@0 | 252 | ifeq ($(BUILD_TYPE),release) |
philpem@0 | 253 | CFLAGS += -O2 |
philpem@0 | 254 | CXXFLAGS += -O2 |
philpem@0 | 255 | else |
philpem@0 | 256 | $(error Unsupported build type: '$(BUILD_TYPE)') |
philpem@0 | 257 | endif |
philpem@0 | 258 | endif |
philpem@0 | 259 | |
philpem@0 | 260 | #### |
philpem@0 | 261 | # wxWidgets support |
philpem@0 | 262 | #### |
philpem@0 | 263 | ifeq ($(ENABLE_WX),yes) |
philpem@0 | 264 | ifeq ($(BUILD_TYPE),debug) |
philpem@0 | 265 | LIBLNK += `wx-config --debug --libs $(WX_LIBS)` |
philpem@0 | 266 | CFLAGS += `wx-config --debug --cflags $(WX_LIBS)` |
philpem@0 | 267 | CXXFLAGS += `wx-config --debug --cxxflags $(WX_LIBS)` |
philpem@0 | 268 | CPPFLAGS += `wx-config --debug --cppflags $(WX_LIBS)` |
philpem@0 | 269 | else |
philpem@0 | 270 | ifeq ($(BUILD_TYPE),release) |
philpem@0 | 271 | LIBLNK += `wx-config --libs $(WX_LIBS)` |
philpem@0 | 272 | CFLAGS += `wx-config --cflags $(WX_LIBS)` |
philpem@0 | 273 | CPPFLAGS += `wx-config --cppflags $(WX_LIBS)` |
philpem@0 | 274 | CXXFLAGS += `wx-config --cxxflags $(WX_LIBS)` |
philpem@0 | 275 | else |
philpem@0 | 276 | $(error Unsupported build type: '$(BUILD_TYPE)') |
philpem@0 | 277 | endif |
philpem@0 | 278 | endif |
philpem@0 | 279 | endif |
philpem@0 | 280 | |
philpem@0 | 281 | #### |
philpem@3 | 282 | # SDL support |
philpem@3 | 283 | #### |
philpem@3 | 284 | ifeq ($(ENABLE_SDL),yes) |
philpem@13 | 285 | LIBLNK += $(shell sdl-config --libs) |
philpem@13 | 286 | CFLAGS += $(shell sdl-config --cflags) |
philpem@3 | 287 | endif |
philpem@3 | 288 | |
philpem@3 | 289 | |
philpem@3 | 290 | #### |
philpem@0 | 291 | # rules |
philpem@0 | 292 | #### |
philpem@0 | 293 | |
philpem@0 | 294 | # object files |
philpem@0 | 295 | OBJ = $(addprefix obj/, $(addsuffix .o, $(basename $(SRC))) $(EXT_OBJ)) $(addsuffix .o, $(basename $(EXTSRC))) |
philpem@0 | 296 | |
philpem@0 | 297 | # dependency files |
philpem@0 | 298 | DEPFILES = $(addprefix dep/, $(addsuffix .d, $(basename $(SRC))) $(EXT_OBJ)) $(addsuffix .d, $(basename $(EXTSRC))) |
philpem@0 | 299 | |
philpem@0 | 300 | # path commands |
philpem@0 | 301 | LIBLNK += $(addprefix -l, $(LIB)) |
philpem@0 | 302 | LIBPTH += $(addprefix -L, $(LIBPATH)) |
philpem@0 | 303 | INCPTH += $(addprefix -I, $(INCPATH)) |
philpem@0 | 304 | |
philpem@0 | 305 | CPPFLAGS += $(INCPTH) |
philpem@0 | 306 | |
philpem@0 | 307 | #### |
philpem@0 | 308 | # Make sure there is at least one object file to be linked in |
philpem@0 | 309 | #### |
philpem@0 | 310 | ifeq ($(strip $(OBJ)),) |
philpem@0 | 311 | $(error Unable to build: no object or source files specified in Makefile) |
philpem@0 | 312 | endif |
philpem@0 | 313 | |
philpem@0 | 314 | #### |
philpem@0 | 315 | # targets |
philpem@0 | 316 | #### |
philpem@0 | 317 | .PHONY: default all update-revision versionheader clean-versioninfo init cleandep clean tidy |
philpem@0 | 318 | |
philpem@0 | 319 | all: update-revision |
philpem@0 | 320 | @$(MAKE) versionheader |
philpem@0 | 321 | $(MAKE) $(TARGET) |
philpem@0 | 322 | |
philpem@0 | 323 | # increment the current build number |
philpem@0 | 324 | NEWBUILD=$(shell expr $(VER_BUILDNUM) + 1) |
philpem@0 | 325 | update-revision: |
philpem@0 | 326 | @echo $(NEWBUILD) > .buildnum |
philpem@0 | 327 | |
philpem@0 | 328 | versionheader: |
philpem@13 | 329 | @sed -e 's/@@datetime@@/$(shell LC_ALL=C date +"%a %d-%b-%Y %T %Z")/g' \ |
philpem@13 | 330 | -e 's/@@date@@/$(shell LC_ALL=C date +"%a %d-%b-%Y")/g' \ |
philpem@13 | 331 | -e 's/@@time@@/$(shell LC_ALL=C date +"%T %Z")/g' \ |
philpem@0 | 332 | -e 's/@@whoami@@/$(shell whoami)/g' \ |
philpem@0 | 333 | -e 's/@@hostname@@/$(shell hostname)/g' \ |
philpem@0 | 334 | -e 's|@@compiler@@|$(shell $(CC) $(CFLAGS) -v 2>&1 | tail -n 1 | sed -e "s;|;/;")|g' \ |
philpem@0 | 335 | -e 's/@@majorver@@/$(VER_MAJOR)/g' \ |
philpem@0 | 336 | -e 's/@@minorver@@/$(VER_MINOR)/g' \ |
philpem@0 | 337 | -e 's/@@extraver@@/$(subst \",,$(VER_EXTRA))/g' \ |
philpem@0 | 338 | -e 's/@@buildnum@@/$(VER_BUILDNUM)/g' \ |
philpem@0 | 339 | -e 's/@@buildtype@@/$(BUILD_TYPE)/g' \ |
philpem@0 | 340 | -e 's/@@vcs@@/$(VER_VCS)/g' \ |
philpem@0 | 341 | -e 's/@@vcsrev@@/$(VER_VCSREV)/g' \ |
philpem@0 | 342 | -e 's/@@vcsstr@@/$(VER_VCSSTR)/g' \ |
philpem@0 | 343 | -e 's/@@fullverstr@@/$(VER_FULLSTR)/g' \ |
philpem@14 | 344 | -e 's#@@cflags@@#$(CFLAGS)#g' \ |
philpem@0 | 345 | < src/version.h.in > src/version.h |
philpem@0 | 346 | |
philpem@0 | 347 | # version.h creation stuff based on code from the Xen makefile |
philpem@0 | 348 | clean-versioninfo: |
philpem@0 | 349 | @if [ ! -r src/version.h -o -O src/version.h ]; then \ |
philpem@0 | 350 | rm -f src/version.h; \ |
philpem@0 | 351 | fi |
philpem@0 | 352 | @echo 0 > .buildnum |
philpem@0 | 353 | |
philpem@0 | 354 | # initialise the build system for a new project |
philpem@0 | 355 | init: |
philpem@0 | 356 | @mkdir -p src dep obj |
philpem@0 | 357 | @echo "This file is a directory-keeper. Do not delete it." > dep/.keepme |
philpem@0 | 358 | @echo "This file is a directory-keeper. Do not delete it." > obj/.keepme |
philpem@0 | 359 | @echo 0 > .buildnum |
philpem@0 | 360 | @echo 'syntax: glob' > .hgignore |
philpem@0 | 361 | @echo 'obj/*.o' >> .hgignore |
philpem@0 | 362 | @echo 'dep/*.d' >> .hgignore |
philpem@0 | 363 | @echo '*~' >> .hgignore |
philpem@0 | 364 | @echo '.*.sw?' >> .hgignore |
philpem@13 | 365 | @echo '#define VER_COMPILE_DATETIME "@@datetime@@"' > src/version.h.in |
philpem@14 | 366 | @echo '#define VER_COMPILE_DATE "@@date@@"' >> src/version.h.in |
philpem@14 | 367 | @echo '#define VER_COMPILE_TIME "@@time@@"' >> src/version.h.in |
philpem@14 | 368 | @echo '#define VER_COMPILE_BY "@@whoami@@"' >> src/version.h.in |
philpem@14 | 369 | @echo '#define VER_COMPILE_HOST "@@hostname@@"' >> src/version.h.in |
philpem@14 | 370 | @echo '#define VER_COMPILER "@@compiler@@"' >> src/version.h.in |
philpem@14 | 371 | @echo '#define VER_BUILD_TYPE "@@buildtype@@"' >> src/version.h.in |
philpem@14 | 372 | @echo '#define VER_CFLAGS "@@cflags@@"' >> src/version.h.in |
philpem@14 | 373 | @echo '' >> src/version.h.in |
philpem@14 | 374 | @echo '#define VER_MAJOR @@majorver@@' >> src/version.h.in |
philpem@14 | 375 | @echo '#define VER_MINOR @@minorver@@' >> src/version.h.in |
philpem@14 | 376 | @echo '#define VER_BUILDNUM @@buildnum@@' >> src/version.h.in |
philpem@14 | 377 | @echo '#define VER_EXTRA "@@extraver@@"' >> src/version.h.in |
philpem@14 | 378 | @echo '#define VER_VCSREV "@@vcsstr@@"' >> src/version.h.in |
philpem@14 | 379 | @echo '' >> src/version.h.in |
philpem@14 | 380 | @echo '#define VER_FULLSTR "@@fullverstr@@"' >> src/version.h.in |
philpem@14 | 381 | @echo '' >> src/version.h.in |
philpem@0 | 382 | @echo Build system initialised |
philpem@0 | 383 | |
philpem@0 | 384 | # remove the dependency files |
philpem@0 | 385 | cleandep: |
philpem@0 | 386 | -rm $(DEPFILES) |
philpem@0 | 387 | |
philpem@0 | 388 | # remove the dependency files and any target or intermediate build files |
philpem@0 | 389 | clean: cleandep clean-versioninfo |
philpem@0 | 390 | -rm $(OBJ) $(TARGET) $(GARBAGE) |
philpem@0 | 391 | |
philpem@0 | 392 | # remove any dependency or intermediate build files |
philpem@0 | 393 | tidy: cleandep clean-versioninfo |
philpem@0 | 394 | -rm $(OBJ) $(GARBAGE) |
philpem@0 | 395 | |
philpem@0 | 396 | ################################# |
philpem@0 | 397 | |
philpem@0 | 398 | $(TARGET): $(OBJ) $(EXTDEP) |
philpem@0 | 399 | ifeq ($(SRC_TYPE),c) |
philpem@0 | 400 | $(CC) $(CXXFLAGS) $(LDFLAGS) $(OBJ) $(LIBPTH) $(LIBLNK) -o $@ |
philpem@0 | 401 | else |
philpem@0 | 402 | $(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJ) $(LIBPTH) $(LIBLNK) -o $@ |
philpem@0 | 403 | endif |
philpem@0 | 404 | ifeq ($(BUILD_TYPE),release) |
philpem@0 | 405 | $(STRIP) $(TARGET) |
philpem@0 | 406 | endif |
philpem@0 | 407 | |
philpem@0 | 408 | ### |
philpem@0 | 409 | # extra rules |
philpem@0 | 410 | # example: |
philpem@0 | 411 | #src/parser.c: src/parser.h |
philpem@0 | 412 | |
philpem@0 | 413 | |
philpem@0 | 414 | #### |
philpem@0 | 415 | ## musashi build rules |
philpem@0 | 416 | # 68k CPU builder |
philpem@0 | 417 | obj/musashi/m68kmake: obj/musashi/m68kmake.o |
philpem@0 | 418 | $(CC) $(CFLAGS) $(CPPFLAGS) obj/musashi/m68kmake.o -o $@ |
philpem@0 | 419 | # 68k CPU sources |
philpem@3 | 420 | src/musashi/m68kops.h src/musashi/m68kops.c src/musashi/m68kopac.c src/musashi/m68kopdm.c src/musashi/m68kopnz.c: obj/musashi/m68kmake src/musashi/m68k_in.c |
philpem@0 | 421 | ./obj/musashi/m68kmake src/musashi src/musashi/m68k_in.c |
philpem@0 | 422 | |
philpem@0 | 423 | #### |
philpem@0 | 424 | # make object files from C source files |
philpem@0 | 425 | obj/%.o: src/%.c |
philpem@0 | 426 | $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ |
philpem@0 | 427 | |
philpem@0 | 428 | ## |
philpem@0 | 429 | # make object files from C++ source files |
philpem@0 | 430 | obj/%.o: src/%.cc |
philpem@0 | 431 | $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ |
philpem@0 | 432 | |
philpem@0 | 433 | obj/%.o: src/%.cpp |
philpem@0 | 434 | $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ |
philpem@0 | 435 | |
philpem@0 | 436 | ### |
philpem@0 | 437 | # make C files from yacc/bison source |
philpem@0 | 438 | src/%.h src/%.c: src/%.y |
philpem@0 | 439 | $(YACC) $(YFLAGS) -d $< |
philpem@0 | 440 | mv -f y.tab.c $*.c |
philpem@0 | 441 | mv -f y.tab.h $*.h |
philpem@0 | 442 | |
philpem@0 | 443 | ### |
philpem@0 | 444 | # make C files from lex/flex source |
philpem@0 | 445 | src/%.c: src/%.l |
philpem@0 | 446 | $(LEX) $(LFLAGS) -o$@ $< |
philpem@0 | 447 | |
philpem@0 | 448 | ### |
philpem@0 | 449 | # make dependencies for our source files |
philpem@0 | 450 | dep/%.d: src/%.c |
philpem@0 | 451 | $(CC) -MM $(CFLAGS) $(CPPFLAGS) $< > $@.$$$$; \ |
philpem@0 | 452 | sed 's,\($*\)\.o[ :]*,obj/\1.o $@ : ,g' < $@.$$$$ > $@; \ |
philpem@0 | 453 | rm -f $@.$$$$ |
philpem@0 | 454 | |
philpem@0 | 455 | dep/%.d: src/%.cpp |
philpem@0 | 456 | $(CXX) -MM $(CXXFLAGS) $(CPPFLAGS) $< > $@.$$$$; \ |
philpem@0 | 457 | sed 's,\($*\)\.o[ :]*,obj/\1.o $@ : ,g' < $@.$$$$ > $@; \ |
philpem@0 | 458 | rm -f $@.$$$$ |
philpem@0 | 459 | |
philpem@0 | 460 | dep/%.d: src/%.cc |
philpem@0 | 461 | $(CXX) -MM $(CXXFLAGS) $(CPPFLAGS) $< > $@.$$$$; \ |
philpem@0 | 462 | sed 's,\($*\)\.o[ :]*,obj/\1.o $@ : ,g' < $@.$$$$ > $@; \ |
philpem@0 | 463 | rm -f $@.$$$$ |
philpem@0 | 464 | |
philpem@0 | 465 | #### |
philpem@0 | 466 | # pull in the dependency files, but only for 'make $(TARGET)' |
philpem@0 | 467 | #### |
philpem@0 | 468 | |
philpem@0 | 469 | ifeq ($(MAKECMDGOALS),$(TARGET)) |
philpem@0 | 470 | -include $(DEPFILES) |
philpem@0 | 471 | endif |