c't

c't-Projekte - Mailinglisten


[Voriger (Datum)] [Nächster (Datum)] [Voriger (Thread)] [Nächster (Thread)]
[Nach Datum][Nach Thread]

Re: [ct-bot] make-Target für Bibliothek

Absender: Simon Siemens
Datum: Do, 19.05.2011 12:06:47
In-reply-to: <22D4A102-B690-4C77-B713-3023EEF6B013@xxxxxxxxxxxxxxx>
References: <1305221409.10999.72.camel@wbam-laptop> <1305652707.2322.17.camel@wbam-laptop> <22D4A102-B690-4C77-B713-3023EEF6B013@xxxxxxxxxxxxxxx>


Hi Timo,

entschuldige bitte den Fehler. (Auf meinem System waren die beiden
binutils-Versionen wohl zu Ãhnlich, als dass der Fehler aufgefallen
wÃre.)

libctbot.a wird aber schon immer bei make clean gelÃscht. Im Makefile
steht

	$(REMOVE) $(LIBRARY)

Die Ãberlegung mit den Namen (pre_behaviour, post_behaviour, init, ...)
kann ich gut nachvollziehen. Ich fragte mich selbiges auch, beschloss
dann aber, einen Patch einzureichen, der am wenigsten invasiv ist. Ich
hÃtte eher den Namen init.c geÃndert.

Herzliche GrÃÃe,

Simon


Am Dienstag, den 17.05.2011, 22:18 +0200 schrieb Timo Sandmann:
> Hi Simon,
> 
> das neue Makefile scheint einen Bug zu haben, es funktioniert fÃr PC-Code, der Buildprozess fÃr MCU scheitert aber:
> 
> ar: creating archive libctbot.a
> ranlib libctbot.a
> ranlib: warning for library: libctbot.a the table of contents is empty (no object file members in the library define global symbols)
> 
> Linking: ct-Bot.elf
> avr-gcc --output ct-Bot.elf -mmcu=atmega32 -Wl,--section-start=.bootloader=0x7C00    -L /usr/local/avr ct-Bot.o bot-logic/behaviour_avoid_border.o bot-logic/behaviour_avoid_col.o bot-logic/behaviour_calibrate_pid.o bot-logic/behaviour_calibrate_sharps.o bot-logic/behaviour_cancel_behaviour.o bot-logic/behaviour_catch_pillar.o bot-logic/behaviour_classify_objects.o bot-logic/behaviour_delay.o bot-logic/behaviour_drive_area.o bot-logic/behaviour_drive_chess.o bot-logic/behaviour_drive_distance.o bot-logic/behaviour_drive_square.o bot-logic/behaviour_drive_stack.o bot-logic/behaviour_follow_line_enhanced.o bot-logic/behaviour_follow_line.o bot-logic/behaviour_follow_object.o bot-logic/behaviour_follow_wall.o bot-logic/behaviour_get_utilization.o bot-logic/behaviour_goto_obstacle.o bot-logic/behaviour_goto_pos.o bot-logic/behaviour_goto.o bot-logic/behaviour_gotoxy.o bot-logic/behaviour_hang_on.o bot-logic/behaviour_line_shortest_way.o bot-logic/behaviour_measure_distance.o bot-logic/behaviour_olympic.o bot-logic/behaviour_pathplaning.o bot-logic/behaviour_remotecall.o bot-logic/behaviour_scan.o bot-logic/behaviour_scan_beacons.o bot-logic/behaviour_servo.o bot-logic/behaviour_simple.o bot-logic/behaviour_solve_maze.o bot-logic/behaviour_transport_pillar.o bot-logic/behaviour_turn.o bot-logic/behaviour_ubasic.o bot-logic/bot-logic.o bot-logic/tokenizer.o bot-logic/ubasic_call.o bot-logic/ubasic_cvars.o bot-logic/ubasic_ext_proc.o bot-logic/ubasic.o libctbot.a -lm
> libctbot.a: could not read symbols: Archive has no index; run ranlib to add one
> make: *** [ct-Bot.elf] Error 1
> 
> 
> Ich glaube, du verwendest ar und ranlib fÃr die falsche Architektur, nÃmlich vom Build und nicht fÃr das Target (AVR).
> AuÃerdem sollte das Makefile bei make clean auch die Library lÃschen.
> 
> 
> Der main()-Patch ist jetzt im SVN. Ich werde daran aber wahrscheinlich noch eine Kleinigkeit Ãndern, weil ich finde pre_behaviour() und post_behaviour() sind in init.c (vom Namen her) nicht ideal aufgehoben. Wenn mir ein passender Name eingefallen ist, werde ich die Funktionen entsprechend verschieben. 
> 
> GrÃÃe,
> Timo
> 
> 
> Am 17.05.2011 um 19:18 schrieb Simon Siemens:
> > Hi Timo,
> > 
> > anbei der verbesserte Patch. Damit wird ct-Bot.elf nun mit Hilfe von
> > libctbot.a gebaut, wenn man make verwendet. Der neue Patch behebt auch
> > zwei kleine Fehler im alten Patch.
> > 
> > Herzliche GrÃÃe,
> > 
> > Simon
> 
> 
> _______________________________________________
> ct-bot-entwickler Mailingliste
> ct-bot-entwickler@xxxxxxxxxxxxxxxxx
> http://www.heise.de/bin/newsletter/listinfo/ct-bot-entwickler

