Comment rédiger un test de chèque makefile.am avec un fichier source et un en-tête multipers?
-
14-11-2019 - |
Question
Quelqu'un savait-il comment rédiger un chèque makefile.am si nous avons plus que * .c Fichier dans le code de test? Exemple:
#include "../src/SpeedGauge.h"
#include "../src/CruiseManager.h"
#include "../src/Throttle.h"
SpeedGauge speedo;
CruiseManager controller;
Throttle throttle;
/* Test case for - Case1 */
START_TEST (test_Case1)
{
int expected = 11; // TODO: Initialize to an appropriate value
speedo.time = 1111; // TODO: Initialize to an appropriate value
speedo.rotaryCount = 3333; // TODO: Initialize to an appropriate value
// tick: 1
SpeedGauge_calcSpeed(&speedo);
CruiseManager_set(&controller);
Throttle_normal(&throttle);
int result = throttle.throttleVal;
fail_unless (result == expected, "Expecting <%i> instead of <%i>", expected, result);
}
END_TEST
C'est mon makefile.am:
## Process this file with automake to produce Makefile.in
lib_LTLIBRARIES = libSpeedGauge.la libCruiseManager.la libThrottle.la
libSpeedGauge_la_SOURCES = SpeedGauge.c SpeedGauge.h CruiseManager.c CruiseManager.h Throttle.c Throttle.h
bin_PROGRAMS = main
main_SOURCES = main.c
main_LDADD = libSpeedGauge.la libCruiseManager.la libThrottle.la
J'ai eu une erreur en disant ceci:
libtool: link: ranlib .libs/libSpeedGauge.a
libtool: link: ( cd ".libs" && rm -f "libSpeedGauge.la" && ln -s "../libSpeedGauge.la" "libSpeedGauge.la" )
make[2]: *** No rule to make target `libCruiseManager.lo', needed by `libCruiseManager.la'. Stop.
make[2]: Leaving directory `/home/mjaa001/Desktop/cruisecontrol/src'
make[1]: *** [all-recursive] Error 1
Il semble qu'il ne puisse pas lier le code de compilation. Ai-je spécifié la classe Lib à tort ou j'ai besoin d'un seul fichier de classe uniquement?
Mise à jour
Résoudre en modifiant le makefile.am à partir de
libSpeedGauge_la_SOURCES = SpeedGauge.c SpeedGauge.h CruiseManager.c CruiseManager.h Throttle.c Throttle.h
à
libSpeedGauge_la_SOURCES = SpeedGauge.c SpeedGauge.h
libCruiseManager_la_SOURCES = CruiseManager.c CruiseManager.h
libThrottle_la_SOURCES = Throttle.c Throttle.h
La solution
lib_LTLIBRARIES = libSpeedGauge.la libCruiseManager.la libThrottle.la
libCruiseManager_la_SOURCES = ...
ou
## Process this file with automake to produce Makefile.in
lib_LTLIBRARIES = libSpeedGauge.la
libSpeedGauge_la_SOURCES = SpeedGauge.c CruiseManager.c Throttle.c
bin_PROGRAMS = main
main_SOURCES = main.c
main_LDADD = libSpeedGauge.la
Autres conseils
LIB_LTBIBRARES sont des bibliothèques qui doivent être construites par Automake (en conjonction avec LiBtool). Vous n'avez pas spécifié le libspeedguage_la_sources. Regardez la réponse d'AAA pour plus de détails sur la façon de le faire.
Si vous vouliez seulement faire référence à une bibliothèque qui est déjà construite, utilisez _LDADD (mais omettez la directive LIB_LTLIBRARY).