CC=gcc
CFLAGS=-Wall -Wextra -O2 -std=c11

#le type par défaut des données est int
TYPE ?= int

#make … -DDATA=float définit, au moment de la compilation, le macro
#DATA comme l'identificateur float.

#si DATA est int (les données sont des int)
ifeq ($(TYPE),int)
  CFLAGS += -DDATA=int -DDATA_IS_INT
endif

ifeq ($(TYPE),float)
  CFLAGS += -DDATA=float -DDATA_IS_FLOAT
endif

ifeq ($(TYPE),string)
  CFLAGS += -DDATA='char*' -DDATA_IS_STRING
endif

OBJS=projet.o tests.o

all: tests

tests: $(OBJS)
	$(CC) $(CFLAGS) -o $@ $(OBJS)

# $< : le premier prérequis, ici projet.c
projet.o: projet.c projet.h bibli.h
	$(CC) $(CFLAGS) -c $<

stack.o: stack.c projet.h bibli.h
	$(CC) $(CFLAGS) -c $<

queue.o: queue.c projet.h bibli.h
	$(CC) $(CFLAGS) -c $<

tests.o: tests.c projet.h bibli.h
	$(CC) $(CFLAGS) -c $<

run: tests
	./tests

clean:
	rm -f *.o tests