Index: Makefile
===================================================================
--- Makefile	(Revision 1786)
+++ Makefile	(Arbeitskopie)
@@ -16,6 +16,8 @@
 #
 # make all = Make software.
 #
+# make library = Build a library (libctbot.a) of the infrastructure components
+#
 # make clean = Clean out built project files.
 #
 # make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
@@ -41,6 +43,9 @@
 # Target file name (without extension).
 TARGET = ct-Bot
 
+# Name of the library that contains the hardware abstraction layer
+LIBRARY = libctbot.a
+
 # Target Device, either pc or mcu, usually defined on commandline
 DEVICE ?= MCU
 #DEVICE ?= PC
@@ -52,7 +57,10 @@
 
 SRCPC = pc/bot-2-sim_pc.c pc/botfs_pc.c pc/botfs-low_pc.c pc/botfs-tools_pc.c pc/cmd-tools_pc.c pc/delay_pc.c pc/display_pc.c pc/eeprom_pc.c pc/ena_pc.c pc/init-low_pc.c pc/ir-rc5_pc.c pc/led_pc.c pc/mini-fat_pc.c pc/mmc-emu_pc.c pc/motor-low_pc.c pc/mouse_pc.c pc/os_thread_pc.c pc/sensor-low_pc.c pc/tcp-server.c pc/tcp.c pc/timer-low_pc.c pc/trace.c
 
-SRCCOM = bot-2-bot.c botfs.c command.c $(TARGET).c fifo.c init.c log.c map.c math_utils.c minilog.c mmc-vm.c motor.c pos_store.c sensor.c timer.c 
+SRCCOM = bot-2-bot.c botfs.c command.c fifo.c init.c log.c map.c math_utils.c minilog.c mmc-vm.c motor.c pos_store.c sensor.c timer.c 
+
+SRCMAIN = $(TARGET).c
+
 SRCUI = ui/gui.c ui/misc.c ui/rc5.c
 
 SRCLOGIC = bot-logic/behaviour_avoid_border.c bot-logic/behaviour_avoid_col.c bot-logic/behaviour_calibrate_pid.c bot-logic/behaviour_calibrate_sharps.c bot-logic/behaviour_cancel_behaviour.c bot-logic/behaviour_catch_pillar.c bot-logic/behaviour_classify_objects.c bot-logic/behaviour_delay.c bot-logic/behaviour_drive_area.c bot-logic/behaviour_drive_chess.c bot-logic/behaviour_drive_distance.c bot-logic/behaviour_drive_square.c bot-logic/behaviour_drive_stack.c bot-logic/behaviour_follow_line_enhanced.c bot-logic/behaviour_follow_line.c bot-logic/behaviour_follow_object.c bot-logic/behaviour_follow_wall.c bot-logic/behaviour_get_utilization.c bot-logic/behaviour_goto_obstacle.c bot-logic/behaviour_goto_pos.c bot-logic/behaviour_goto.c bot-logic/behaviour_gotoxy.c bot-logic/behaviour_hang_on.c bot-logic/behaviour_line_shortest_way.c bot-logic/behaviour_measure_distance.c bot-logic/behaviour_olympic.c bot-logic/behaviour_pathplaning.c bot-logic/behaviour_remotecall.c bot-logic/behaviour_scan.c bot-logic/behaviour_scan_beacons.c bot-logic/behaviour_servo.c bot-logic/behaviour_simple.c bot-logic/behaviour_solve_maze.c bot-logic/behaviour_transport_pillar.c bot-logic/behaviour_turn.c bot-logic/behaviour_ubasic.c bot-logic/bot-logic.c bot-logic/tokenizer.c bot-logic/ubasic_call.c bot-logic/ubasic_cvars.c bot-logic/ubasic_ext_proc.c bot-logic/ubasic.c
@@ -65,7 +73,8 @@
 #else
 #	SRC = $(TARGET).c $(SRCCOM) $(SRCPC)
 #endif
