2023-03-18 17:51:56 +01:00
# Makefile
# Auteur : Farès BELHADJ
# Email : amsi@up8.edu
# Date : 28/04/2020
# Définition des commandes utilisées
CC = gcc
ECHO = echo
RM = rm -f
TAR = tar
ZIP = zip
MKDIR = mkdir
CHMOD = chmod
CP = rsync -R
# Déclaration des options du compilateur
CFLAGS = -Wall -O3
CPPFLAGS = -I.
LDFLAGS = -lm
# Définition des fichiers et dossiers
PACKNAME = api8_2023
PROGNAME = demo
VERSION = 0.1
distdir = $( PACKNAME) _$( PROGNAME) -$( VERSION)
HEADERS =
SOURCES = main.c
MSVCSRC = $( patsubst %,<ClCompile Include = \" %\\ \" \\ />,$( SOURCES) )
OBJ = $( SOURCES:.c= .o)
DOXYFILE = documentation/Doxyfile
VSCFILES = $( PROGNAME) .vcxproj $( PROGNAME) .sln
EXTRAFILES = COPYING $( wildcard shaders/*.?s images/*.png) $( VSCFILES)
DISTFILES = $( SOURCES) Makefile $( HEADERS) $( DOXYFILE) $( EXTRAFILES)
# Traitements automatiques pour ajout de chemins et options (ne pas modifier)
i f n e q ( , $( shell ls -d /usr /local /include 2>/dev /null | tail -n 1) )
CPPFLAGS += -I/usr/local/include
e n d i f
i f n e q ( , $( shell ls -d $ ( HOME ) /local /include 2>/dev /null | tail -n 1) )
CPPFLAGS += -I$( HOME) /local/include
e n d i f
i f n e q ( , $( shell ls -d /usr /local /lib 2>/dev /null | tail -n 1) )
LDFLAGS += -L/usr/local/lib
e n d i f
i f n e q ( , $( shell ls -d $ ( HOME ) /local /lib 2>/dev /null | tail -n 1) )
LDFLAGS += -L$( HOME) /local/lib
e n d i f
i f e q ( $( shell uname ) , D a r w i n )
MACOSX_DEPLOYMENT_TARGET = 11.0
CFLAGS += -mmacosx-version-min= $( MACOSX_DEPLOYMENT_TARGET)
LDFLAGS += -framework OpenGL -mmacosx-version-min= $( MACOSX_DEPLOYMENT_TARGET)
e l s e
LDFLAGS += -lGL
e n d i f
CPPFLAGS += $( shell sdl2-config --cflags)
LDFLAGS += -lGL4Dummies $( shell sdl2-config --libs)
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 $@ ... "
@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) / " > $@
clean :
@$( RM) -r $( PROGNAME) $( OBJ) *~ $( distdir) .tgz $( distdir) .zip gmon.out \
core.* documentation/*~ shaders/*~ documentation/html