/*
 * mkliblst.c
 *
 * Add library module names to a file
 *
 * presently supports Borland and LADsoft library formats
 *
 * David Lindauer, camille@bluegrass.net
 *
 * August, 1996
 */

#include <stdio.h>

int main(int argc, char *argv[])
{
	int i,addret=0,obj = 0;
	FILE *fil;
  if (argc < 3) {
		printf("usage: mkliblst lib type files");
		exit(1) ;
	}
	if (!strcmp(argv[2],".obj")) {
		obj = 1;
	}
	fil = fopen(argv[1],"r");
	if (fil) {
		addret = 1;
		fclose(fil);
	}
	fil = fopen(argv[1],"a+");
	if (!fil) {
		printf("Can't open output file");
		exit(1);
	}
	for (i=3; i < argc; i++) {
		if (addret) {
			if (obj) 
				fputc('&',fil);
			fputc('\n',fil);
		}
		if (obj) {
			fputc('+',fil);
		}
		addret=1;
		fprintf(fil,"%s%s ",argv[i],argv[2]);
	}
	fclose(fil);
	return 0;
}