reintroduce conditional front-ends at build, try to auto-detect them.
This commit is contained in:
parent
3e3f046ee6
commit
07a2aaa9ee
7 changed files with 82 additions and 37 deletions
44
Makefile
44
Makefile
|
@ -8,24 +8,14 @@ MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES)
|
|||
|
||||
CC ?= gcc
|
||||
|
||||
GUI ?= sdl
|
||||
WITH_X11 ?= yes
|
||||
WITH_SDL ?= yes
|
||||
|
||||
OPTIM ?= 2
|
||||
|
||||
CFLAGS = -g -O$(OPTIM) -I./src/ -D_GNU_SOURCE=1 -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DPATCHLEVEL=$(PATCHLEVEL)
|
||||
LIBS = -lm
|
||||
|
||||
### X11 UI
|
||||
CFLAGS += $(shell pkg-config --cflags x11 xext) -D_GNU_SOURCE=1
|
||||
LIBS += $(shell pkg-config --libs x11 xext)
|
||||
|
||||
### SDL UI
|
||||
CFLAGS += $(shell pkg-config --cflags SDL_gfx sdl12_compat)
|
||||
LIBS += $(shell pkg-config --libs SDL_gfx sdl12_compat)
|
||||
|
||||
### Text UI
|
||||
CFLAGS += $(shell pkg-config --cflags ncursesw -DNCURSES_WIDECHAR=1)
|
||||
LIBS += $(shell pkg-config --libs ncursesw)
|
||||
|
||||
### debugger
|
||||
CFLAGS += $(shell pkg-config --cflags readline)
|
||||
LIBS += $(shell pkg-config --libs readline)
|
||||
|
@ -45,12 +35,36 @@ DOTOS = src/emu_serial.o \
|
|||
src/debugger.o \
|
||||
src/runtime_options.o \
|
||||
src/romio.o \
|
||||
src/ui_x11.o \
|
||||
src/ui_sdl.o \
|
||||
src/ui_text.o \
|
||||
src/ui.o \
|
||||
src/main.o
|
||||
|
||||
### X11 UI
|
||||
ifeq ($(WITH_X11), yes)
|
||||
X11CFLAGS = $(shell pkg-config --cflags x11 xext) -D_GNU_SOURCE=1
|
||||
X11LIBS = $(shell pkg-config --libs x11 xext)
|
||||
ifneq ($(X11CFLAGS), "")
|
||||
CFLAGS += $(X11CFLAGS) -DHAS_X11=1
|
||||
LIBS += $(X11LIBS)
|
||||
DOTOS += src/ui_x11.o
|
||||
endif
|
||||
endif
|
||||
|
||||
### SDL UI
|
||||
ifeq ($(WITH_SDL), yes)
|
||||
SDLCFLAGS = $(shell pkg-config --cflags SDL_gfx sdl12_compat)
|
||||
SDLLIBS = $(shell pkg-config --libs SDL_gfx sdl12_compat)
|
||||
ifneq ($(SDLCFLAGS), "")
|
||||
CFLAGS += $(SDLCFLAGS) -DHAS_SDL=1
|
||||
LIBS += $(SDLLIBS)
|
||||
DOTOS += src/ui_sdl.o
|
||||
endif
|
||||
endif
|
||||
|
||||
### Text UI
|
||||
CFLAGS += $(shell pkg-config --cflags ncursesw) -DNCURSES_WIDECHAR=1
|
||||
LIBS += $(shell pkg-config --libs ncursesw)
|
||||
|
||||
.PHONY: all clean clean-all pretty-code install
|
||||
|
||||
all: dist/mkcard dist/checkrom dist/dump2rom dist/x48ng
|
||||
|
|
12
README.md
12
README.md
|
@ -61,6 +61,14 @@ See https://github.com/gwenhael-le-moine/x48ng/issues
|
|||
|
||||
## Compilation
|
||||
|
||||
The `Makefile` will try to autodetect if necessary dependencies for x11 and sdl front-ends are met and enable/disable x11 and sdl front-ends accordingly.
|
||||
|
||||
You can force disable x11 front-end by compiling with `make WITH_X11=no`.
|
||||
|
||||
You can force disable sdl front-end by compiling with `make WITH_SDL=no`.
|
||||
|
||||
Ncurses front-end is always built-in.
|
||||
|
||||
### Dependencies (see .github/workflows/c-cpp.yml for debian packages names)
|
||||
|
||||
- readline
|
||||
|
@ -74,6 +82,10 @@ for x11 version:
|
|||
|
||||
- x11
|
||||
|
||||
for Ncurses:
|
||||
|
||||
- ncursesw
|
||||
|
||||
## Installation
|
||||
|
||||
1. Run `sudo make install PREFIX=/usr DOCDIR=/usr/doc/x48ng MANDIR=/usr/man DESTDIR=/tmp/package` filling in your own values for PREFIX, DOCDIR, MANDIR and DESTDIR.
|
||||
|
|
4
dist/x48ng.man.1
vendored
4
dist/x48ng.man.1
vendored
|
@ -49,7 +49,7 @@ x48ng \- scientific calculator and an HP 48 emulator
|
|||
.B x48ng
|
||||
[\--options ...]
|
||||
|
||||
where options include:
|
||||
where options include (depending on compiled front-ends):
|
||||
.br
|
||||
\-h \-\-help what you are reading
|
||||
.br
|
||||
|
@ -70,8 +70,6 @@ where options include:
|
|||
\-\-serial\-line=<path> use <path> as serial device default: /dev/ttyS0)
|
||||
.br
|
||||
\-V \-\-verbose be verbose (default: false)
|
||||
.br
|
||||
\-u \-\-front-end specify a front-end (available: x11, sdl, text; default: x11)
|
||||
.br
|
||||
\-\-x11 use X11 front-end (default: true)
|
||||
.br
|
||||
|
|
|
@ -29,7 +29,13 @@ char* stateFileName = "hp48";
|
|||
char* port1FileName = "port1";
|
||||
char* port2FileName = "port2";
|
||||
|
||||
#ifdef HAS_X11
|
||||
int frontend_type = FRONTEND_X11;
|
||||
#elif HAS_SDL
|
||||
int frontend_type = FRONTEND_SDL;
|
||||
#else
|
||||
int frontend_type = FRONTEND_TEXT;
|
||||
#endif
|
||||
|
||||
/* sdl */
|
||||
int show_ui_chrome = 1;
|
||||
|
@ -158,8 +164,6 @@ int parse_args( int argc, char* argv[] )
|
|||
|
||||
{ "serial-line", required_argument, NULL, 1015 },
|
||||
|
||||
{ "front-end", required_argument, NULL, 'u' },
|
||||
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "version", no_argument, NULL, 'v' },
|
||||
|
||||
|
@ -173,10 +177,13 @@ int parse_args( int argc, char* argv[] )
|
|||
|
||||
{ "no-debug", no_argument, &useDebugger, 0 },
|
||||
|
||||
#ifdef HAS_SDL
|
||||
{ "sdl", no_argument, &frontend_type, FRONTEND_SDL },
|
||||
{ "sdl-no-chrome", no_argument, &show_ui_chrome, 0 },
|
||||
{ "sdl-fullscreen", no_argument, &show_ui_fullscreen, 1 },
|
||||
#endif
|
||||
|
||||
#ifdef HAS_X11
|
||||
{ "x11", no_argument, &frontend_type, FRONTEND_X11 },
|
||||
{ "x11-netbook", no_argument, &netbook, 1 },
|
||||
{ "x11-visual", required_argument, NULL, 8110 },
|
||||
|
@ -184,6 +191,7 @@ int parse_args( int argc, char* argv[] )
|
|||
{ "x11-medium-font", required_argument, NULL, 8112 },
|
||||
{ "x11-large-font", required_argument, NULL, 8113 },
|
||||
{ "x11-connection-font", required_argument, NULL, 8114 },
|
||||
#endif
|
||||
|
||||
{ "tui", no_argument, &frontend_type, FRONTEND_TEXT},
|
||||
|
||||
|
@ -212,11 +220,12 @@ int parse_args( int argc, char* argv[] )
|
|||
"\t --serial-line=<path>\t\tuse <path> as serial device default: "
|
||||
"%s)\n"
|
||||
"\t-V --verbose\t\t\tbe verbose (default: false)\n"
|
||||
"\t-u --front-end\t\t\tspecify a front-end (available: x11, sdl, "
|
||||
"text; "
|
||||
"default: x11)\n"
|
||||
#ifdef HAS_X11
|
||||
"\t --x11\t\tuse X11 front-end (default: true)\n"
|
||||
#endif
|
||||
#ifdef HAS_SDL
|
||||
"\t --sdl\t\tuse SDL front-end (default: false)\n"
|
||||
#endif
|
||||
"\t --tui\t\tuse terminal front-end (default: false)\n"
|
||||
"\t-t --use-terminal\t\tactivate pseudo terminal interface (default: "
|
||||
"true)\n"
|
||||
|
@ -225,11 +234,14 @@ int parse_args( int argc, char* argv[] )
|
|||
"\t-i --initialize\t\t\tinitialize the content of <config-dir>\n"
|
||||
"\t-r --reset\t\t\tperform a reset on startup\n"
|
||||
"\t-T --throttle\t\t\ttry to emulate real speed (default: false)\n"
|
||||
#ifdef HAS_SDL
|
||||
"\t --sdl-no-chrome\t\tonly display the LCD (default: "
|
||||
"false)\n"
|
||||
"\t --sdl-fullscreen\t\tmake the UI fullscreen "
|
||||
"(default: "
|
||||
"false)\n"
|
||||
#endif
|
||||
#ifdef HAS_X11
|
||||
"\t --x11-netbook\t\tmake the UI horizontal (default: "
|
||||
"false)\n"
|
||||
"\t --x11-visual=<X visual>\tuse visual <X visual> (default: "
|
||||
|
@ -244,6 +256,7 @@ int parse_args( int argc, char* argv[] )
|
|||
"font (default: %s)\n"
|
||||
"\t --x11-connection-font=<X font name>\tuse <X font name> as "
|
||||
"connection font (default: %s)\n"
|
||||
#endif
|
||||
"\t --mono\t\t\tmake the UI monochrome (default: "
|
||||
"false)\n"
|
||||
"\t --gray\t\t\tmake the UI grayscale (default: "
|
||||
|
@ -281,6 +294,7 @@ int parse_args( int argc, char* argv[] )
|
|||
case 1015:
|
||||
serialLine = optarg;
|
||||
break;
|
||||
#ifdef HAS_X11
|
||||
case 8110:
|
||||
x11_visual = optarg;
|
||||
break;
|
||||
|
@ -296,18 +310,7 @@ int parse_args( int argc, char* argv[] )
|
|||
case 8114:
|
||||
connFont = optarg;
|
||||
break;
|
||||
case 'u':
|
||||
if ( strcmp( optarg, "sdl" ) == 0 )
|
||||
frontend_type = FRONTEND_SDL;
|
||||
else if ( strcmp( optarg, "text" ) == 0 )
|
||||
frontend_type = FRONTEND_TEXT;
|
||||
else if ( strcmp( optarg, "x11" ) == 0 )
|
||||
frontend_type = FRONTEND_X11;
|
||||
else {
|
||||
fprintf( stderr, "Error: unknown frontend '%s'\n", optarg );
|
||||
exit( 1 );
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case 'V':
|
||||
verbose = 1;
|
||||
break;
|
||||
|
@ -355,12 +358,16 @@ int parse_args( int argc, char* argv[] )
|
|||
fprintf( stderr, "resetOnStartup = %i\n", resetOnStartup );
|
||||
fprintf( stderr, "frontend_type = " );
|
||||
switch ( frontend_type ) {
|
||||
#ifdef HAS_X11
|
||||
case FRONTEND_X11:
|
||||
fprintf( stderr, "x11\n" );
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAS_SDL
|
||||
case FRONTEND_SDL:
|
||||
fprintf( stderr, "sdl\n" );
|
||||
break;
|
||||
#endif
|
||||
case FRONTEND_TEXT:
|
||||
fprintf( stderr, "text\n" );
|
||||
break;
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
#ifndef _OPTIONS_H
|
||||
#define _OPTIONS_H 1
|
||||
|
||||
#define FRONTEND_SDL 0
|
||||
#define FRONTEND_X11 1
|
||||
#ifdef HAS_SDL
|
||||
# define FRONTEND_SDL 0
|
||||
#endif
|
||||
|
||||
#ifdef HAS_X11
|
||||
# define FRONTEND_X11 1
|
||||
#endif
|
||||
|
||||
#define FRONTEND_TEXT 2
|
||||
|
||||
extern char* progname;
|
||||
|
|
4
src/ui.c
4
src/ui.c
|
@ -152,14 +152,18 @@ void ( *init_ui )( int argc, char** argv );
|
|||
void setup_frontend( void )
|
||||
{
|
||||
switch ( frontend_type ) {
|
||||
#ifdef HAS_X11
|
||||
case FRONTEND_X11:
|
||||
default:
|
||||
init_ui = init_x11_ui;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_SDL
|
||||
case FRONTEND_SDL:
|
||||
init_ui = init_sdl_ui;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case FRONTEND_TEXT:
|
||||
init_ui = init_text_ui;
|
||||
|
|
4
src/ui.h
4
src/ui.h
|
@ -26,9 +26,13 @@ extern letter_t small_font[ 128 ];
|
|||
/*************/
|
||||
/* functions */
|
||||
/*************/
|
||||
#ifdef HAS_X11
|
||||
extern void init_x11_ui( int argc, char** argv );
|
||||
#endif
|
||||
|
||||
#ifdef HAS_SDL
|
||||
extern void init_sdl_ui( int argc, char** argv );
|
||||
#endif
|
||||
|
||||
extern void init_text_ui( int argc, char** argv );
|
||||
|
||||
|
|
Loading…
Reference in a new issue