1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-05-21 14:16:22 +02:00
cdf2018-principal/chef/Makefile

61 lines
1.5 KiB
Makefile

# VARIABLES
## Compilateur
CC=gcc
# Bibliothèques
LIBS=
## Drapeaux pour le linker
LDFLAGS_CUSTOM += -lpthread -lwiringPi
## Drapeaux pour le compilateur
CFLAGS=
## Générateurs de drapeaux pour les bibliothèques
PKG_CONFIG=pkg-config
# VARIABLES AUTOMATIQUES
ifdef LIBS
LDFLAGS_CUSTOM += $(shell $(PKG_CONFIG) --libs $(LIBS))
CFLAGS += $(shell $(PKG_CONFIG) --cflags $(LIBS))
endif
# Par défaut on affiche les warnings et on ajoute les symboles de debug pour utiliser GDB
CFLAGS += -Wall -Wextra -pedantic -g -DDEBUG
# buildroot se charge de remplacer ces flags avec des optimisations
# RÈGLES AUTOMATIQUES DE COMPILATION
# Génération des fichiers éxecutables
bin/%: obj/%.o
$(CC) $(LDFLAGS_CUSTOM) $^ -o $@
# On enlève les symboles inutiles pour gagner en temps de chargement de l'éxecutable
ifeq ($(DEBUG),no)
strip $@
endif
# RÈGLES DE COMPILATION
# Règle éxecutée par défaut (quand on fait juste `make`)
default: bin/testpin bin/premier bin/local
# Binaires (dont il faut spécifier les objets explicitement)
bin/premier: obj/CF.o obj/movement.o obj/debug.o obj/position.o
bin/testPin: obj/testPin.o
bin/local: obj/local.o obj/CF.o obj/position.o
$(CC) -lpthread $^ -o $@
# Génération des fichiers objets
obj/%.o: src/%.c src/%.h
$(CC) $(CFLAGS) -c $< -o $@
obj/%.o: src/%.c
$(CC) $(CFLAGS) -c $< -o $@
# OUTILS DE DÉVELOPPEMENT
# Supprime les fichiers automatiquement générés
clean:
rm -f obj/*
rm -f bin/*
# Au cas où des fichiers avec certains noms existent, les règles suivantes seront executées quand même
.PHONY: default clean