Reputation: 195
# Macros
CC = gcc
COMP_FLAG = -std=c99 -Wall -pedantic-errors -Werror -DNDEBUG
LIB_FLAG = -L. -lmtm -lex1
# Main target
tests: yad3_test realtor_test customer_test
# Targets make <file>
yad3_test: yad3_test.o yad3.o realtor.o customer.o
$(CC) yad3_test.o yad3.o realtor.o customer.o $(LIB_FLAG) -o $@
yad3_test.o: tests/yad3_test.c yad3.h customer.h realtor.h apartment_service.h apartment.h tests/test_utilities.h mtm_ex2.h
$(CC) -c $(COMP_FLAG) $(LIB_FLAG) tests/$*.c
yad3.o: yad3.c yad3.h customer.h realtor.h apartment_service.h apartment.h mtm_ex2.h list.h map.h
$(CC) -c $(COMP_FLAG) $(LIB_FLAG) $*.c
realtor.o: realtor.c realtor.h apartment_service.h apartment.h map.h
$(CC) -c $(COMP_FLAG) $(LIB_FLAG) $*.c
customer.o: customer.c map.h customer.h
$(CC) -c $(COMP_FLAG) $(LIB_FLAG) $*.c
realtor_test: realtor_test.o realtor.o
$(CC) realtor_test.o realtor.o $(LIB_FLAG) -o $@
realtor_test.o: tests/realtor_test.c realtor.h apartment_service.h apartment.h tests/test_utilities.h
$(CC) -c $(COMP_FLAG) $(LIB_FLAG) tests/$*.c
#realtor.o: realtor.c realtor.h apartment_service.h apartment.h map.h
# $(CC) -c $(COMP_FLAG) $(LIB_FLAG) $*.c
customer_test: customer_test.o customer.o
$(CC) customer_test.o customer.o $(LIB_FLAG) -o $@
customer_test.o: tests/customer_test.c customer.h tests/test_utilities.h
$(CC) -c $(COMP_FLAG) $(LIB_FLAG) tests/$*.c
#customer.o: customer.c map.h customer.h
# $(CC) -c $(COMP_FLAG) $(LIB_FLAG) $*.c
run: run_yad3_test run_realtor_test run_customer_test
run_clean: clean run
#run_my_set_test: my_set_test
# ./my_set_test
run_yad3_test: yad3_test
./yad3_test
realtor_test_test: realtor_test
./realtor_test
run_customer_test: customer_test
./customer_test
# Target remove all <*_test> and <*.o> files
clean: clean_o clean_test
clean_test:
rm -f *_test
clean_o:
rm -f *.o
Is there any logical reason that the compiling is working fine, but it doesn't run the final created tests properly ???
It seemed to be written correctly adn there is not any reason. it shouldn't work. Help anybody?
Upvotes: 0
Views: 169
Reputation: 11526
By default make
run the first target of the file, so you can just move the run
rule at the top and make
will make run
.
Also since GNU Make 3.81
a .DEFAULT_GOAL
permit to override this behavior, so, if you want, keep the actual order, add:
.DEFAULT_GOAL = run
Upvotes: 1