-SRC =$(SRCCOM) $(SRCUI) $(SRCPC) $(SRCMCU) $(SRCLOGIC)
+SRCLIBRARY = $(SRCCOM) $(SRCUI) $(SRCPC) $(SRCMCU)
+SRCBEHAVIOUR = $(SRCMAIN) $(SRCLOGIC)
 
 
 # List Assembler source files here.
@@ -191,22 +200,26 @@
 	DIRAVRUTILS = $(DIRAVR)/utils/bin
 	DIRINC = $(DIRAVR)/include
 	DIRLIB = $(DIRAVR)/lib/avr5
-	
+
+	AR = avr-ar
+	AVRDUDE = avrdude
 	CC = avr-gcc
+	NM = avr-nm
 	OBJCOPY = avr-objcopy
 	OBJDUMP = avr-objdump
+	RANLIB = avr-ranlib
 	SIZE = avr-size
-	NM = avr-nm
-	AVRDUDE = avrdude
 
 else
 	# List any extra directories to look for include files here.
 	#     Each directory must be seperated by a space.
 	EXTRAINCDIRS = include
 
-	CC = gcc 
 	PTHREAD_LIB = -lpthread
 	LDFLAGS += $(PTHREAD_LIB)  $(MATH_LIB)
+
+	CC = gcc
+	RANLIB = ranlib
 	SIZE = size
 endif
 
@@ -258,7 +271,10 @@
 
 ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
 
+# Flags for the library archiver (ar)
+ARFLAGS = r
 
+
 # Define Messages
 # English
 MSG_ERRORS_NONE = Errors: none
@@ -276,12 +292,14 @@
 MSG_COMPILING = Compiling:
 MSG_ASSEMBLING = Assembling:
 MSG_CLEANING = Cleaning project:
+MSG_CREATING_LIBRARY = Creating library:
 
 
 
 
 # Define all object files.
-OBJ = $(ASRC:.S=.o) $(SRC:.c=.o)
+OBJLIBRARY = $(ASRC:.S=.o) $(SRCLIBRARY:.c=.o)
+OBJBEHAVIOUR = $(SRCBEHAVIOUR:.c=.o)
 
 # Define all listing files.
 LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
@@ -319,6 +337,7 @@
 lss: $(TARGET).lss 
 sym: $(TARGET).sym
 
+library: $(LIBRARY)
 
 # Eye candy.
 # AVR Studio 3.x does not check make's exit code but relies on
@@ -381,6 +400,11 @@
 	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
 
 
+$(LIBRARY): $(OBJLIBRARY)
+	@echo
+	@echo $(MSG_CREATING_LIBRARY) $@
+	$(AR) $(ARFLAGS) $@ $^
+	$(RANLIB) $@
 
 # Create final output files (.hex, .eep) from ELF output file.
 %.hex: %.elf
@@ -410,11 +434,11 @@
 
 # Link: create ELF output file from object files.
 .SECONDARY : $(TARGET).elf
-.PRECIOUS : $(OBJ)
-%.elf: $(OBJ)
+.PRECIOUS : $(OBJBEHAVIOUR)
+%.elf: $(OBJBEHAVIOUR) $(LIBRARY)
 	@echo
 	@echo $(MSG_LINKING) $@
-	$(CC) --output $@ $(LDFLAGS) $(OBJ) $(MATH_LIB)
+	$(CC) --output $@ $(LDFLAGS) $^ $(MATH_LIB)
 
 
 # Compile: create object files from C source files.
@@ -454,10 +478,14 @@
 	$(REMOVE) $(TARGET).sym
 	$(REMOVE) $(TARGET).lnk
 	$(REMOVE) $(TARGET).lss
-	$(REMOVE) $(OBJ)
+	$(REMOVE) $(LIBRARY)
+	$(REMOVE) $(OBJBEHAVIOUR)
+	$(REMOVE) $(OBJLIBRARY)
 	$(REMOVE) $(LST)
-	$(REMOVE) $(SRC:.c=.s)
-	$(REMOVE) $(SRC:.c=.d)
+	$(REMOVE) $(SRCBEHAVIOUR:.c=.s)
+	$(REMOVE) $(SRCLIBRARY:.c=.s)
+	$(REMOVE) $(SRCBEHAVIOUR:.c=.d)
+	$(REMOVE) $(SRCLIBRARY:.c=.d)
 	$(REMOVE) .dep/*
 
 
Index: Changelog.txt
===================================================================
--- Changelog.txt	(Revision 1786)
+++ Changelog.txt	(Arbeitskopie)
@@ -1,2 +1,4 @@
 CHANGELOG fuer c't-Bot
 ======================
+2011-05-12 Simon Siemens [simon.siemens@xxxxxxxx]: Neues make-Target library fÃr eine Bibliothek der Infrastrukturkomponenten (Hardwareabstraktion, OS, ...).
+