make: optimize Makefile

pull/5179/head
yuyi 2020-06-03 00:11:58 +08:00 committed by GitHub
parent 1386c5df13
commit f1f4e380a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 13 deletions

View File

@ -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: