From f1f4e380a2ece83088eaf33bc39ad00b39474a4d Mon Sep 17 00:00:00 2001 From: yuyi Date: Wed, 3 Jun 2020 00:11:58 +0800 Subject: [PATCH] make: optimize Makefile --- Makefile | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 7a3f8295b0..f578b4efa5 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,9 @@ CC ?= cc CFLAGS ?= LDFLAGS ?= TMPDIR ?= /tmp +VC ?= ./vc VCFILE := v.c -TMPVC := $(TMPDIR)/vc TMPTCC := /var/tmp/tcc VCREPO := https://github.com/vlang/vc TCCREPO := https://github.com/vlang/tccbin @@ -45,20 +45,27 @@ endif all: latest_vc latest_tcc ifdef WIN32 - $(CC) $(CFLAGS) -g -std=c99 -municode -w -o v.exe $(TMPVC)/$(VCFILE) $(LDFLAGS) - ./v.exe self + $(CC) $(CFLAGS) -g -std=c99 -municode -w -o v.exe $(VC)/$(VCFILE) $(LDFLAGS) +ifdef prod + ./v.exe -prod self else - $(CC) $(CFLAGS) -g -std=gnu11 -w -o v $(TMPVC)/$(VCFILE) $(LDFLAGS) -lm -lpthread + ./v.exe self +endif +else + $(CC) $(CFLAGS) -g -std=gnu11 -w -o v $(VC)/$(VCFILE) $(LDFLAGS) -lm -lpthread ifdef ANDROID chmod 755 v endif + +ifdef prod + ./v -prod self +else ./v self +endif + ifndef ANDROID $(MAKE) modules endif -endif -ifdef V_ALWAYS_CLEAN_TMP - $(MAKE) clean_tmp endif @echo "V has been successfully built" @./v -version @@ -68,19 +75,26 @@ endif clean: rm -rf $(TMPTCC) - rm -rf $(TMPVC) + rm -rf $(VC) -latest_vc: $(TMPVC)/.git/config - cd $(TMPVC) && $(GITCLEANPULL) +latest_vc: $(VC)/.git/config +ifndef local + cd $(VC) && $(GITCLEANPULL) +else + @echo "Using local vc" +endif fresh_vc: - rm -rf $(TMPVC) - $(GITFASTCLONE) $(VCREPO) $(TMPVC) + $(GITFASTCLONE) $(VCREPO) $(VC) latest_tcc: $(TMPTCC)/.git/config ifndef ANDROID ifndef MAC +ifndef local cd $(TMPTCC) && $(GITCLEANPULL) +else + @echo "Using local tcc" +endif endif endif @@ -97,7 +111,7 @@ ifndef MAC $(MAKE) fresh_tcc endif -$(TMPVC)/.git/config: +$(VC)/.git/config: $(MAKE) fresh_vc selfcompile: