Add automatic detection of 32/64-bit platform on linux (makefile)

This commit is contained in:
Marek Karcz 2019-01-04 23:36:40 -05:00
parent b730b0cb1a
commit 37fa527d75
2 changed files with 35 additions and 9 deletions

View File

@ -18,8 +18,9 @@ MOS-6502-compatible virtual computer featuring BASIC interpreter, machine code
monitor, input/output device emulation etc.
Main UI of the program works in DOS/shell console.
Graphics display emulation requires SDL2.
Makefile are included to build under Windows 32/64 (mingw compiler required)
and under Linux Ubuntu or Ubuntu based distro.
The best way is to download source code of SDL2 and build it.
Makefile-s are included to build under Windows 32/64 (mingw compiler required)
and under Linux Ubuntu or Ubuntu based distro (GNU make).
SDL2 library must be on your execution path in order to run program.
E.g.:
set PATH=C:\src\SDL\lib\x64;%PATH%
@ -28,6 +29,7 @@ To build under Windows 32/64:
* Install MINGW64 under C:\mingw-w64\x86_64-5.3.0 folder.
* Run mingw terminal.
* Build SDL2 library.
* Change current directory to that of this project.
* Set environment variable SDLDIR. (E.g.: set SDLDIR=C:\src\SDL)
* Run: makeming.bat
@ -35,9 +37,20 @@ To build under Windows 32/64:
To build under Linux:
* Make sure C++11 compliant version of GCC compiler is installed.
NOTE: Under older distros, e.g.: Ubuntu Server 12.04, the newest c++
compiler installed may not be modern enough. Follow instructions
for your distro to install compatible c++ compiler.
E.g.:
https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91
* Build SDL2 library (make, make install) or download C/C++ headers and
install SDL2 from binary installation package.
* Change current directory to that of this project.
* Set environment variable SDLDIR.
* Set environment variable SDLDIR. Your C/C++ headers for SDL2 should exist
in $SDLDIR/include folder.
* Run: make clean all
NOTE: To run the emulator under Linux, it may be necessary to set env.
variable LD_LIBRARY_PATH, e.g.:
export LD_LIBRARY_PATH=/usr/local/lib
Program passed following tests:

View File

@ -1,4 +1,4 @@
# Project: MKBasic
# Project: VM65
SDLBASE = $(SDLDIR)
SDLINCS = -I"$(SDLBASE)/include"
@ -8,13 +8,27 @@ OBJ = main.o VMachine.o MKCpu.o Memory.o Display.o GraphDisp.o MemMapDev.o
LINKOBJ = main.o VMachine.o MKCpu.o Memory.o Display.o GraphDisp.o MemMapDev.o MKGenException.o ConsoleIO.o MassStorage.o
BIN = vm65
SDLLIBS = -L/usr/local/lib -lSDL2main -lSDL2
LIBS = -static-libgcc -m32 -g3 -ltermcap -lncurses
CLIBS = -static-libgcc -m32 -g3
INCS =
CXXINCS =
CXXFLAGS = $(CXXINCS) -m32 -std=c++0x -Wall -pedantic -g3 -fpermissive
ifeq ($(SDLBASE),)
$(error ***** SDLDIR not set)
endif
$(eval $(export HOSTTYPE = $(arch)))
$(info ***** SDLDIR = $(SDLDIR))
$(info ***** HOSTTYPE = $(HOSTTYPE))
ifeq ($(HOSTTYPE),x86_64)
$(info ***** 64-bit)
LIBS = -static-libgcc -g3 -ltermcap -lncurses -lpthread
CLIBS = -static-libgcc -g3
CXXFLAGS = $(CXXINCS) -std=c++11 -pthread -Wall -pedantic -g3 -fpermissive
else
$(info ***** 32-bit)
LIBS = -static-libgcc -m32 -g3 -ltermcap -lncurses
CLIBS = -static-libgcc -m32 -g3
CXXFLAGS = $(CXXINCS) -m32 -std=c++11 -pthread -Wall -pedantic -g3 -fpermissive
endif
#CFLAGS = $(INCS) -m32 -std=c++0x -Wall -pedantic -g3
CFLAGS = $(INCS) -m32 -Wall -pedantic -g3
CFLAGS = $(INCS) -Wall -pedantic -g3
RM = rm -f
.PHONY: all all-before all-after clean clean-custom
@ -32,7 +46,6 @@ main.o: main.cpp
VMachine.o: VMachine.cpp
$(CPP) -c VMachine.cpp -o VMachine.o $(CXXFLAGS) $(SDLINCS)
MKBasic.o: MKBasic.cpp
$(CPP) -c MKBasic.cpp -o MKBasic.o $(CXXFLAGS)