summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschodet2006-03-09 21:47:36 +0000
committerschodet2006-03-09 21:47:36 +0000
commit3be1cb1479ecfaba4d39117d09b39e0e1e17402f (patch)
tree0e6493f3bfa73cd3df54bea5bdbe71db9f1fdfc9
parent9663eddfb74a97f89f9bb98a8e68409d2958110b (diff)
Génération automatique des règles de compilation pour les programmes.
Suppression du problème de dépendance des SUBDIRS grâce à ça. Support de la compilation en exterieur (en ajoutant des sources d'un autre répertoire, prochainement un exemple dans n/asserv/utils). Réajout de -O2.
-rw-r--r--i/marvin/src/Makefile.defs24
-rw-r--r--i/marvin/src/asserv/Makefile.defs2
-rw-r--r--i/marvin/src/config/Makefile.defs2
-rw-r--r--i/marvin/src/data/Makefile.defs4
-rw-r--r--i/marvin/src/log/Makefile.defs2
-rw-r--r--i/marvin/src/motor/Makefile.defs2
-rw-r--r--i/marvin/src/proto/Makefile.defs2
-rw-r--r--i/marvin/src/scheduler/Makefile.defs2
-rw-r--r--i/marvin/src/serial/Makefile.defs2
-rw-r--r--i/marvin/src/socket/Makefile.defs3
-rw-r--r--i/marvin/src/tester/Makefile.defs2
-rw-r--r--i/marvin/src/timer/Makefile.defs2
-rw-r--r--i/marvin/src/utils/Makefile.defs6
-rw-r--r--i/marvin/src/utils/meta/Makefile.defs2
14 files changed, 13 insertions, 44 deletions
diff --git a/i/marvin/src/Makefile.defs b/i/marvin/src/Makefile.defs
index 3f569e6..09f35b0 100644
--- a/i/marvin/src/Makefile.defs
+++ b/i/marvin/src/Makefile.defs
@@ -5,7 +5,7 @@ INCLUDES = -I$(SRCDIR) -I.
# Tests de coverage (man gcov).
ifeq ($(COV),)
-#CXXFLAGS += -O2
+CXXFLAGS += -O2
else
CXXFLAGS += -fprofile-arcs -ftest-coverage
endif
@@ -16,38 +16,40 @@ CXXFLAGS += -pg
LDFLAGS += -pg
endif
-
# Messages sur une ligne.
CXXFLAGS += -fmessage-length=0
-# Attention, il y a un problme de dpendences dans l'ordre des SUBDIRS
-# cause de la gnration des rgles.
SUBDIRS = utils utils/meta \
tester \
log serial timer \
config data scheduler \
- proto asserv\
+ proto asserv \
motor
LINK.o = $(CXX) $(LDFLAGS) $(TARGET_ARCH)
LEX = flex
YACC = bison
-VPATH = $(SUBDIRS:%=$(SRCDIR)/%)
-
-PROGRAMS =
-LIBS =
-EXTRA_CLEAN =
+vpath %.cc $(SUBDIRS:%=$(SRCDIR)/%) $(EXTRA_SUBDIRS)
+vpath %.ll $(SUBDIRS:%=$(SRCDIR)/%) $(EXTRA_SUBDIRS)
+vpath %.yy $(SUBDIRS:%=$(SRCDIR)/%) $(EXTRA_SUBDIRS)
all: build-all
# Inclus les autres rpertoires.
-include $(SUBDIRS:%=$(SRCDIR)/%/Makefile.defs)
+include $(SUBDIRS:%=$(SRCDIR)/%/Makefile.defs) \
+ $(EXTRA_SUBDIRS:%=%/Makefile.defs)
OBJECTS = $(filter %.o,$(foreach PROGRAM,$(PROGRAMS),$($(PROGRAM)_OBJECTS)))
build-all: $(PROGRAMS)
+define PROGRAMS_template
+$(1): $$($(1)_OBJECTS)
+endef
+
+$(foreach prog,$(PROGRAMS),$(eval $(call PROGRAMS_template,$(prog))))
+
# Rgles.
%.cc: %.ll
$(LEX) $<
diff --git a/i/marvin/src/asserv/Makefile.defs b/i/marvin/src/asserv/Makefile.defs
index 80bf8ee..c56d34c 100644
--- a/i/marvin/src/asserv/Makefile.defs
+++ b/i/marvin/src/asserv/Makefile.defs
@@ -3,5 +3,3 @@ PROGRAMS += test_asserv
asserv_OBJECTS = asserv.o
test_asserv_OBJECTS = test_asserv.o $(asserv_OBJECTS) $(config_OBJECTS) $(timer_OBJECTS) $(proto_OBJECTS) $(log_OBJECTS) $(serial_OBJECTS) $(utils_OBJECTS)
-
-test_asserv: $(test_asserv_OBJECTS)
diff --git a/i/marvin/src/config/Makefile.defs b/i/marvin/src/config/Makefile.defs
index d255c9b..500470c 100644
--- a/i/marvin/src/config/Makefile.defs
+++ b/i/marvin/src/config/Makefile.defs
@@ -6,8 +6,6 @@ test_config_data_OBJECTS = $(config_OBJECTS) test_config_data.o
EXTRA_CLEAN += parser.hh parser.cc lexer.hh lexer.cc
-test_config_data: $(test_config_data_OBJECTS)
-
parser.hh: parser.cc
lexer.o: parser.hh
diff --git a/i/marvin/src/data/Makefile.defs b/i/marvin/src/data/Makefile.defs
index 31698f1..54e6cb6 100644
--- a/i/marvin/src/data/Makefile.defs
+++ b/i/marvin/src/data/Makefile.defs
@@ -6,7 +6,3 @@ data_OBJECTS = data_input.o data_input_file.o data_input_zlib.o \
test_data_OBJECTS = test_data.o $(data_OBJECTS)
test_data_buffer_OBJECTS = test_data_buffer.o data_buffer.o
-
-test_data: $(test_data_OBJECTS)
-
-test_data_buffer: $(test_data_buffer_OBJECTS)
diff --git a/i/marvin/src/log/Makefile.defs b/i/marvin/src/log/Makefile.defs
index 8462793..d160eb1 100644
--- a/i/marvin/src/log/Makefile.defs
+++ b/i/marvin/src/log/Makefile.defs
@@ -3,5 +3,3 @@ PROGRAMS += test_log
log_OBJECTS = log.o log_message.o
test_log_OBJECTS = test_log.o $(log_OBJECTS)
-
-test_log: $(test_log_OBJECTS)
diff --git a/i/marvin/src/motor/Makefile.defs b/i/marvin/src/motor/Makefile.defs
index 51c658c..4867e00 100644
--- a/i/marvin/src/motor/Makefile.defs
+++ b/i/marvin/src/motor/Makefile.defs
@@ -6,5 +6,3 @@ test_motor_OBJECTS = test_motor.o $(motor_OBJECTS) $(timer_OBJECTS) \
$(config_OBJECTS) $(serial_OBJECTS) \
$(asserv_OBJECTS) $(proto_OBJECTS) $(log_OBJECTS) \
$(utils_OBJECTS)
-
-test_motor: $(test_motor_OBJECTS)
diff --git a/i/marvin/src/proto/Makefile.defs b/i/marvin/src/proto/Makefile.defs
index fa984bc..ffad4dc 100644
--- a/i/marvin/src/proto/Makefile.defs
+++ b/i/marvin/src/proto/Makefile.defs
@@ -4,5 +4,3 @@ proto_OBJECTS = proto.o
test_proto_OBJECTS = test_proto.o $(proto_OBJECTS) $(utils_OBJECTS) \
$(serial_OBJECTS) $(timer_OBJECTS) $(log_OBJECTS)
-
-test_proto: $(test_proto_OBJECTS)
diff --git a/i/marvin/src/scheduler/Makefile.defs b/i/marvin/src/scheduler/Makefile.defs
index 9aff718..fc6c157 100644
--- a/i/marvin/src/scheduler/Makefile.defs
+++ b/i/marvin/src/scheduler/Makefile.defs
@@ -5,5 +5,3 @@ scheduler_OBJECTS = scheduler.o schedulable_read_fd.o schedulable_alarm.o
test_scheduler_OBJECTS = \
test_scheduler.o scheduler.o schedulable_read_fd.o schedulable_alarm.o \
$(timer_OBJECTS)
-
-test_scheduler: $(test_scheduler_OBJECTS)
diff --git a/i/marvin/src/serial/Makefile.defs b/i/marvin/src/serial/Makefile.defs
index 0ece3d9..fcf71f9 100644
--- a/i/marvin/src/serial/Makefile.defs
+++ b/i/marvin/src/serial/Makefile.defs
@@ -3,5 +3,3 @@ PROGRAMS += test_serial
serial_OBJECTS = serial.o serial_base.o serial_dev.o serial_stdio.o
test_serial_OBJECTS = test_serial.o $(serial_OBJECTS) $(utils_OBJECTS)
-
-test_serial: $(test_serial_OBJECTS)
diff --git a/i/marvin/src/socket/Makefile.defs b/i/marvin/src/socket/Makefile.defs
index c125e61..b3a03cc 100644
--- a/i/marvin/src/socket/Makefile.defs
+++ b/i/marvin/src/socket/Makefile.defs
@@ -4,6 +4,3 @@ net_OBJECTS = address.o server_socket.o socket_text.o
test_socket_OBJECTS = test_socket.o $(net_OBJECTS) $(data_OBJECTS)
test_server_OBJECTS = test_server.o $(net_OBJECTS) $(data_OBJECTS) $(image_OBJECTS)
-
-test_socket: $(test_socket_OBJECTS)
-test_server: $(test_server_OBJECTS)
diff --git a/i/marvin/src/tester/Makefile.defs b/i/marvin/src/tester/Makefile.defs
index 834cae6..d0e6b73 100644
--- a/i/marvin/src/tester/Makefile.defs
+++ b/i/marvin/src/tester/Makefile.defs
@@ -3,5 +3,3 @@ PROGRAMS += test_tester
tester_OBJECTS = tester.o
test_tester_OBJECTS = test_tester.o $(tester_OBJECTS) $(utils_OBJECTS)
-
-test_tester: $(test_tester_OBJECTS)
diff --git a/i/marvin/src/timer/Makefile.defs b/i/marvin/src/timer/Makefile.defs
index e7b58cc..81a57e2 100644
--- a/i/marvin/src/timer/Makefile.defs
+++ b/i/marvin/src/timer/Makefile.defs
@@ -3,5 +3,3 @@ PROGRAMS += test_timer
timer_OBJECTS = timer.o
test_timer_OBJECTS = test_timer.o $(timer_OBJECTS)
-
-test_timer: $(test_timer_OBJECTS)
diff --git a/i/marvin/src/utils/Makefile.defs b/i/marvin/src/utils/Makefile.defs
index 43711a8..ebd316c 100644
--- a/i/marvin/src/utils/Makefile.defs
+++ b/i/marvin/src/utils/Makefile.defs
@@ -7,9 +7,3 @@ test_any_OBJECTS = test_any.o
test_callback_OBJECTS = test_callback.o
test_bind_OBJECTS = test_bind.o
-
-test_any: $(test_any_OBJECTS)
-
-test_callback: $(test_callback_OBJECTS)
-
-test_bind: $(test_bind_OBJECTS)
diff --git a/i/marvin/src/utils/meta/Makefile.defs b/i/marvin/src/utils/meta/Makefile.defs
index 929205e..8fa3a10 100644
--- a/i/marvin/src/utils/meta/Makefile.defs
+++ b/i/marvin/src/utils/meta/Makefile.defs
@@ -1,5 +1,3 @@
PROGRAMS += test_meta
test_meta_OBJECTS = test_meta.o
-
-test_meta: $(test_meta_OBJECTS)