@@ -61,9 +61,11 @@ void SMake_InitContext(smake_ctx_t *pCtx)
6161 pCtx -> sPath [0 ] = pCtx -> sOutDir [0 ] = '.' ;
6262 pCtx -> sPath [1 ] = pCtx -> sOutDir [1 ] = XSTR_NUL ;
6363
64+ pCtx -> sInjectPath [0 ] = XSTR_NUL ;
6465 pCtx -> sHeaderDst [0 ] = XSTR_NUL ;
6566 pCtx -> sBinaryDst [0 ] = XSTR_NUL ;
6667 pCtx -> sCompiler [0 ] = XSTR_NUL ;
68+ pCtx -> sLDFlags [0 ] = XSTR_NUL ;
6769 pCtx -> sConfig [0 ] = XSTR_NUL ;
6870 pCtx -> sName [0 ] = XSTR_NUL ;
6971 pCtx -> sMain [0 ] = XSTR_NUL ;
@@ -428,22 +430,36 @@ xbool_t SMake_WriteMake(smake_ctx_t *pCtx)
428430
429431 xbool_t bLDLibs = xstrused (sLd );
430432 if (xstrused (sLd )) XFile_Print (& file , "LD_LIBS = %s\n" , sLd );
433+ XFile_Print (& file , "LDFLAGS =%s%s\n" , xstrused (pCtx -> sLDFlags ) ? " " : "" , pCtx -> sLDFlags );
431434
432435 XFile_Print (& file , "LIBS = %s\n" , sLibs );
433436 XFile_Print (& file , "NAME = %s\n" , pCtx -> sName );
434437 XFile_Print (& file , "ODIR = %s\n" , pCtx -> sOutDir );
435438 XFile_Print (& file , "OBJ = o\n\n" );
436- XFile_Print (& file , "OBJS = " );
439+
440+ if (xstrused (pCtx -> sInjectPath ) && XPath_Exists (pCtx -> sInjectPath ))
441+ {
442+ xbyte_buffer_t fileBuffer ;
443+ XPath_LoadBuffer (pCtx -> sInjectPath , & fileBuffer );
444+
445+ if (fileBuffer .pData != NULL )
446+ {
447+ XFile_Print (& file , "%s\n\n" , (char * )fileBuffer .pData );
448+ XByteBuffer_Clear (& fileBuffer );
449+ }
450+ }
437451
438452 xlogi ("Compiler flags: %s %s" , sFlags , sIncludes );
439453 xlogi ("Linked libraries: %s" , sLibs );
440454 xlogi ("Custom libraries: %s" , sLd );
441455 xlogi ("Binary file name: %s" , pCtx -> sName );
442456 xlogi ("Output Directory: %s" , pCtx -> sOutDir );
457+ xlogi ("Inject file: %s" , xstrused (pCtx -> sInjectPath ) ? pCtx -> sInjectPath : "None" );
443458 xlogi ("Compiler: %s" , strlen (pCtx -> sCompiler ) ? pCtx -> sCompiler : pCompiler );
444459
445460 XArray_Sort (& pCtx -> objArr , SMake_CompareName , NULL );
446461 size_t i , nObjs = XArray_Used (& pCtx -> objArr );
462+ XFile_Print (& file , "OBJS = " );
447463
448464 for (i = 0 ; i < nObjs ; i ++ )
449465 {
@@ -482,8 +498,8 @@ xbool_t SMake_WriteMake(smake_ctx_t *pCtx)
482498
483499 if (bStatic ) XFile_Print (& file , "\t$(AR) rcs $(ODIR)/$(NAME) $(OBJECTS)\n" );
484500 else if (bShared ) XFile_Print (& file , "\t$(%s) -shared -o $(ODIR)/$(NAME) $(OBJECTS)\n" , pCompiler );
485- else if (!bLDLibs ) XFile_Print (& file , "\t$(%s) $(%s) -o $(ODIR)/$(NAME) $(OBJECTS) $(LIBS)\n" , pCompiler , pCFlags );
486- else XFile_Print (& file , "\t$(%s) $(%s) -o $(ODIR)/$(NAME) $(OBJECTS) $(LD_LIBS) $(LIBS)\n" , pCompiler , pCFlags );
501+ else if (!bLDLibs ) XFile_Print (& file , "\t$(%s) $(%s) $(LDFLAGS) -o $(ODIR)/$(NAME) $(OBJECTS) $(LIBS)\n" , pCompiler , pCFlags );
502+ else XFile_Print (& file , "\t$(%s) $(%s) $(LDFLAGS) -o $(ODIR)/$(NAME) $(OBJECTS) $(LD_LIBS) $(LIBS)\n" , pCompiler , pCFlags );
487503
488504 if (bInstallBinary || bInstallIncludes )
489505 {
0 commit comments