Fixed Makefile so it tracks dependencies better

It now tracks main.cpp's dependencies and rebuilds them as needed.
This commit is contained in:
2024-04-16 20:42:51 +06:30
parent 190bb766cb
commit f060a856d3
8 changed files with 26 additions and 26 deletions

33
src/base.cpp Normal file
View File

@@ -0,0 +1,33 @@
/* Copyright (C) 2024 Aryadev Chavali
* You may distribute and modify this code under the terms of the
* GPLv2 license. You should have received a copy of the GPLv2
* license with this file. If not, please write to:
* aryadev@aryadevchavali.com.
* Created: 2024-04-14
* Author: Aryadev Chavali
* Description:
*/
#include "./base.hpp"
#include <cstdio>
std::optional<std::string> read_file(const char *filename)
{
FILE *fp = fopen(filename, "rb");
if (fp)
{
std::string contents;
fseek(fp, 0, SEEK_END);
contents.resize(ftell(fp));
rewind(fp);
fread(&contents[0], 1, contents.size(), fp);
fclose(fp);
return contents;
}
else
return std::nullopt;
}