Add more warnings and add a release option

This commit is contained in:
Mylloon 2022-05-15 21:04:15 +02:00
parent b052570c1c
commit cac541a314
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,34 +1,35 @@
# Makefile # Auteur : Farès BELHADJ (amsi@up8.edu)
# Auteur : Farès BELHADJ
# Email : amsi@up8.edu # Définition des commandes utilisées
# Date : 16/11/2021 CC = gcc
# définition des commandes utilisées ECHO = echo
CC = gcc RM = rm -f
ECHO = echo TAR = tar
RM = rm -f ZIP = zip
TAR = tar
ZIP = zip
MKDIR = mkdir MKDIR = mkdir
CHMOD = chmod CHMOD = chmod
CP = rsync -R CP = rsync -R
# déclaration des options du compilateur
CFLAGS = -Wall -O3 # Déclaration des options du compilateur
CFLAGS =
CPPFLAGS = -I. CPPFLAGS = -I.
LDFLAGS = -lm LDFLAGS = -lm
# définition des fichiers et dossiers
PACKNAME = sc_00_07 # Définition des fichiers et dossiers
PROGNAME = demo PACKNAME = projet
VERSION = 1.0 PROGNAME = demo
distdir = $(PACKNAME)_$(PROGNAME)-$(VERSION) VERSION = 1.0
HEADERS = $(wildcard includes/*.h) distdir = $(PACKNAME)_$(PROGNAME)-$(VERSION)
SOURCES = window.c $(wildcard src/*.c) HEADERS = $(wildcard includes/*.h)
MSVCSRC = $(patsubst %,<ClCompile Include=\"%\\\" \\/>,$(SOURCES)) SOURCES = window.c $(wildcard src/*.c)
OBJ = $(SOURCES:.c=.o) MSVCSRC = $(patsubst %,<ClCompile Include=\"%\\\" \\/>,$(SOURCES))
DOXYFILE = documentation/Doxyfile OBJ = $(SOURCES:.c=.o)
VSCFILES = $(PROGNAME).vcxproj $(PROGNAME).sln DOXYFILE = documentation/Doxyfile
VSCFILES = $(PROGNAME).vcxproj $(PROGNAME).sln
EXTRAFILES = COPYING $(wildcard shaders/*.?s images/*) $(VSCFILES) EXTRAFILES = COPYING $(wildcard shaders/*.?s images/*) $(VSCFILES)
DISTFILES = $(SOURCES) Makefile $(HEADERS) $(DOXYFILE) $(EXTRAFILES) DISTFILES = $(SOURCES) Makefile $(HEADERS) $(DOXYFILE) $(EXTRAFILES)
# Traitements automatiques pour ajout de chemins et options (ne pas modifier)
# Traitements automatiques pour ajout des chemins et options
ifneq (,$(shell ls -d /usr/local/include 2>/dev/null | tail -n 1)) ifneq (,$(shell ls -d /usr/local/include 2>/dev/null | tail -n 1))
CPPFLAGS += -I/usr/local/include CPPFLAGS += -I/usr/local/include
endif endif
@ -48,36 +49,54 @@ ifeq ($(shell uname),Darwin)
else else
LDFLAGS += -lGL LDFLAGS += -lGL
endif endif
CPPFLAGS += $(shell sdl2-config --cflags) CPPFLAGS += $(shell sdl2-config --cflags)
LDFLAGS += -lGL4Dummies $(shell sdl2-config --libs) LDFLAGS += -lGL4Dummies $(shell sdl2-config --libs)
all: $(PROGNAME)
$(PROGNAME): $(OBJ)
$(CC) $(OBJ) $(LDFLAGS) -o $(PROGNAME)
%.o: %.c %.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
# Par défaut
$(PROGNAME): CFLAGS += -Wall -Wextra -Wshadow -pedantic -g -Wsign-conversion
$(PROGNAME): compilation
# Version finale avec optimisation
release: CFLAGS += -O3
release: compilation
compilation: $(OBJ)
$(CC) $(OBJ) $(LDFLAGS) -o $(PROGNAME)
dist: distdir dist: distdir
$(CHMOD) -R a+r $(distdir) $(CHMOD) -R a+r $(distdir)
$(TAR) zcvf $(distdir).tgz $(distdir) $(TAR) zcvf $(distdir).tgz $(distdir)
$(RM) -r $(distdir) $(RM) -r $(distdir)
zip: distdir zip: distdir
$(CHMOD) -R a+r $(distdir) $(CHMOD) -R a+r $(distdir)
$(ZIP) -r $(distdir).zip $(distdir) $(ZIP) -r $(distdir).zip $(distdir)
$(RM) -r $(distdir) $(RM) -r $(distdir)
distdir: $(DISTFILES) distdir: $(DISTFILES)
$(RM) -r $(distdir) $(RM) -r $(distdir)
$(MKDIR) $(distdir) $(MKDIR) $(distdir)
$(CHMOD) 777 $(distdir) $(CHMOD) 777 $(distdir)
$(CP) $(DISTFILES) $(distdir) $(CP) $(DISTFILES) $(distdir)
doc: $(DOXYFILE) doc: $(DOXYFILE)
cat $< | sed -e "s/PROJECT_NAME *=.*/PROJECT_NAME = $(PROGNAME)/" |\ cat $< | sed -e "s/PROJECT_NAME *=.*/PROJECT_NAME = $(PROGNAME)/" |\
sed -e "s/PROJECT_NUMBER *=.*/PROJECT_NUMBER = $(VERSION)/" >> $<.new sed -e "s/PROJECT_NUMBER *=.*/PROJECT_NUMBER = $(VERSION)/" >> $<.new
mv -f $<.new $< mv -f $<.new $<
cd documentation && doxygen && cd .. cd documentation && doxygen && cd ..
msvc: $(VSCFILES) msvc: $(VSCFILES)
@echo "Now these files ($?) already exist. If you wish to regenerate them, you should first delete them manually." @echo "Now these files ($?) already exist. If you wish to regenerate them, you should first delete them manually."
$(VSCFILES): $(VSCFILES):
@echo "Generating $@ ..." @echo "Generating $@ ..."
@cat ../../Windows/templates/gl4dSample$(suffix $@) | sed -e "s/INSERT_PROJECT_NAME/$(PROGNAME)/g" | sed -e "s/INSERT_TARGET_NAME/$(PROGNAME)/" | sed -e "s/INSERT_SOURCE_FILES/$(MSVCSRC)/" > $@ @cat ../../Windows/templates/gl4dSample$(suffix $@) | sed -e "s/INSERT_PROJECT_NAME/$(PROGNAME)/g" | sed -e "s/INSERT_TARGET_NAME/$(PROGNAME)/" | sed -e "s/INSERT_SOURCE_FILES/$(MSVCSRC)/" > $@
all: $(PROGNAME)
clean: clean:
@$(RM) -r $(PROGNAME) $(OBJ) *~ $(distdir).tgz $(distdir).zip gmon.out \ @$(RM) -r $(PROGNAME) $(OBJ) *~ $(distdir).tgz $(distdir).zip gmon.out \
core.* documentation/*~ shaders/*~ documentation/html core.* documentation/*~ shaders/*~ documentation/html