From 2d28146e3f0f8b1d39eb5121bfa691fc078a79ff Mon Sep 17 00:00:00 2001 From: "(Tim) Efthimis Kritikos" Date: Sat, 2 Mar 2024 00:23:29 +0000 Subject: [PATCH] Build system: Made the aalib integration fully selectable in the Makefile --- Makefile | 7 ++++++- config.h | 2 +- gui_display.c | 14 +++++++------- main.c | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index dc92687..a429f90 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ QUIET=1 ADDRESS_SANITIZE=1 +USE_AALIB=1 all:first @@ -25,7 +26,11 @@ else endif CFLAGS::=-O2 $(shell pkg-config ncursesw --cflags) + +ifeq "${USE_AALIB}" "1" +CFLAGS::=$(shell pkg-config ncursesw --cflags) LDFLAGS::=$(shell aalib-config --libs) +endif ifeq "${ADDRESS_SANITIZE}" "1" CFLAGS += -fsanitize=address -ggdb @@ -47,7 +52,7 @@ gprof: %.o:%.c ${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} ${QUIET_VALGRIND} diff --git a/config.h b/config.h index e133849..1b3a427 100644 --- a/config.h +++ b/config.h @@ -1 +1 @@ -#define USE_AALIB +//#define USE_AALIB diff --git a/gui_display.c b/gui_display.c index c4c4ab3..3007a28 100644 --- a/gui_display.c +++ b/gui_display.c @@ -7,7 +7,7 @@ #include "gui.h" #include "gui_display.h" -#ifdef USE_AALIB +#if USE_AALIB==1 #include #endif @@ -74,7 +74,7 @@ int clean_braille(){ /////////////////////////////////////////////// //// AALib code /////////////////////////////////////////////// -#ifdef USE_AALIB +#if USE_AALIB==1 struct aa_context *aactx; int print_aalib_frame_buffer(WINDOW* win,uint8_t *fb,int fb_width,int fb_height,int fullscreen){ int height, width; @@ -158,7 +158,7 @@ int clean_aalib(){ //// Generic code /////////////////////////////////////////////// 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) return print_aalib_frame_buffer(win,fb,fb_width,fb_height,fullscreen); else @@ -166,7 +166,7 @@ else return print_braille_frame_buffer(win,fb,fb_width,fb_height,fullscreen); } int init(WINDOW *win,int fullscreen){ -#ifdef USE_AALIB +#if USE_AALIB==1 if(selected_fb_driver==FB_AALIB) return init_aalib(win,fullscreen); else @@ -174,7 +174,7 @@ else return init_braille(win,fullscreen); } float get_aspec_ratio(){ -#ifdef USE_AALIB +#if USE_AALIB==1 if(selected_fb_driver==FB_AALIB) return 2; else @@ -215,7 +215,7 @@ int update_terminal_output(WINDOW *win, struct simdata_t *simdata,uint8_t fullsc int vfb_width, vfb_height; -#ifdef USE_AALIB +#if USE_AALIB==1 if(selected_fb_driver==FB_AALIB){ vfb_width=aa_imgwidth(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); -# ifdef USE_AALIB +#if USE_AALIB==1 if(selected_fb_driver==FB_AALIB) clean_aalib(); else diff --git a/main.c b/main.c index 0023af0..c386811 100644 --- a/main.c +++ b/main.c @@ -36,7 +36,7 @@ void help(char* progname){ "Options:\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" -#ifdef USE_AALIB +#if USE_AALIB==1 " aalib, braille\n" #else " braille\n" @@ -93,7 +93,7 @@ int main(int argc, char* argd[] ){ return 1; } } -#ifndef USE_AALIB +#if USE_AALIB==0 if(fb_driver==FB_AALIB){ printf("ERROR:Project wasn't compiled with aalib support.\n"); help(argd[0]);