2022-05-15 21:04:15 +02:00
|
|
|
# Auteur : Farès BELHADJ (amsi@up8.edu)
|
|
|
|
|
|
|
|
# Définition des commandes utilisées
|
|
|
|
CC = gcc
|
|
|
|
ECHO = echo
|
|
|
|
RM = rm -f
|
|
|
|
TAR = tar
|
|
|
|
ZIP = zip
|
2022-05-12 13:15:23 +02:00
|
|
|
MKDIR = mkdir
|
|
|
|
CHMOD = chmod
|
2022-05-15 21:04:15 +02:00
|
|
|
CP = rsync -R
|
|
|
|
|
|
|
|
# Déclaration des options du compilateur
|
|
|
|
CFLAGS =
|
2022-05-12 13:15:23 +02:00
|
|
|
CPPFLAGS = -I.
|
2022-05-15 21:04:15 +02:00
|
|
|
LDFLAGS = -lm
|
|
|
|
|
|
|
|
# Définition des fichiers et dossiers
|
|
|
|
PACKNAME = projet
|
|
|
|
PROGNAME = demo
|
|
|
|
VERSION = 1.0
|
|
|
|
distdir = $(PACKNAME)_$(PROGNAME)-$(VERSION)
|
|
|
|
HEADERS = $(wildcard includes/*.h)
|
|
|
|
SOURCES = window.c $(wildcard src/*.c)
|
|
|
|
OBJ = $(SOURCES:.c=.o)
|
|
|
|
DOXYFILE = documentation/Doxyfile
|
2022-05-15 21:31:56 +02:00
|
|
|
EXTRAFILES = COPYING $(wildcard shaders/*.?s images/*)
|
2022-05-15 21:04:15 +02:00
|
|
|
DISTFILES = $(SOURCES) Makefile $(HEADERS) $(DOXYFILE) $(EXTRAFILES)
|
|
|
|
|
|
|
|
# Traitements automatiques pour ajout des chemins et options
|
2022-05-12 13:15:23 +02:00
|
|
|
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 = 10.8
|
|
|
|
CFLAGS += -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
|
|
|
|
LDFLAGS += -framework OpenGL -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
|
|
|
|
else
|
|
|
|
LDFLAGS += -lGL
|
|
|
|
endif
|
2022-05-15 21:04:15 +02:00
|
|
|
|
2022-05-12 13:15:23 +02:00
|
|
|
CPPFLAGS += $(shell sdl2-config --cflags)
|
2022-05-19 14:04:52 +02:00
|
|
|
LDFLAGS += -lGL4Dummies $(shell sdl2-config --libs) -lSDL2_mixer -lSDL2_image
|
2022-05-15 21:04:15 +02:00
|
|
|
|
2022-05-12 13:15:23 +02:00
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
2022-05-15 21:04:15 +02:00
|
|
|
|
|
|
|
# Par défaut
|
2022-05-15 21:20:30 +02:00
|
|
|
$(PROGNAME): CFLAGS += -Wall -Wextra -Wshadow -pedantic -g -Wsign-conversion -fanalyzer
|
2022-05-15 21:04:15 +02:00
|
|
|
$(PROGNAME): compilation
|
|
|
|
|
2022-05-15 21:51:49 +02:00
|
|
|
# Version finale avec optimisations
|
2022-05-15 21:04:15 +02:00
|
|
|
release: CFLAGS += -O3
|
|
|
|
release: compilation
|
|
|
|
|
|
|
|
compilation: $(OBJ)
|
|
|
|
$(CC) $(OBJ) $(LDFLAGS) -o $(PROGNAME)
|
|
|
|
|
2022-05-12 13:15:23 +02:00
|
|
|
dist: distdir
|
|
|
|
$(CHMOD) -R a+r $(distdir)
|
|
|
|
$(TAR) zcvf $(distdir).tgz $(distdir)
|
|
|
|
$(RM) -r $(distdir)
|
2022-05-15 21:04:15 +02:00
|
|
|
|
2022-05-12 13:15:23 +02:00
|
|
|
zip: distdir
|
|
|
|
$(CHMOD) -R a+r $(distdir)
|
|
|
|
$(ZIP) -r $(distdir).zip $(distdir)
|
|
|
|
$(RM) -r $(distdir)
|
2022-05-15 21:04:15 +02:00
|
|
|
|
2022-05-12 13:15:23 +02:00
|
|
|
distdir: $(DISTFILES)
|
|
|
|
$(RM) -r $(distdir)
|
|
|
|
$(MKDIR) $(distdir)
|
|
|
|
$(CHMOD) 777 $(distdir)
|
|
|
|
$(CP) $(DISTFILES) $(distdir)
|
2022-05-15 21:04:15 +02:00
|
|
|
|
2022-05-12 13:15:23 +02:00
|
|
|
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 ..
|
2022-05-15 21:04:15 +02:00
|
|
|
|
|
|
|
all: $(PROGNAME)
|
|
|
|
|
2022-05-12 13:15:23 +02:00
|
|
|
clean:
|
|
|
|
@$(RM) -r $(PROGNAME) $(OBJ) *~ $(distdir).tgz $(distdir).zip gmon.out \
|
|
|
|
core.* documentation/*~ shaders/*~ documentation/html
|