From b82689c547448061fad62fb1e5fbae71edac24d7 Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Wed, 6 Sep 2023 20:11:59 +0800 Subject: [PATCH] Make Makefile more flexible --- Makefile | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 0274830..6f7f512 100644 --- a/Makefile +++ b/Makefile @@ -3,17 +3,27 @@ # License : GPLv3 # Authors : Aoran Zeng # Created on : <2023-08-28> -# Last modified : <2023-09-05> +# Last modified : <2023-09-06> # --------------------------------------------------------------- -CFLAGS = +CFLAGS = # -Wall + +ifeq ($(OS), Windows_NT) + CLANG_FLAGS = -target x86_64-pc-windows-gnu +endif TARGET = chsrc #======================= -all: - @echo Compile - @gcc chsrc.c $(CFLAGS) -o $(TARGET) +all: echo +ifeq ($(CC), clang) + @$(CC) chsrc.c $(CLANG_FLAGS) $(CFLAGS) -o $(TARGET) +else + @$(CC) chsrc.c $(CFLAGS) -o $(TARGET) +endif + +echo: + @echo Compile using \'$(CC)\' $(CFLAGS) on $(OS) ... test: $(TARGET) ./$(TARGET) list mirror @@ -21,8 +31,8 @@ test: $(TARGET) ./$(TARGET) get ruby ./$(TARGET) get python -test_xy: - @gcc test_xy.c -o xy +xy: + @$(CC) test_xy.c -o xy @./xy clean: