Blame src/internal/slibtool_objmeta_impl.c

70f645
/*******************************************************************/
70f645
/*  slibtool: a skinny libtool implementation, written in C        */
70f645
/*  Copyright (C) 2016  Z. Gilboa                                  */
70f645
/*  Released under the Standard MIT License; see COPYING.SLIBTOOL. */
70f645
/*******************************************************************/
70f645
70f645
#include <stdio.h>
70f645
#include <slibtool/slibtool.h>
70f645
#include "slibtool_metafile_impl.h"
70f645
70f645
static int  slbt_create_default_object_wrapper(
70f645
	const struct slbt_driver_ctx *	dctx,
70f645
	struct slbt_exec_ctx *		ectx)
70f645
{
70f645
	int					ret;
70f645
	FILE *					fout;
70f645
	const struct slbt_source_version *	verinfo;
70f645
70f645
	if (!(fout = fopen(ectx->ltobjname,"w")))
70f645
		return -1;
70f645
70f645
	verinfo = slbt_source_version();
70f645
70f645
	ret = fprintf(fout,
70f645
		"# libtool compatible object wrapper\n"
70f645
		"# Generated by %s (slibtool %d.%d.%d)\n"
70f645
		"# [commit reference: %s]\n\n"
70f645
70f645
		"pic_object='%s'\n"
70f645
		"non_pic_object='%s'\n",
70f645
70f645
		dctx->program,
70f645
		verinfo->major,verinfo->minor,verinfo->revision,
70f645
		verinfo->commit,
70f645
70f645
		(dctx->cctx->drvflags & SLBT_DRIVER_SHARED)
70f645
			? ectx->lobjname
70f645
			: "none",
70f645
		(dctx->cctx->drvflags & SLBT_DRIVER_STATIC)
70f645
			? ectx->aobjname
70f645
			: "none");
70f645
70f645
	return (ret <= 0) || fclose(fout)
70f645
		? -1 : 0;
70f645
}
70f645
70f645
static int  slbt_create_compatible_object_wrapper(
70f645
	const struct slbt_driver_ctx *	dctx,
70f645
	struct slbt_exec_ctx *		ectx)
70f645
{
70f645
	/* awaiting submission */
70f645
	return slbt_create_default_object_wrapper(dctx,ectx);
70f645
}
70f645
70f645
int  slbt_create_object_wrapper(
70f645
	const struct slbt_driver_ctx *	dctx,
70f645
	struct slbt_exec_ctx *		ectx)
70f645
{
70f645
	if (dctx->cctx->drvflags & SLBT_DRIVER_LEGABITS)
70f645
		return slbt_create_compatible_object_wrapper(dctx,ectx);
70f645
	else
70f645
		return slbt_create_default_object_wrapper(dctx,ectx);
70f645
}