From 205de25237f5cd88f55f6a5f4264f65a4f1cbc6f Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 27 Apr 2024 22:27:18 +0200 Subject: Simplify macros and define _GNU_SOURCE on Glibc --- make.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/make.c b/make.c index b2cba46..255fb21 100644 --- a/make.c +++ b/make.c @@ -1,5 +1,8 @@ #define _GNU_SOURCE #include +#if __has_include() +# include +#endif #include #include #include @@ -8,20 +11,29 @@ #define CBS_PTHREAD #include "cbs.h" -#define CC "gcc" -#define CFLAGS_ALL WARNINGS, "-pipe", "-std=c23", "-Iinclude" -#define CFLAGS_DBG CFLAGS_ALL, "-g", "-ggdb3", "-Og" -#ifdef __APPLE__ -# define CFLAGS_RLS CFLAGS_ALL, "-O3", "-flto", "-DNDEBUG" -#else -# define CFLAGS_RLS \ - CFLAGS_ALL, "-O3", "-flto", "-DNDEBUG", "-march=native", "-mtune=native" -#endif +#define CC "gcc" #define LIBNAME "libmlib" + +#define CFLAGS_ALL WARNINGS, "-pipe", "-std=c23", "-Iinclude" GLIB_EXTRAS +#define CFLAGS_DBG CFLAGS_ALL, "-g", "-ggdb3", "-Og" +#define CFLAGS_RLS CFLAGS_ALL, "-O3", "-flto", "-DNDEBUG" NOT_APPLE_EXTRAS + #define WARNINGS \ "-Wall", "-Wextra", "-Wpedantic", "-Werror", "-Wno-attributes", "-Wvla", \ "-Wno-pointer-sign", "-Wno-parentheses" +#ifdef __GLIBC__ +# define GLIB_EXTRAS , "-D_GNU_SOURCE" +#else +# define GLIB_EXTRAS +#endif + +#ifndef __APPLE__ +# define NOT_APPLE_EXTRAS , "-march=native", "-mtune=native" +#else +# define NOT_APPLE_EXTRAS +#endif + #define CMDRC(c) \ do { \ int ec; \ -- cgit v1.2.3