From 4886403bc682d0ea921b0e007c427f29973fa915 Mon Sep 17 00:00:00 2001 From: inmarket Date: Thu, 25 Sep 2014 17:42:11 +1000 Subject: [PATCH 01/10] Expose the GDISP_STARTUP_COLOR setting for the initial color of displays --- gfxconf.example.h | 4 +- src/gdisp/gdisp_gdisp.c | 3 - src/gdisp/sys_options.h | 119 +++++++++++++++++++--------------------- 3 files changed, 58 insertions(+), 68 deletions(-) diff --git a/gfxconf.example.h b/gfxconf.example.h index 205c79d3..7ac48591 100644 --- a/gfxconf.example.h +++ b/gfxconf.example.h @@ -101,10 +101,10 @@ // #define GDISP_NEED_IMAGE_PNG FALSE // #define GDISP_NEED_IMAGE_ACCOUNTING FALSE -//#define GDISP_NEED_STARTUP_LOGO TRUE - //#define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_LANDSCAPE // If not defined the native hardware orientation is used. //#define GDISP_LINEBUF_SIZE 128 +//#define GDISP_STARTUP_COLOR Black +//#define GDISP_NEED_STARTUP_LOGO TRUE //#define GDISP_TOTAL_DISPLAYS 1 diff --git a/src/gdisp/gdisp_gdisp.c b/src/gdisp/gdisp_gdisp.c index 4a149faa..74cfb67e 100644 --- a/src/gdisp/gdisp_gdisp.c +++ b/src/gdisp/gdisp_gdisp.c @@ -38,9 +38,6 @@ #define GDISP_STARTUP_LOGO_TIMEOUT 0 #endif -// The color to clear the display on startup -#define GDISP_STARTUP_COLOR Black - /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ diff --git a/src/gdisp/sys_options.h b/src/gdisp/sys_options.h index 855f22ff..f3d8875d 100644 --- a/src/gdisp/sys_options.h +++ b/src/gdisp/sys_options.h @@ -20,14 +20,6 @@ * @name GDISP Functionality to be included * @{ */ - /** - * @brief Should the startup logo be displayed - * - * @details Defaults to TRUE - */ - #ifndef GDISP_NEED_STARTUP_LOGO - #define GDISP_NEED_STARTUP_LOGO TRUE - #endif /** * @brief Should drawing operations be automatically flushed. * @details Defaults to FALSE @@ -177,6 +169,62 @@ #ifndef GDISP_NEED_IMAGE #define GDISP_NEED_IMAGE FALSE #endif +/** + * @} + * + * @name GDISP Multi-Threading Options + * @{ + */ + /** + * @brief Do the drawing functions need to be thread-safe. + * @details Defaults to FALSE + */ + #ifndef GDISP_NEED_MULTITHREAD + #define GDISP_NEED_MULTITHREAD FALSE + #endif +/** + * @} + * + * @name GDISP Optional Parameters + * @{ + */ + /** + * @brief Should the startup logo be displayed + * + * @details Defaults to TRUE + */ + #ifndef GDISP_NEED_STARTUP_LOGO + #define GDISP_NEED_STARTUP_LOGO TRUE + #endif + /** + * @brief Define the initial background color for all displays in the system. + */ + #ifndef GDISP_STARTUP_COLOR + #define GDISP_STARTUP_COLOR Black + #endif + /** + * @brief Define the default orientation for all displays in the system. + * @note GDISP_NEED_CONTROL must also be set (and the hardware must support it) + * @note If not specified then displays default to the native hardware orientation + */ + // #define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_LANDSCAPE + /** + * @brief The size of pixel buffer (in pixels) used for optimization. + * @details Set to zero to guarantee disabling of the buffer. + * @note Depending on the driver and what operations the application + * needs, this buffer may never be allocated. + * @note Setting the size to zero may cause some operations to not + * compile eg. Scrolling if there is no hardware scroll support. + * @note Increasing the size will speedup certain operations + * at the expense of RAM. + * @note Currently only used to support scrolling on hardware without + * scrolling support, and to increase the speed of streaming + * operations on non-streaming hardware where there is a + * hardware supported bit-blit. + */ + #ifndef GDISP_LINEBUF_SIZE + #define GDISP_LINEBUF_SIZE 128 + #endif /** * @} * @@ -267,7 +315,6 @@ #ifndef GDISP_NEED_UTF8 #define GDISP_NEED_UTF8 FALSE #endif - /** * @brief Enable kerning for font rendering (improves character placement). * @details Defaults to FALSE @@ -275,7 +322,6 @@ #ifndef GDISP_NEED_TEXT_KERNING #define GDISP_NEED_TEXT_KERNING FALSE #endif - /** * @brief Enable antialiased font support * @details Defaults to FALSE @@ -283,65 +329,12 @@ #ifndef GDISP_NEED_ANTIALIAS #define GDISP_NEED_ANTIALIAS FALSE #endif - -/** - * @} - * - * @name GDISP Multi-Threading Options - * @{ - */ - /** - * @brief Do the drawing functions need to be thread-safe. - * @details Defaults to FALSE - */ - #ifndef GDISP_NEED_MULTITHREAD - #define GDISP_NEED_MULTITHREAD FALSE - #endif -/** - * @} - * - * @name GDISP Fonts - * @{ - */ - /** - * @brief Predefined built in fonts - * @note Turning off the ones you are not using can save program size. - */ - -/** - * @} - * - * @name GDISP Optional Sizing Parameters - * @{ - */ - /** - * @brief The size of pixel buffer (in pixels) used for optimization. - * @details Set to zero to guarantee disabling of the buffer. - * @note Depending on the driver and what operations the application - * needs, this buffer may never be allocated. - * @note Setting the size to zero may cause some operations to not - * compile eg. Scrolling if there is no hardware scroll support. - * @note Increasing the size will speedup certain operations - * at the expense of RAM. - * @note Currently only used to support scrolling on hardware without - * scrolling support, and to increase the speed of streaming - * operations on non-streaming hardware where there is a - * hardware supported bit-blit. - */ - #ifndef GDISP_LINEBUF_SIZE - #define GDISP_LINEBUF_SIZE 128 - #endif /** * @} * * @name GDISP Optional Low Level Driver Defines * @{ */ - /** - * @brief Define the default orientation for all displays in the system. - * @note GDISP_NEED_CONTROL must also be set (and the hardware must support it) - */ - // #define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_LANDSCAPE /** * @brief Set the screen height and width. * @note Ignored by some low level GDISP drivers, optional for others. From 9f720b1f122ffc7986cc467ef1a7607000c6b491 Mon Sep 17 00:00:00 2001 From: inmarket Date: Thu, 25 Sep 2014 17:43:05 +1000 Subject: [PATCH 02/10] C decls on GDISP functions --- src/gdisp/driver.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gdisp/driver.h b/src/gdisp/driver.h index f8d66f4b..98bf64fc 100644 --- a/src/gdisp/driver.h +++ b/src/gdisp/driver.h @@ -617,9 +617,15 @@ typedef struct GDISPVMT { #endif // Routines needed by the general driver VMT - bool_t _gdispInitDriver(GDriver *g, unsigned driverinstance, unsigned systeminstance); - void _gdispPostInitDriver(GDriver *g); - void _gdispDeInitDriver(GDriver *g); + #ifdef __cplusplus + extern "C" { + #endif + bool_t _gdispInitDriver(GDriver *g, unsigned driverinstance, unsigned systeminstance); + void _gdispPostInitDriver(GDriver *g); + void _gdispDeInitDriver(GDriver *g); + #ifdef __cplusplus + } + #endif // Build the VMT const GDISPVMT const GDISP_DRIVER_VMT[1] = {{ From 0e73d65e58777f77882bc6dbbfd0e3e3aa5860b2 Mon Sep 17 00:00:00 2001 From: inmarket Date: Thu, 25 Sep 2014 17:43:43 +1000 Subject: [PATCH 03/10] Additional GDriver call --- src/gdriver/gdriver_gdriver.c | 27 ++++++++++++++++++--------- src/gdriver/sys_defs.h | 9 +++++++++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/gdriver/gdriver_gdriver.c b/src/gdriver/gdriver_gdriver.c index 0a53aaf7..3c17fca0 100644 --- a/src/gdriver/gdriver_gdriver.c +++ b/src/gdriver/gdriver_gdriver.c @@ -11,19 +11,13 @@ #include "sys_defs.h" +#include // For memset + // Define the tables to hold the driver instances. static GDriver *dhead; // The system initialization. void _gdriverInit(void) { - - // Drivers not loaded yet - // GINPUT_NEED_MOUSE - // GINPUT_NEED_DIAL - // GINPUT_NEED_TOGGLE - // GINPUT_NEED_KEYBOARD - // GINPUT_NEED_STRING - // GFX_USE_GBLOCK } // The system de-initialization. @@ -51,7 +45,7 @@ GDriver *gdriverRegister(const GDriverVMT *vmt) { pd = gfxAlloc(vmt->objsize); if (!pd) return 0; - pd->driverchain = 0; + memset(pd, 0, vmt->objsize); pd->vmt = vmt; if (vmt->init && !vmt->init(pd, dinstance, sinstance)) { gfxFree(pd); @@ -136,4 +130,19 @@ GDriver *gdriverGetNext(uint16_t type, GDriver *driver) { return driver; } +unsigned gdriverGetDriverInstanceNumber(GDriver *driver) { + GDriver *pd; + unsigned instance; + + // Loop to find the system instance + instance = 0; + for(pd = dhead; pd; pd = pd->driverchain) { + if (pd == driver) + return instance; + if (pd->vmt->type == driver->vmt->type) + instance++; + } + return (unsigned)-1; +} + #endif /* GFX_USE_GDRIVER */ diff --git a/src/gdriver/sys_defs.h b/src/gdriver/sys_defs.h index 546246de..d8de25fc 100644 --- a/src/gdriver/sys_defs.h +++ b/src/gdriver/sys_defs.h @@ -70,6 +70,7 @@ typedef struct GDriverVMT { bool_t (*init)(GDriver *driver, unsigned driverinstance, unsigned systeminstance); // @< Initialise the driver. Returns TRUE if OK. // driverinstance is the instance 0..n of this driver. // systeminstance is the instance 0..n of this type of device. + // The memory allocated is cleared before this call. void (*postinit)(GDriver *driver); // @< Called once the driver is registered. void (*deinit)(GDriver *driver); // @< De-initialise the driver } GDriverVMT; @@ -130,6 +131,14 @@ extern "C" { */ unsigned gdriverInstanceCount(uint16_t type); + /** + * @brief Get the instance number for a device + * @return The instance number or (unsigned)-1 if it fails. + * + * @param[in] driver The driver to find the instance number for + */ + unsigned gdriverGetDriverInstanceNumber(GDriver *driver); + /** * @brief Get the next driver for a type of device * @return The runtime driver structure or NULL if there are no more. From 9db9255bad8090e15e51922402c807bb1bbe082a Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 26 Sep 2014 16:27:34 +1000 Subject: [PATCH 04/10] Makefile: Add support for - - ..'s in the source path - USER_LISTINGS to control whether listings are generated - dependancy directory now a MACRO - support for Code::Blocks make targets --- boards/base/Win32/example/Makefile | 80 ++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 21 deletions(-) diff --git a/boards/base/Win32/example/Makefile b/boards/base/Win32/example/Makefile index 94a99caf..030cfc20 100644 --- a/boards/base/Win32/example/Makefile +++ b/boards/base/Win32/example/Makefile @@ -12,15 +12,32 @@ # To rebuild project do "make clean" and "make all". # +############################################################################################## +# Start of make control +# + +# Turn ChibiOS simimulator on or off? +USE_CHIBIOS=no + +# Verbose compiling? +USE_VERBOSE_COMPILE=no + +# Generate listing files? +USE_LISTING=no + +# Your project name and executable file name - Optional, defaults to the project directory name +#PROJECT=uGFX + +# +# End of make control +############################################################################################## + ############################################################################################## # Start of default section # CC = i686-pc-mingw32-gcc -g -# Turn ChibiOS simimulator on or off - uGFX doesn't need it but you might for other purposes. -USE_CHIBIOS=no - # List all default C defines here, like -D_DEBUG=1 DDEFS = @@ -34,7 +51,7 @@ DLIBDIR = DLIBS = -lws2_32 -lgdi32 -lwinmm # Make sure this empty for now -SRC = +SRC = # # End of default section @@ -44,9 +61,6 @@ SRC = # Start of user section # -# Define project name here -PROJECT = uGFX - # Imported source files and paths for uGFX GFXLIB = ../uGFX include $(GFXLIB)/gfx.mk @@ -108,51 +122,75 @@ OPT = -ggdb -O0 -fomit-frame-pointer ############################################################################################## -# Output directory and files -ifeq ($(BUILDDIR),) - BUILDDIR = .build +# Default project name is the project directory name +ifeq ($(PROJECT),) + PROJECT := $(notdir $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST)))))) endif -ifeq ($(BUILDDIR),.) + +# Output directory and files +ifeq ($(MAKECMDGOALS),Debug) + BUILDDIR = bin/Debug +else ifeq ($(MAKECMDGOALS),Release) + BUILDDIR = bin/Release +else ifeq ($(BUILDDIR),) + BUILDDIR = .build +else ifeq ($(BUILDDIR),.) BUILDDIR = .build endif OBJDIR = $(BUILDDIR)/obj LSTDIR = $(BUILDDIR)/lst MAPDIR = $(BUILDDIR)/map +DEPDIR = .dep INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR)) LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) DEFS = $(DDEFS) $(UDEFS) ADEFS = $(DADEFS) $(UADEFS) -COBJ = $(addprefix $(OBJDIR)/, $(SRC:.c=.o)) -AOBJ = $(addprefix $(OBJDIR)/, $(ASRC:.s=.o)) +COBJ = $(addprefix $(OBJDIR)/, $(subst ../,_dot_dot/,$(SRC:.c=.o))) +AOBJ = $(addprefix $(OBJDIR)/, $(subst ../,_dot_dot/,$(ASRC:.s=.o))) OBJS = $(AOBJ) $(COBJ) LIBS = $(DLIBS) $(ULIBS) LDFLAGS = -Wl,-Map=$(MAPDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR) -CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm -Wa,-alms=$(LSTDIR)/$(<:.c=.lst) $(DEFS) +CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS) +ifeq ($(USE_LISTING),yes) + CPFLAGS += -Wa,-alms=$(LSTDIR)/$(<:.c=.lst) +endif # Generate dependency information -CPFLAGS += -MD -MP -MF .dep/$(@F).d +CPFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d # # makefile rules # +Debug Release: all + +cleanDebug cleanRelease: clean + -rm -fR bin + all: $(BUILDDIR) $(OBJS) $(BUILDDIR)/$(PROJECT).exe MAKE_ALL_RULE_HOOK +#all: main.cp + +main.cp: $(MYCSRC) + $(CC) -c $(CPFLAGS) -E -P -I. $(INCDIR) $< -o $@ MAKE_ALL_RULE_HOOK: $(BUILDDIR) $(OBJDIR) $(LSTDIR): mkdir -p $(OBJDIR) - mkdir -p $(LSTDIR) mkdir -p $(MAPDIR) +ifeq ($(USE_LISTING),yes) + mkdir -p $(LSTDIR) +endif ifneq ($(USE_VERBOSE_COMPILE),yes) @echo Compiler Options - $(CC) -c $(CPFLAGS) -I. $(INCDIR) main.c -o $(OBJDIR)/main.o @echo endif -$(OBJDIR)/%.o : %.c +.SECONDEXPANSION: +$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.c) @mkdir -p $(dir $@) ifeq ($(USE_VERBOSE_COMPILE),yes) @echo @@ -162,7 +200,7 @@ else @$(CC) -c $(CPFLAGS) -I. $(INCDIR) $< -o $@ endif -$(OBJDIR)/%.o : %.s +$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.s) @mkdir -p $(dir $@) ifeq ($(USE_VERBOSE_COMPILE),yes) @echo @@ -187,12 +225,12 @@ gcov: -mv *.gcov ./gcov clean: - -rm -fR .build - -rm -fR .dep + -rm -fR $(BUILDDIR) + -rm -fR $(DEPDIR) # # Include the dependency files, should be the last of the makefile # --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) +-include $(shell mkdir $(DEPDIR) 2>/dev/null) $(wildcard $(DEPDIR)/*) # *** EOF *** From ff28a0aa37fb0400e0cd7e504f6af7cdcd01aa48 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 26 Sep 2014 16:28:26 +1000 Subject: [PATCH 05/10] Reorder initialisation to ensure gwin is initialised last --- src/gfx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gfx.c b/src/gfx.c index 0803f59a..dfb438e2 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -89,9 +89,6 @@ void gfxInit(void) #if GFX_USE_GDISP _gdispInit(); #endif - #if GFX_USE_GWIN - _gwinInit(); - #endif #if GFX_USE_GINPUT _ginputInit(); #endif @@ -101,6 +98,9 @@ void gfxInit(void) #if GFX_USE_GAUDIO _gaudioInit(); #endif + #if GFX_USE_GWIN + _gwinInit(); + #endif } void gfxDeinit(void) @@ -110,6 +110,9 @@ void gfxDeinit(void) initDone = FALSE; // We deinitialise the opposite way as we initialised + #if GFX_USE_GWIN + _gwinDeinit(); + #endif #if GFX_USE_GAUDIN _gaudioDeinit(); #endif @@ -119,9 +122,6 @@ void gfxDeinit(void) #if GFX_USE_GINPUT _ginputDeinit(); #endif - #if GFX_USE_GWIN - _gwinDeinit(); - #endif #if GFX_USE_GDISP _gdispDeinit(); #endif From b42a2098ebec7ece6ba075ee55f5c29061526a24 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 26 Sep 2014 16:29:52 +1000 Subject: [PATCH 06/10] Change to GDriver to support an initialisation parameter --- src/gdisp/driver.h | 2 +- src/gdisp/gdisp_gdisp.c | 9 +++++---- src/gdriver/gdriver_gdriver.c | 4 ++-- src/gdriver/sys_defs.h | 5 +++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gdisp/driver.h b/src/gdisp/driver.h index 98bf64fc..8d22135d 100644 --- a/src/gdisp/driver.h +++ b/src/gdisp/driver.h @@ -620,7 +620,7 @@ typedef struct GDISPVMT { #ifdef __cplusplus extern "C" { #endif - bool_t _gdispInitDriver(GDriver *g, unsigned driverinstance, unsigned systeminstance); + bool_t _gdispInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance); void _gdispPostInitDriver(GDriver *g); void _gdispDeInitDriver(GDriver *g); #ifdef __cplusplus diff --git a/src/gdisp/gdisp_gdisp.c b/src/gdisp/gdisp_gdisp.c index 74cfb67e..1552cea6 100644 --- a/src/gdisp/gdisp_gdisp.c +++ b/src/gdisp/gdisp_gdisp.c @@ -572,7 +572,7 @@ void _gdispInit(void) static const struct GDriverVMT const * dclist[] = {GDISP_DRIVER_LIST}; for(i = 0; i < sizeof(dclist)/sizeof(dclist[0]); i++) - gdriverRegister(dclist[i]); + gdriverRegister(dclist[i], 0); } #elif GDISP_TOTAL_DISPLAYS > 1 { @@ -580,13 +580,13 @@ void _gdispInit(void) extern GDriverVMTList GDISPVMT_OnlyOne; for(i = 0; i < GDISP_TOTAL_DISPLAYS; i++) - gdriverRegister(GDISPVMT_OnlyOne); + gdriverRegister(GDISPVMT_OnlyOne, 0); } #else { extern GDriverVMTList GDISPVMT_OnlyOne; - gdriverRegister(GDISPVMT_OnlyOne); + gdriverRegister(GDISPVMT_OnlyOne, 0); } #endif @@ -620,9 +620,10 @@ void _gdispDeinit(void) /* ToDo */ } -bool_t _gdispInitDriver(GDriver *g, unsigned driverinstance, unsigned systeminstance) { +bool_t _gdispInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance) { #define gd ((GDisplay *)g) bool_t ret; + (void) param; // Intialise fields gd->systemdisplay = systeminstance; diff --git a/src/gdriver/gdriver_gdriver.c b/src/gdriver/gdriver_gdriver.c index 3c17fca0..d44d6f3c 100644 --- a/src/gdriver/gdriver_gdriver.c +++ b/src/gdriver/gdriver_gdriver.c @@ -27,7 +27,7 @@ void _gdriverDeinit(void) { } -GDriver *gdriverRegister(const GDriverVMT *vmt) { +GDriver *gdriverRegister(const GDriverVMT *vmt, void *param) { GDriver * pd; GDriver * dtail; unsigned dinstance, sinstance; @@ -47,7 +47,7 @@ GDriver *gdriverRegister(const GDriverVMT *vmt) { return 0; memset(pd, 0, vmt->objsize); pd->vmt = vmt; - if (vmt->init && !vmt->init(pd, dinstance, sinstance)) { + if (vmt->init && !vmt->init(pd, param, dinstance, sinstance)) { gfxFree(pd); return 0; } diff --git a/src/gdriver/sys_defs.h b/src/gdriver/sys_defs.h index d8de25fc..f7bf622e 100644 --- a/src/gdriver/sys_defs.h +++ b/src/gdriver/sys_defs.h @@ -67,7 +67,7 @@ typedef struct GDriverVMT { uint16_t type; // @< What type of driver this is uint16_t flags; // @< Flags for the driver. Meaning is specific to each driver type. uint32_t objsize; // @< How big the runtime driver structure is - bool_t (*init)(GDriver *driver, unsigned driverinstance, unsigned systeminstance); // @< Initialise the driver. Returns TRUE if OK. + bool_t (*init)(GDriver *driver, void *param, unsigned driverinstance, unsigned systeminstance); // @< Initialise the driver. Returns TRUE if OK. // driverinstance is the instance 0..n of this driver. // systeminstance is the instance 0..n of this type of device. // The memory allocated is cleared before this call. @@ -102,8 +102,9 @@ extern "C" { * @return The runtime driver structure or NULL if it fails. * * @param[in] vmt The driver's vmt + * @param[in] param An arbitrary paramater passed to the driver init routine. */ - GDriver *gdriverRegister(const GDriverVMT *vmt); + GDriver *gdriverRegister(const GDriverVMT *vmt, void *param); /** * @brief UnRegister a driver instance. From be9d35472764523f36ac91891b78aca613467ac1 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 26 Sep 2014 17:28:43 +1000 Subject: [PATCH 07/10] Update more Makefiles --- .../base/Linux-Framebuffer/example/Makefile | 113 +++++++++++++----- boards/base/Linux/example/Makefile | 111 ++++++++++++----- 2 files changed, 169 insertions(+), 55 deletions(-) diff --git a/boards/base/Linux-Framebuffer/example/Makefile b/boards/base/Linux-Framebuffer/example/Makefile index 66af4bdc..8be8c839 100644 --- a/boards/base/Linux-Framebuffer/example/Makefile +++ b/boards/base/Linux-Framebuffer/example/Makefile @@ -12,16 +12,29 @@ # To rebuild project do "make clean" and "make all". # +############################################################################################## +# Start of make control +# + +# Verbose compiling? +USE_VERBOSE_COMPILE=no + +# Generate listing files? +USE_LISTING=no + +# Your project name and executable file name - Optional, defaults to the project directory name +#PROJECT=uGFX + ############################################################################################## # Start of default section # -TRGT = +TRGT = CC = $(TRGT)gcc AS = $(TRGT)gcc -x assembler-with-cpp # List all default C defines here, like -D_DEBUG=1 -DDEFS = +DDEFS = # List all default ASM defines here, like -D_DEBUG=1 DADEFS = @@ -33,7 +46,7 @@ DINCDIR = DLIBDIR = # List all default libraries here -DLIBS = -lX11 -pthread -lrt +DLIBS = -lrt # # End of default section @@ -43,8 +56,10 @@ DLIBS = -lX11 -pthread -lrt # Start of user section # -# Define project name here -PROJECT = ugfx +# Default project name is the project directory name +ifeq ($(PROJECT),) + PROJECT := $(notdir $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST)))))) +endif # Imported source files and paths for uGFX GFXLIB = ../ugfx @@ -87,15 +102,38 @@ OPT = -ggdb -O0 -fomit-frame-pointer # End of user defines ############################################################################################## +I# Output directory and files +ifeq ($(MAKECMDGOALS),Debug) + BUILDDIR = bin/Debug +else ifeq ($(MAKECMDGOALS),Release) + BUILDDIR = bin/Release +else ifeq ($(BUILDDIR),) + BUILDDIR = .build +else ifeq ($(BUILDDIR),.) + BUILDDIR = .build +endif + +OBJDIR = $(BUILDDIR)/obj +LSTDIR = $(BUILDDIR)/lst +MAPDIR = $(BUILDDIR)/map +DEPDIR = .dep + INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR)) LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) DEFS = $(DDEFS) $(UDEFS) ADEFS = $(DADEFS) $(UADEFS) -OBJS = $(ASRC:.s=.o) $(SRC:.c=.o) +COBJ = $(addprefix $(OBJDIR)/, $(subst ../,_dot_dot/,$(SRC:.c=.o))) +AOBJ = $(addprefix $(OBJDIR)/, $(subst ../,_dot_dot/,$(ASRC:.s=.o))) +OBJS = $(AOBJ) $(COBJ) LIBS = $(DLIBS) $(ULIBS) -ASFLAGS = -Wa,-amhls=$(<:.s=.lst) $(ADEFS) -CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS) +ASFLAGS = $(ADEFS) +CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS) +LDFLAGS = -Wl,-Map=$(MAPDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR) +ifeq ($(USE_LISTING),yes) + ASFLAGS += -Wa,-amhls=$(LSTDIR)/$(subst ../,_dot_dot/,$(<:.s=.lst)) + CPFLAGS += -Wa,-alms=$(LSTDIR)/$(subst ../,_dot_dot/,$(<:.c=.lst)) +endif ifeq ($(HOST_OSX),yes) ifeq ($(OSX_SDK),) @@ -105,29 +143,54 @@ ifeq ($(HOST_OSX),yes) OSX_ARCH = -mmacosx-version-min=10.3 -arch i386 endif - CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH) - LDFLAGS = -Wl -Map=$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR) LIBS += $(OSX_ARCH) + CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH) + LDFLAGS = -Wl -Map=$(MAPDIR)/$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR) else # Linux, or other - CPFLAGS += -m32 -Wa,-alms=$(<:.c=.lst) - LDFLAGS = -m32 -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR) + CPFLAGS += -m32 endif # Generate dependency information -CPFLAGS += -MD -MP -MF .dep/$(@F).d +CPFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d # # makefile rules # -all: $(OBJS) $(PROJECT) +all: $(BUILDDIR) $(OBJS) $(PROJECT) -%.o : %.c - $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@ +$(BUILDDIR) $(OBJDIR) $(LSTDIR) $(MAPDIR): + mkdir -p $(OBJDIR) + mkdir -p $(MAPDIR) +ifeq ($(USE_LISTING),yes) + mkdir -p $(LSTDIR) +endif +ifneq ($(USE_VERBOSE_COMPILE),yes) + @echo Compiler Options - $(CC) -c $(CPFLAGS) -I. $(INCDIR) main.c -o $(OBJDIR)/main.o + @echo +endif -%.o : %.s - $(AS) -c $(ASFLAGS) $< -o $@ +.SECONDEXPANSION: +$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.c) + @mkdir -p $(dir $@) +ifeq ($(USE_VERBOSE_COMPILE),yes) + @echo + $(CC) -c $(CPFLAGS) -I. $(INCDIR) $< -o $@ +else + @echo Compiling $< + @$(CC) -c $(CPFLAGS) -I. $(INCDIR) $< -o $@ +endif + +$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.s) + @mkdir -p $(dir $@) +ifeq ($(USE_VERBOSE_COMPILE),yes) + @echo + $(AS) -c $(ASFLAGS) -I. $(INCDIR) $< -o $@ +else + @echo Compiling $< + @$(AS) -c $(ASFLAGS) -I. $(INCDIR) $< -o $@ +endif $(PROJECT): $(OBJS) $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ @@ -137,19 +200,13 @@ gcov: $(COV) -u $(subst /,\,$(SRC)) -mv *.gcov ./gcov -clean: - -rm -f $(OBJS) - -rm -f $(PROJECT) - -rm -f $(PROJECT).map - -rm -f $(SRC:.c=.c.bak) - -rm -f $(SRC:.c=.lst) - -rm -f $(ASRC:.s=.s.bak) - -rm -f $(ASRC:.s=.lst) - -rm -fR .dep +clean: + -rm -f $(BUILDDIR) + -rm -fR $(DEPDIR) # # Include the dependency files, should be the last of the makefile # --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) +-include $(shell mkdir $(DEPDIR) 2>/dev/null) $(wildcard $(DEPDIR)/*) # *** EOF *** diff --git a/boards/base/Linux/example/Makefile b/boards/base/Linux/example/Makefile index e454a811..938494cb 100644 --- a/boards/base/Linux/example/Makefile +++ b/boards/base/Linux/example/Makefile @@ -12,16 +12,29 @@ # To rebuild project do "make clean" and "make all". # +############################################################################################## +# Start of make control +# + +# Verbose compiling? +USE_VERBOSE_COMPILE=no + +# Generate listing files? +USE_LISTING=no + +# Your project name and executable file name - Optional, defaults to the project directory name +#PROJECT=uGFX + ############################################################################################## # Start of default section # -TRGT = +TRGT = CC = $(TRGT)gcc AS = $(TRGT)gcc -x assembler-with-cpp # List all default C defines here, like -D_DEBUG=1 -DDEFS = +DDEFS = # List all default ASM defines here, like -D_DEBUG=1 DADEFS = @@ -43,8 +56,10 @@ DLIBS = -lX11 -pthread -lrt # Start of user section # -# Define project name here -PROJECT = ugfx +# Default project name is the project directory name +ifeq ($(PROJECT),) + PROJECT := $(notdir $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST)))))) +endif # Imported source files and paths for uGFX GFXLIB = ../ugfx @@ -87,15 +102,38 @@ OPT = -ggdb -O0 -fomit-frame-pointer # End of user defines ############################################################################################## +# Output directory and files +ifeq ($(MAKECMDGOALS),Debug) + BUILDDIR = bin/Debug +else ifeq ($(MAKECMDGOALS),Release) + BUILDDIR = bin/Release +else ifeq ($(BUILDDIR),) + BUILDDIR = .build +else ifeq ($(BUILDDIR),.) + BUILDDIR = .build +endif + +OBJDIR = $(BUILDDIR)/obj +LSTDIR = $(BUILDDIR)/lst +MAPDIR = $(BUILDDIR)/map +DEPDIR = .dep + INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR)) LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) DEFS = $(DDEFS) $(UDEFS) ADEFS = $(DADEFS) $(UADEFS) -OBJS = $(ASRC:.s=.o) $(SRC:.c=.o) +COBJ = $(addprefix $(OBJDIR)/, $(subst ../,_dot_dot/,$(SRC:.c=.o))) +AOBJ = $(addprefix $(OBJDIR)/, $(subst ../,_dot_dot/,$(ASRC:.s=.o))) +OBJS = $(AOBJ) $(COBJ) LIBS = $(DLIBS) $(ULIBS) -ASFLAGS = -Wa,-amhls=$(<:.s=.lst) $(ADEFS) -CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS) +ASFLAGS = $(ADEFS) +CPFLAGS = $(OPT) -Wall -Wextra -Wstrict-prototypes -fverbose-asm $(DEFS) +LDFLAGS = -Wl,-Map=$(MAPDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR) +ifeq ($(USE_LISTING),yes) + ASFLAGS += -Wa,-amhls=$(LSTDIR)/$(subst ../,_dot_dot/,$(<:.s=.lst)) + CPFLAGS += -Wa,-alms=$(LSTDIR)/$(subst ../,_dot_dot/,$(<:.c=.lst)) +endif ifeq ($(HOST_OSX),yes) ifeq ($(OSX_SDK),) @@ -105,29 +143,54 @@ ifeq ($(HOST_OSX),yes) OSX_ARCH = -mmacosx-version-min=10.3 -arch i386 endif - CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH) - LDFLAGS = -Wl -Map=$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR) LIBS += $(OSX_ARCH) + CPFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH) + LDFLAGS = -Wl -Map=$(MAPDIR)/$(PROJECT).map,-syslibroot,$(OSX_SDK),$(LIBDIR) else # Linux, or other - CPFLAGS += -m32 -Wa,-alms=$(<:.c=.lst) - LDFLAGS = -m32 -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR) + CPFLAGS += -m32 endif # Generate dependency information -CPFLAGS += -MD -MP -MF .dep/$(@F).d +CPFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d # # makefile rules # -all: $(OBJS) $(PROJECT) +all: $(BUILDDIR) $(OBJS) $(PROJECT) -%.o : %.c - $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@ +$(BUILDDIR) $(OBJDIR) $(LSTDIR) $(MAPDIR): + mkdir -p $(OBJDIR) + mkdir -p $(MAPDIR) +ifeq ($(USE_LISTING),yes) + mkdir -p $(LSTDIR) +endif +ifneq ($(USE_VERBOSE_COMPILE),yes) + @echo Compiler Options - $(CC) -c $(CPFLAGS) -I. $(INCDIR) main.c -o $(OBJDIR)/main.o + @echo +endif -%.o : %.s - $(AS) -c $(ASFLAGS) $< -o $@ +.SECONDEXPANSION: +$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.c) + @mkdir -p $(dir $@) +ifeq ($(USE_VERBOSE_COMPILE),yes) + @echo + $(CC) -c $(CPFLAGS) -I. $(INCDIR) $< -o $@ +else + @echo Compiling $< + @$(CC) -c $(CPFLAGS) -I. $(INCDIR) $< -o $@ +endif + +$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.s) + @mkdir -p $(dir $@) +ifeq ($(USE_VERBOSE_COMPILE),yes) + @echo + $(AS) -c $(ASFLAGS) -I. $(INCDIR) $< -o $@ +else + @echo Compiling $< + @$(AS) -c $(ASFLAGS) -I. $(INCDIR) $< -o $@ +endif $(PROJECT): $(OBJS) $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ @@ -137,19 +200,13 @@ gcov: $(COV) -u $(subst /,\,$(SRC)) -mv *.gcov ./gcov -clean: - -rm -f $(OBJS) - -rm -f $(PROJECT) - -rm -f $(PROJECT).map - -rm -f $(SRC:.c=.c.bak) - -rm -f $(SRC:.c=.lst) - -rm -f $(ASRC:.s=.s.bak) - -rm -f $(ASRC:.s=.lst) - -rm -fR .dep +clean: + -rm -f $(BUILDDIR) + -rm -fR $(DEPDIR) # # Include the dependency files, should be the last of the makefile # --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) +-include $(shell mkdir $(DEPDIR) 2>/dev/null) $(wildcard $(DEPDIR)/*) # *** EOF *** From b2b3859e6265f3841d0205ad64a4d5b654f98959 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 26 Sep 2014 18:08:49 +1000 Subject: [PATCH 08/10] More makefile updates --- boards/base/Linux-Framebuffer/example/Makefile | 10 +++++++++- boards/base/Linux/example/Makefile | 10 +++++++++- boards/base/Win32/example/Makefile | 5 ++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/boards/base/Linux-Framebuffer/example/Makefile b/boards/base/Linux-Framebuffer/example/Makefile index 8be8c839..d5032f57 100644 --- a/boards/base/Linux-Framebuffer/example/Makefile +++ b/boards/base/Linux-Framebuffer/example/Makefile @@ -107,6 +107,10 @@ ifeq ($(MAKECMDGOALS),Debug) BUILDDIR = bin/Debug else ifeq ($(MAKECMDGOALS),Release) BUILDDIR = bin/Release +else ifeq ($(MAKECMDGOALS),cleanDebug) + BUILDDIR = bin/Debug +else ifeq ($(MAKECMDGOALS),cleanRelease) + BUILDDIR = bin/Release else ifeq ($(BUILDDIR),) BUILDDIR = .build else ifeq ($(BUILDDIR),.) @@ -158,6 +162,10 @@ CPFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d # makefile rules # +Debug Release: all + +cleanDebug cleanRelease: clean + all: $(BUILDDIR) $(OBJS) $(PROJECT) $(BUILDDIR) $(OBJDIR) $(LSTDIR) $(MAPDIR): @@ -201,7 +209,7 @@ gcov: -mv *.gcov ./gcov clean: - -rm -f $(BUILDDIR) + -rm -fR $(BUILDDIR) -rm -fR $(DEPDIR) # diff --git a/boards/base/Linux/example/Makefile b/boards/base/Linux/example/Makefile index 938494cb..21343755 100644 --- a/boards/base/Linux/example/Makefile +++ b/boards/base/Linux/example/Makefile @@ -107,6 +107,10 @@ ifeq ($(MAKECMDGOALS),Debug) BUILDDIR = bin/Debug else ifeq ($(MAKECMDGOALS),Release) BUILDDIR = bin/Release +else ifeq ($(MAKECMDGOALS),cleanDebug) + BUILDDIR = bin/Debug +else ifeq ($(MAKECMDGOALS),cleanRelease) + BUILDDIR = bin/Release else ifeq ($(BUILDDIR),) BUILDDIR = .build else ifeq ($(BUILDDIR),.) @@ -158,6 +162,10 @@ CPFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d # makefile rules # +Debug Release: all + +cleanDebug cleanRelease: clean + all: $(BUILDDIR) $(OBJS) $(PROJECT) $(BUILDDIR) $(OBJDIR) $(LSTDIR) $(MAPDIR): @@ -201,7 +209,7 @@ gcov: -mv *.gcov ./gcov clean: - -rm -f $(BUILDDIR) + -rm -fR $(BUILDDIR) -rm -fR $(DEPDIR) # diff --git a/boards/base/Win32/example/Makefile b/boards/base/Win32/example/Makefile index 030cfc20..7d54ac02 100644 --- a/boards/base/Win32/example/Makefile +++ b/boards/base/Win32/example/Makefile @@ -132,6 +132,10 @@ ifeq ($(MAKECMDGOALS),Debug) BUILDDIR = bin/Debug else ifeq ($(MAKECMDGOALS),Release) BUILDDIR = bin/Release +else ifeq ($(MAKECMDGOALS),cleanDebug) + BUILDDIR = bin/Debug +else ifeq ($(MAKECMDGOALS),cleanRelease) + BUILDDIR = bin/Release else ifeq ($(BUILDDIR),) BUILDDIR = .build else ifeq ($(BUILDDIR),.) @@ -168,7 +172,6 @@ CPFLAGS += -MD -MP -MF $(DEPDIR)/$(@F).d Debug Release: all cleanDebug cleanRelease: clean - -rm -fR bin all: $(BUILDDIR) $(OBJS) $(BUILDDIR)/$(PROJECT).exe MAKE_ALL_RULE_HOOK #all: main.cp From 2d811142562c9509c82ffa2fa5dedeeae22b3e17 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 26 Sep 2014 18:23:41 +1000 Subject: [PATCH 09/10] gdriver bugfix --- src/gdriver/gdriver_gdriver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gdriver/gdriver_gdriver.c b/src/gdriver/gdriver_gdriver.c index d44d6f3c..916b44fb 100644 --- a/src/gdriver/gdriver_gdriver.c +++ b/src/gdriver/gdriver_gdriver.c @@ -56,7 +56,7 @@ GDriver *gdriverRegister(const GDriverVMT *vmt, void *param) { if (dhead) dtail->driverchain = pd; else - dhead = pd; + dhead = dtail = pd; // Do the post init if (vmt->postinit) From 0d35e6b6ae5eb8c44f7a35d0dac0fc3bcf41a130 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 26 Sep 2014 18:35:51 +1000 Subject: [PATCH 10/10] Another GDriver bugfix --- src/gdriver/gdriver_gdriver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gdriver/gdriver_gdriver.c b/src/gdriver/gdriver_gdriver.c index 916b44fb..210840b1 100644 --- a/src/gdriver/gdriver_gdriver.c +++ b/src/gdriver/gdriver_gdriver.c @@ -15,6 +15,7 @@ // Define the tables to hold the driver instances. static GDriver *dhead; +static GDriver *dtail; // The system initialization. void _gdriverInit(void) { @@ -29,12 +30,11 @@ void _gdriverDeinit(void) { GDriver *gdriverRegister(const GDriverVMT *vmt, void *param) { GDriver * pd; - GDriver * dtail; unsigned dinstance, sinstance; // Loop to find the driver instance and the system instance numbers dinstance = sinstance = 0; - for(pd = dhead; pd; dtail = pd, pd = pd->driverchain) { + for(pd = dhead; pd; pd = pd->driverchain) { if (pd->vmt == vmt) dinstance++; if (pd->vmt->type == vmt->type)