2023-05-03 12:57:22 +02:00
|
|
|
# Makefile
|
|
|
|
# Auteur : Farès BELHADJ
|
|
|
|
# Email : amsi@up8.edu
|
|
|
|
# Date : 28/04/2020
|
|
|
|
# Modified : Anri KENNEL (anri.kennel@etud.univ-paris8.fr) - 03/05/2023
|
2023-03-18 17:51:56 +01:00
|
|
|
|
|
|
|
# Définition des commandes utilisées
|
2023-05-03 13:29:17 +02:00
|
|
|
CC = gcc
|
|
|
|
ECHO = echo
|
|
|
|
RM = rm -f
|
|
|
|
TAR = tar
|
|
|
|
ZIP = zip
|
|
|
|
MKDIR = mkdir
|
|
|
|
CHMOD = chmod
|
|
|
|
CP = rsync -R
|
|
|
|
MINIFIER = minifier
|
|
|
|
CURL = curl -s
|
2023-05-03 14:18:21 +02:00
|
|
|
DU = du --block-size=1K --human-readable
|
|
|
|
TAIL = tail
|
|
|
|
GREP = grep
|
|
|
|
AWK = awk
|
2023-03-18 17:51:56 +01:00
|
|
|
|
|
|
|
# Déclaration des options du compilateur
|
2023-05-03 13:02:43 +02:00
|
|
|
CFLAGS = -Wall -O3
|
2023-03-18 17:51:56 +01:00
|
|
|
CPPFLAGS = -I.
|
2023-05-03 13:02:43 +02:00
|
|
|
LDFLAGS = -lm
|
2023-03-18 17:51:56 +01:00
|
|
|
|
|
|
|
# Définition des fichiers et dossiers
|
2023-05-03 13:02:43 +02:00
|
|
|
PACKNAME = api8_2023
|
|
|
|
PROGNAME = demo
|
|
|
|
VERSION = anri
|
|
|
|
distdir = $(PACKNAME)_$(PROGNAME)-$(VERSION)
|
|
|
|
HEADERS = $(wildcard includes/*.h)
|
|
|
|
SOURCES = main.c $(wildcard src/*.c)
|
|
|
|
MSVCSRC = $(patsubst %,<ClCompile Include=\"%\\\" \\/>,$(SOURCES))
|
|
|
|
OBJ = $(SOURCES:.c=.o)
|
|
|
|
DOXYFILE = documentation/Doxyfile
|
|
|
|
VSCFILES = $(PROGNAME).vcxproj $(PROGNAME).sln
|
2023-03-18 17:51:56 +01:00
|
|
|
EXTRAFILES = COPYING $(wildcard shaders/*.?s images/*.png) $(VSCFILES)
|
2023-05-03 13:02:43 +02:00
|
|
|
DISTFILES = $(SOURCES) Makefile $(HEADERS) $(DOXYFILE) $(EXTRAFILES)
|
2023-03-18 17:51:56 +01:00
|
|
|
|
2023-05-03 14:18:21 +02:00
|
|
|
MAXSIZE = 64
|
|
|
|
|
2023-03-18 17:51:56 +01:00
|
|
|
# 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
|
|
|
|
endif
|
|
|
|
ifneq (,$(shell ls -d $(HOME)/local/include 2>/dev/null | tail -n 1))
|
|
|
|
CPPFLAGS += -I$(HOME)/local/include
|
|
|
|
endif
|
|
|
|
ifneq (,$(shell ls -d /usr/local/lib 2>/dev/null | tail -n 1))
|
|
|
|
LDFLAGS += -L/usr/local/lib
|
|
|
|
endif
|
|
|
|
ifneq (,$(shell ls -d $(HOME)/local/lib 2>/dev/null | tail -n 1))
|
|
|
|
LDFLAGS += -L$(HOME)/local/lib
|
|
|
|
endif
|
|
|
|
ifeq ($(shell uname),Darwin)
|
|
|
|
MACOSX_DEPLOYMENT_TARGET = 11.0
|
2023-05-03 13:02:43 +02:00
|
|
|
CFLAGS += -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
|
|
|
|
LDFLAGS += -framework OpenGL -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
|
2023-03-18 17:51:56 +01:00
|
|
|
else
|
2023-05-03 13:02:43 +02:00
|
|
|
LDFLAGS += -lGL
|
2023-03-18 17:51:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
CPPFLAGS += $(shell sdl2-config --cflags)
|
2023-05-03 12:22:42 +02:00
|
|
|
LDFLAGS += -lGL4Dummies $(shell sdl2-config --libs) -lSDL2_mixer -lSDL2_image
|
2023-03-18 17:51:56 +01:00
|
|
|
|
|
|
|
all: $(PROGNAME)
|
|
|
|
$(PROGNAME): $(OBJ)
|
|
|
|
$(CC) $(OBJ) $(LDFLAGS) -o $(PROGNAME)
|
|
|
|
|
2023-04-30 17:04:55 +02:00
|
|
|
debug: CFLAGS = -Wall -Wextra -Wconversion -Wno-sign-conversion -Wno-unused-parameter \
|
|
|
|
-Wno-unused-function -Wdouble-promotion -Wshadow -Wcast-align \
|
|
|
|
-Wstrict-prototypes -fanalyzer -fsanitize=undefined \
|
|
|
|
-fsanitize-undefined-trap-on-error -g3
|
2023-04-30 17:02:41 +02:00
|
|
|
debug: $(PROGNAME)
|
|
|
|
|
2023-03-18 17:51:56 +01:00
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
dist: distdir
|
|
|
|
$(CHMOD) -R a+r $(distdir)
|
|
|
|
$(TAR) zcvf $(distdir).tgz $(distdir)
|
|
|
|
$(RM) -r $(distdir)
|
|
|
|
|
|
|
|
zip: distdir
|
|
|
|
$(CHMOD) -R a+r $(distdir)
|
|
|
|
$(ZIP) -r $(distdir).zip $(distdir)
|
|
|
|
$(RM) -r $(distdir)
|
|
|
|
|
|
|
|
distdir: $(DISTFILES)
|
|
|
|
$(RM) -r $(distdir)
|
|
|
|
$(MKDIR) $(distdir)
|
|
|
|
$(CHMOD) 777 $(distdir)
|
|
|
|
$(CP) $(DISTFILES) $(distdir)
|
|
|
|
|
|
|
|
doc: $(DOXYFILE)
|
|
|
|
cat $< | sed -e "s/PROJECT_NAME *=.*/PROJECT_NAME = $(PROGNAME)/" |\
|
|
|
|
sed -e "s/PROJECT_NUMBER *=.*/PROJECT_NUMBER = $(VERSION)/" >> $<.new
|
|
|
|
mv -f $<.new $<
|
|
|
|
cd documentation && doxygen && cd ..
|
|
|
|
|
|
|
|
msvc: $(VSCFILES)
|
|
|
|
@echo "Now these files ($?) already exist. If you wish to regenerate them, you should first delete them manually."
|
|
|
|
|
|
|
|
$(VSCFILES):
|
|
|
|
@echo "Generating $@ ..."
|
2023-05-03 12:59:20 +02:00
|
|
|
@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)/" > $@
|
2023-03-18 17:51:56 +01:00
|
|
|
|
|
|
|
clean:
|
2023-05-03 12:57:22 +02:00
|
|
|
@$(RM) -r $(PROGNAME) $(OBJ) *~ $(distdir).tgz $(distdir).zip $(distdir)/ \
|
|
|
|
gmon.out core.* documentation/*~ shaders/*~ documentation/html
|
2023-05-03 13:29:17 +02:00
|
|
|
|
2023-05-03 13:42:14 +02:00
|
|
|
distminified: distdirminified dist
|
|
|
|
|
|
|
|
# Remove all unnecessary extra files
|
2023-05-03 14:18:21 +02:00
|
|
|
distdirminified: EXTRAFILES := $(filter-out $(VSCFILES),$(EXTRAFILES))
|
2023-05-03 13:42:14 +02:00
|
|
|
distdirminified: DISTFILES := $(filter-out $(DOXYFILE),$(DISTFILES))
|
2023-05-03 13:29:17 +02:00
|
|
|
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)
|
2023-05-03 14:18:21 +02:00
|
|
|
|
|
|
|
size: $(PROGNAME)
|
|
|
|
size:
|
|
|
|
@$(DU) --total $(PROGNAME) $(filter-out $(VSCFILES) $(DOXYFILE) COPYING,$(EXTRAFILES)) | \
|
|
|
|
$(TAIL) -n 1 | \
|
|
|
|
$(GREP) -o '[0-9]*K'| \
|
2023-05-03 14:19:32 +02:00
|
|
|
$(AWK) '{ \
|
2023-05-03 14:23:59 +02:00
|
|
|
if($$1 <= $(MAXSIZE)) { \
|
|
|
|
printf "> Taille conforme ("; printf $$1; print ")" \
|
2023-05-03 14:18:21 +02:00
|
|
|
} else { \
|
2023-05-03 14:23:59 +02:00
|
|
|
printf "> Fichiers trop lourd ("; printf $$1; print ")" \
|
2023-05-03 14:18:21 +02:00
|
|
|
} \
|
|
|
|
}'
|