diff --git a/Makefile b/Makefile index 347e44c..82e34f4 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,7 @@ -# Makefile for building Parsee +# (GNU)Makefile for building Parsee # ================================ # TODO: Consider making something akin to a configure script that checks # for dependencies, or maybe even use *autoconf* (the devil!) -# -# TODO: Either get rid of the GNU extensions, or use a script/program -# to build Parsee on a POSIXly environment. I'd dig parsee-buildout, tbf. # =========================== Parsee Flags ============================= diff --git a/build.c b/build.c index 27f29af..663f57b 100644 --- a/build.c +++ b/build.c @@ -9,12 +9,12 @@ * cc build.c -o /tmp/build && /tmp/build * * TODO: Parallel jobs, CFLAGS and LDFLAGS. - * * Note that this bit is formatted differently. * -------------------------------- * LICENSE: CC0 * Written-By: LDA [lda@freetards.xyz] [@fourier:ari.lt] */ +#include #include #include #include @@ -23,6 +23,7 @@ #include #include #include +#include #define DEFAULT_BUILD_PATH "build.conf" #define DEFAULT_COMPILER "cc" @@ -250,6 +251,11 @@ destroy_buildinfo(buildinfo_t *info) free(info->basic.obj); info->basic.obj = NULL; } + if (info->basic.cc) + { + free(info->basic.cc); + info->basic.cc = NULL; + } if (info->repo) { @@ -352,6 +358,16 @@ mkdir_rec(char *dir) } } } +static time_t +mod_date(char *file) +{ + struct stat s; + if (stat(file, &s)) + { + return (time_t) 0; + } + return s.st_mtime; +} static bool build_file(char *cSource, buildinfo_t info, bool isTool) { @@ -384,6 +400,14 @@ build_file(char *cSource, buildinfo_t info, bool isTool) } mkdir_rec(oFileName); + if (!isTool && (mod_date(cSource) < mod_date(oFileName))) + { + free(objPath); + free(oFileName); + free(oFile); + return true; + } + args[i++] = Compiler(info); if (isTool) { diff --git a/build.conf b/build.conf index b64d366..b3ce98b 100644 --- a/build.conf +++ b/build.conf @@ -5,4 +5,4 @@ BINARY=parsee SOURCE=src INCLUDES=src/include OBJECT=build -CC=tcc +CC=cc