Skip to content

Commit ed4369f

Browse files
committed
Finished LDFLAGS support
1 parent 371aa73 commit ed4369f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/cfg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ int SMake_ParseConfig(smake_ctx_t *pCtx)
451451
pValueObj = XJSON_GetObject(pBuildObj, "inject");
452452
if (pValueObj != NULL) xstrncpy(pCtx->sInjectPath, sizeof(pCtx->sInjectPath), XJSON_GetString(pValueObj));
453453

454-
pValueObj = XJSON_GetObject(pBuildObj, "ldflags");
454+
pValueObj = XJSON_GetObject(pBuildObj, "ldFlags");
455455
if (pValueObj != NULL) xstrncpy(pCtx->sLDFlags, sizeof(pCtx->sLDFlags), XJSON_GetString(pValueObj));
456456

457457
pValueObj = XJSON_GetObject(pBuildObj, "overwrite");
@@ -551,7 +551,7 @@ int SMake_WriteConfig(smake_ctx_t *pCtx)
551551
if (xstrused(pCtx->sCompiler)) XJSON_AddObject(pBuildObj, XJSON_NewString(NULL, "compiler", pCtx->sCompiler));
552552
if (xstrused(pCtx->sOutDir)) XJSON_AddObject(pBuildObj, XJSON_NewString(NULL, "outputDir", pCtx->sOutDir));
553553
if (xstrused(pCtx->sInjectPath)) XJSON_AddObject(pBuildObj, XJSON_NewString(NULL, "inject", pCtx->sInjectPath));
554-
if (xstrused(pCtx->sLDFlags)) XJSON_AddObject(pBuildObj, XJSON_NewString(NULL, "ldflags", pCtx->sLDFlags));
554+
if (xstrused(pCtx->sLDFlags)) XJSON_AddObject(pBuildObj, XJSON_NewString(NULL, "ldFlags", pCtx->sLDFlags));
555555

556556
if (XArray_Used(&pCtx->flagArr))
557557
{

src/make.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ xbool_t SMake_WriteMake(smake_ctx_t *pCtx)
430430

431431
xbool_t bLDLibs = xstrused(sLd);
432432
if (xstrused(sLd)) XFile_Print(&file, "LD_LIBS = %s\n", sLd);
433-
XFile_Print(&file, "LDFLAGS =%s%s\n", xstrused(pCtx->sLDFlags) ? " " : "", pCtx->sLDFlags);
433+
if (xstrused(pCtx->sLDFlags)) XFile_Print(&file, "LDFLAGS = %s\n", pCtx->sLDFlags);
434434

435435
XFile_Print(&file, "LIBS = %s\n", sLibs);
436436
XFile_Print(&file, "NAME = %s\n", pCtx->sName);
@@ -496,10 +496,19 @@ xbool_t SMake_WriteMake(smake_ctx_t *pCtx)
496496
XFile_Print(&file, "\t$(%s) $(%s)%s -c -o $(ODIR)/$@ $< $(LIBS)\n\n", pCompiler, pCFlags, pFPICOption);
497497
XFile_Print(&file, "$(NAME):$(OBJS)\n");
498498

499+
499500
if (bStatic) XFile_Print(&file, "\t$(AR) rcs $(ODIR)/$(NAME) $(OBJECTS)\n");
500501
else if (bShared) XFile_Print(&file, "\t$(%s) -shared -o $(ODIR)/$(NAME) $(OBJECTS)\n", pCompiler);
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);
502+
else if (xstrused(pCtx->sLDFlags))
503+
{
504+
if (!bLDLibs) XFile_Print(&file, "\t$(%s) $(%s) $(LDFLAGS) -o $(ODIR)/$(NAME) $(OBJECTS) $(LIBS)\n", pCompiler, pCFlags);
505+
else XFile_Print(&file, "\t$(%s) $(%s) $(LDFLAGS) -o $(ODIR)/$(NAME) $(OBJECTS) $(LD_LIBS) $(LIBS)\n", pCompiler, pCFlags);
506+
}
507+
else
508+
{
509+
if (!bLDLibs) XFile_Print(&file, "\t$(%s) $(%s) -o $(ODIR)/$(NAME) $(OBJECTS) $(LIBS)\n", pCompiler, pCFlags);
510+
else XFile_Print(&file, "\t$(%s) $(%s) -o $(ODIR)/$(NAME) $(OBJECTS) $(LD_LIBS) $(LIBS)\n", pCompiler, pCFlags);
511+
}
503512

504513
if (bInstallBinary || bInstallIncludes)
505514
{

0 commit comments

Comments
 (0)