diff --git a/Makefile b/Makefile index 435457c..b16d2b4 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,10 @@ CHMOD = chmod CP = rsync -R MINIFIER = minifier CURL = curl -s +DU = du --block-size=1K --human-readable +TAIL = tail +GREP = grep +AWK = awk # Déclaration des options du compilateur CFLAGS = -Wall -O3 @@ -35,6 +39,8 @@ VSCFILES = $(PROGNAME).vcxproj $(PROGNAME).sln EXTRAFILES = COPYING $(wildcard shaders/*.?s images/*.png) $(VSCFILES) DISTFILES = $(SOURCES) Makefile $(HEADERS) $(DOXYFILE) $(EXTRAFILES) +MAXSIZE = 64 + # Traitements automatiques pour ajout de chemins et options (ne pas modifier) ifneq (,$(shell ls -d /usr/local/include 2>/dev/null | tail -n 1)) CPPFLAGS += -I/usr/local/include @@ -111,9 +117,22 @@ clean: distminified: distdirminified dist # Remove all unnecessary extra files -distdirminified: EXTRAFILES := $(filter-out $(VSCFILES) $(DOXYFILE),$(EXTRAFILES)) +distdirminified: EXTRAFILES := $(filter-out $(VSCFILES),$(EXTRAFILES)) distdirminified: DISTFILES := $(filter-out $(DOXYFILE),$(DISTFILES)) distdirminified: distdir @$(CURL) https://raw.githubusercontent.com/BaseMax/C-Minifier/main/Minifier.c | $(CC) -o $(MINIFIER) $(CFLAGS) -x c - $(foreach f,$(SOURCES),./$(MINIFIER) $(f) $(distdir)/$(f);) @$(RM) $(MINIFIER) + +size: $(PROGNAME) +size: + @$(DU) --total $(PROGNAME) $(filter-out $(VSCFILES) $(DOXYFILE) COPYING,$(EXTRAFILES)) | \ + $(TAIL) -n 1 | \ + $(GREP) -o '[0-9]*K'| \ + $(AWK) 'BEGIN{ \ + if($$1 < $(MAXSIZE)) { \ + print "> Taille conforme" \ + } else { \ + print "> Fichiers trop lourd" \ + } \ + }'