From 30988be5570b69708f7fa12aac91cd4969afdf92 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 10 Sep 2019 09:23:20 +0200 Subject: [PATCH] mymake:: select existing Makefile, fixed incorrect 'file not found' error, added/removed some comments --- mymake.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mymake.cpp b/mymake.cpp index 90b89b13..cae2ce19 100644 --- a/mymake.cpp +++ b/mymake.cpp @@ -1,5 +1,6 @@ // HyperRogue: alternative build system // This reads the file 'hyper.cpp' and compiles the cpp files it includes into separate object files, and then links them. +// Tested in Linux, should work in other systems with some changes. // Options: // -O2 -- optimize @@ -12,6 +13,7 @@ #include #include #include +#include using namespace std; @@ -46,9 +48,15 @@ string setdir = "../"; int system(string cmdline) { return system(cmdline.c_str()); } + +bool file_exists(string fname) { + return access(fname.c_str(), F_OK) != -1; + } int main(int argc, char **argv) { - system("make -f Makefile.loc language-data.cpp autohdr.h savepng-loc.o"); + for(string fname: {"Makefile.loc", "Makefile.simple", "Makefile"}) + if(file_exists(fname)) + system("make -f " + fname + " language-data.cpp autohdr.h savepng-loc.o"); for(int i=1; i