1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-06-30 06:55:24 +02:00
cdf2018-principal/chef/Makefile

63 lines
1.8 KiB
Makefile
Raw Normal View History

2018-02-07 17:57:01 +01:00
# VARIABLES
## Compilateur
CC=gcc
# Bibliothèques
LIBS=
## Drapeaux pour le linker
2018-04-04 16:17:13 +02:00
LDFLAGS_CUSTOM += -lpthread -lwiringPi
2018-02-07 17:57:01 +01:00
## Drapeaux pour le compilateur
2018-04-30 16:15:10 +02:00
CFLAGS_CUSTOM += -g
2018-02-07 17:57:01 +01:00
## Générateurs de drapeaux pour les bibliothèques
PKG_CONFIG=pkg-config
# VARIABLES AUTOMATIQUES
ifdef LIBS
2018-04-04 16:17:13 +02:00
LDFLAGS_CUSTOM += $(shell $(PKG_CONFIG) --libs $(LIBS))
2018-02-07 17:57:01 +01:00
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
2018-04-30 16:15:10 +02:00
$(CC) $(LDFLAGS) $(LDFLAGS_CUSTOM) $^ -o $@
$(OBJCOPY) --only-keep-debug $@ $@.debug
$(STRIP) --strip-debug --strip-unneeded $@
2018-02-07 17:57:01 +01:00
# RÈGLES DE COMPILATION
# Règle éxecutée par défaut (quand on fait juste `make`)
2018-04-29 21:57:29 +02:00
default: bin/testpin bin/premier bin/local bin/testI2c
2018-02-07 17:57:01 +01:00
# Binaires (dont il faut spécifier les objets explicitement)
2018-04-30 16:15:10 +02:00
OBJS=CF movement debug position ihm lcd i2c points parcours
bin/premier: $(addprefix obj/,$(addsuffix .o,$(OBJS)))
2018-02-07 17:57:01 +01:00
bin/testPin: obj/testPin.o
2018-04-30 16:15:10 +02:00
# TODO ↑ Enlever (remplacé par IHM)
2018-04-29 09:38:49 +02:00
bin/testI2c: obj/testI2c.o obj/i2c.o obj/srf08.o obj/lcd.o
2018-04-04 16:17:13 +02:00
2018-04-30 16:15:10 +02:00
# Programme de test sur PC, n'embarquant pas wiringPi
2018-04-29 09:38:49 +02:00
bin/local: obj/local.o obj/debug.o
2018-04-30 16:15:10 +02:00
$(CC) $(CFLAGS) $(CFLAGS_CUSTOM) -lpthread $^ -o $@
2018-02-07 17:57:01 +01:00
# Génération des fichiers objets
obj/%.o: src/%.c src/%.h
2018-04-30 16:15:10 +02:00
$(CC) $(CFLAGS) $(CFLAGS_CUSTOM) -c $< -o $@
2018-02-07 17:57:01 +01:00
obj/%.o: src/%.c
2018-04-30 16:15:10 +02:00
$(CC) $(CFLAGS) $(CFLAGS_CUSTOM) -c $< -o $@
2018-02-07 17:57:01 +01:00
# 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