56 lines
1015 B
C
56 lines
1015 B
C
#include "mem.h"
|
|
#include "mem_seg.h"
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#define STR(name) XSTR(name)
|
|
#define XSTR(name) #name
|
|
|
|
#ifndef ARCH
|
|
#pragma message "ARCH not set, using empty"
|
|
#define ARCH asdf
|
|
#endif
|
|
|
|
|
|
#define __ARCH STR(ARCH)
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
if(argc != 2)
|
|
{
|
|
printf("provide target directory\n");
|
|
return 1;
|
|
}
|
|
|
|
const char *dirpath = argv[1];
|
|
const char *filename = "dev_variant";
|
|
|
|
char *tgtpath = (char*)calloc(strlen(dirpath) + strlen(filename) + 2, sizeof(char));
|
|
if(tgtpath == NULL)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
sprintf(tgtpath, "%s/%s", dirpath, filename);
|
|
tgtpath[strlen(dirpath) + strlen(filename) + 1] = 0;
|
|
|
|
FILE *fptr;
|
|
|
|
fptr = fopen(tgtpath, "w");
|
|
|
|
if(fptr == NULL)
|
|
{
|
|
printf("errof opening file\n");
|
|
return 1;
|
|
}
|
|
|
|
char* dev_variant = STR(ARCH);
|
|
fprintf(fptr, "%s", dev_variant);
|
|
|
|
|
|
fclose(fptr);
|
|
free(tgtpath);
|
|
return 0;
|
|
} |