Build system: Made the aalib integration fully selectable in the Makefile

This commit is contained in:
(Tim) Efthimis Kritikos 2024-03-02 00:23:29 +00:00
parent b9f93b8fa5
commit 2d28146e3f
4 changed files with 16 additions and 11 deletions

View File

@ -1,5 +1,6 @@
QUIET=1 QUIET=1
ADDRESS_SANITIZE=1 ADDRESS_SANITIZE=1
USE_AALIB=1
all:first all:first
@ -25,7 +26,11 @@ else
endif endif
CFLAGS::=-O2 $(shell pkg-config ncursesw --cflags) CFLAGS::=-O2 $(shell pkg-config ncursesw --cflags)
ifeq "${USE_AALIB}" "1"
CFLAGS::=$(shell pkg-config ncursesw --cflags)
LDFLAGS::=$(shell aalib-config --libs) LDFLAGS::=$(shell aalib-config --libs)
endif
ifeq "${ADDRESS_SANITIZE}" "1" ifeq "${ADDRESS_SANITIZE}" "1"
CFLAGS += -fsanitize=address -ggdb CFLAGS += -fsanitize=address -ggdb
@ -47,7 +52,7 @@ gprof:
%.o:%.c %.o:%.c
${QUIET_CC} ${QUIET_CC}
${Q}gcc -c $< -Wall -Wextra -Werror ${CFLAGS} ${Q}gcc -c $< -DUSE_AALIB=${USE_AALIB} -Wall -Wextra -Werror ${CFLAGS}
callgrind.out:first ${MAIN_ROM} callgrind.out:first ${MAIN_ROM}
${QUIET_VALGRIND} ${QUIET_VALGRIND}

View File

@ -1 +1 @@
#define USE_AALIB //#define USE_AALIB

View File

@ -7,7 +7,7 @@
#include "gui.h" #include "gui.h"
#include "gui_display.h" #include "gui_display.h"
#ifdef USE_AALIB #if USE_AALIB==1
#include <aalib.h> #include <aalib.h>
#endif #endif
@ -74,7 +74,7 @@ int clean_braille(){
/////////////////////////////////////////////// ///////////////////////////////////////////////
//// AALib code //// AALib code
/////////////////////////////////////////////// ///////////////////////////////////////////////
#ifdef USE_AALIB #if USE_AALIB==1
struct aa_context *aactx; struct aa_context *aactx;
int print_aalib_frame_buffer(WINDOW* win,uint8_t *fb,int fb_width,int fb_height,int fullscreen){ int print_aalib_frame_buffer(WINDOW* win,uint8_t *fb,int fb_width,int fb_height,int fullscreen){
int height, width; int height, width;
@ -158,7 +158,7 @@ int clean_aalib(){
//// Generic code //// Generic code
/////////////////////////////////////////////// ///////////////////////////////////////////////
int print_frame_buffer(WINDOW* win,uint8_t *fb,int fb_width,int fb_height,int fullscreen){ int print_frame_buffer(WINDOW* win,uint8_t *fb,int fb_width,int fb_height,int fullscreen){
#ifdef USE_AALIB #if USE_AALIB==1
if(selected_fb_driver==FB_AALIB) if(selected_fb_driver==FB_AALIB)
return print_aalib_frame_buffer(win,fb,fb_width,fb_height,fullscreen); return print_aalib_frame_buffer(win,fb,fb_width,fb_height,fullscreen);
else else
@ -166,7 +166,7 @@ else
return print_braille_frame_buffer(win,fb,fb_width,fb_height,fullscreen); return print_braille_frame_buffer(win,fb,fb_width,fb_height,fullscreen);
} }
int init(WINDOW *win,int fullscreen){ int init(WINDOW *win,int fullscreen){
#ifdef USE_AALIB #if USE_AALIB==1
if(selected_fb_driver==FB_AALIB) if(selected_fb_driver==FB_AALIB)
return init_aalib(win,fullscreen); return init_aalib(win,fullscreen);
else else
@ -174,7 +174,7 @@ else
return init_braille(win,fullscreen); return init_braille(win,fullscreen);
} }
float get_aspec_ratio(){ float get_aspec_ratio(){
#ifdef USE_AALIB #if USE_AALIB==1
if(selected_fb_driver==FB_AALIB) if(selected_fb_driver==FB_AALIB)
return 2; return 2;
else else
@ -215,7 +215,7 @@ int update_terminal_output(WINDOW *win, struct simdata_t *simdata,uint8_t fullsc
int vfb_width, vfb_height; int vfb_width, vfb_height;
#ifdef USE_AALIB #if USE_AALIB==1
if(selected_fb_driver==FB_AALIB){ if(selected_fb_driver==FB_AALIB){
vfb_width=aa_imgwidth(aactx); vfb_width=aa_imgwidth(aactx);
vfb_height=aa_imgheight(aactx); vfb_height=aa_imgheight(aactx);
@ -330,7 +330,7 @@ int update_terminal_output(WINDOW *win, struct simdata_t *simdata,uint8_t fullsc
free(vector_display_frame_buffer); free(vector_display_frame_buffer);
# ifdef USE_AALIB #if USE_AALIB==1
if(selected_fb_driver==FB_AALIB) if(selected_fb_driver==FB_AALIB)
clean_aalib(); clean_aalib();
else else

4
main.c
View File

@ -36,7 +36,7 @@ void help(char* progname){
"Options:\n" "Options:\n"
" -a < out rom file > Assemble in file to out rom file\n" " -a < out rom file > Assemble in file to out rom file\n"
" -r < framebuffer driver > Use one of the following for writing the framebuffer\n" " -r < framebuffer driver > Use one of the following for writing the framebuffer\n"
#ifdef USE_AALIB #if USE_AALIB==1
" aalib, braille\n" " aalib, braille\n"
#else #else
" braille\n" " braille\n"
@ -93,7 +93,7 @@ int main(int argc, char* argd[] ){
return 1; return 1;
} }
} }
#ifndef USE_AALIB #if USE_AALIB==0
if(fb_driver==FB_AALIB){ if(fb_driver==FB_AALIB){
printf("ERROR:Project wasn't compiled with aalib support.\n"); printf("ERROR:Project wasn't compiled with aalib support.\n");
help(argd[0]); help(argd[0]);