// 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. // Options: // -O2 -- optimize // -O3 -- optimize // -D... -- change compilation flags // [file.cpp] -- add a module to the build (e.g. ./mymake rogueviz) #include #include #include #include #include using namespace std; string opts = "-DFHS -DLINUX -DWHATEVER -I/usr/include/SDL"; string preprocessor = "g++ " + opts + " -E"; string compiler = "g++ " + opts + " -Wall -Wextra -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-unused-parameter -Wno-implicit-fallthrough -std=c++11 -rdynamic -fdiagnostics-color=always -c"; string linker = "g++ -rdynamic -o hyper"; string libs = " savepng-loc.o -lSDL -lSDL_ttf -lSDL_mixer -lSDL_gfx -lGLEW -lGL -lpng -rdynamic -lpthread"; vector modules; time_t get_file_time(const string s) { struct stat attr; if(stat(s.c_str(), &attr)) return 0; return attr.st_mtime; } int optimized = 0; string obj_dir = "mymake_files"; string setdir = "../"; int system(string cmdline) { return system(cmdline.c_str()); } int main(int argc, char **argv) { system("make -f Makefile.loc language-data.cpp autohdr.h savepng-loc.o"); for(int i=1; i obj_time) { printf("compiling %s... [%d/%d]\n", m.c_str(), id, int(modules.size())); if(system(compiler + " " + src + " -o " + obj)) { printf("error\n"); exit(1); } } else { printf("ok: %s\n", m.c_str()); } allobj += " "; allobj += obj; } printf("linking...\n"); system(linker + allobj + libs); return 0; } // g++ hyper.cpp -c -o hyper.o // g++ savepng-loc.o hyper.o -o hyper -lSDL -lSDL_ttf -lSDL_mixer -lSDL_gfx -lGLEW -g3 -lGL -lpng -rdynamic