Skip to contentSkip to conversation

qemu Makefile.target

Qemu-devel Blue Swirl 4 participants 6 messages Jun 1, 2007 – Oct 9, 2007 Kbuild

lore
Share & tools
lore
#1 lore raw

Wouldn't it be better to let the compiler create dependency files which make can read? I posted a patch some time ago and use it since many months for different QEMU target platforms.

Stefan

Quoted 12 lines · Blue Swirl

CVSROOT: /cvsroot/qemu
Module name: qemu
Changes by: Blue Swirl <blueswir1> 07/06/01 16:44:42

Modified files:
. : Makefile.target

Log message:
Update Sparc dependencies

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/Makefile.target?cvsroot=qemu&r1=1.179&r2=1.180

author
#2 lore raw
Quoted 3 lines · Stefan Weil

Wouldn't it be better to let the compiler create dependency files which make can read? I posted a patch some time ago and use it since many months for different QEMU target platforms.

I don't know, the dependencies aren't changing very often.

#3 lore raw
Quoted 6 lines · Blue Swirl
Quoted 3 lines · Stefan Weil

Wouldn't it be better to let the compiler create dependency files which make can read? I posted a patch some time ago and use it since many months for different QEMU target platforms.

I don't know, the dependencies aren't changing very often.

The current Makefile.target contains a lot of dependencies, and I think they change often, their number is growing and nevertheless they are far from being complete.

The appended patch removes most explicit dependencies and adds gcc flags which create dependency files during normal compilation (so they are always up-to-date).

Stefan

Index: Makefile.target
===================================================================
RCS file: /sources/qemu/qemu/Makefile.target,v
retrieving revision 1.206

Makefile.target +7 -52
diff -u -b -B -r1.206 Makefile.target
@@ -33,6 +33,7 @@
 BASE_CFLAGS=
 BASE_LDFLAGS=
 #CFLAGS+=-Werror
+BASE_CFLAGS += -MMD -MP
 LIBS=
 HELPER_CFLAGS=$(CFLAGS)
 DYNGEN=../dyngen$(EXESUF)
@@ -107,6 +108,8 @@
 OP_CFLAGS+=$(call cc-option, -fno-align-functions, $(call cc-option, -malign-functions=0, ""))
 OP_CFLAGS+=$(call cc-option, -fno-section-anchors, "")
 
+OP_CFLAGS += -MMD -MP
+
 ifeq ($(ARCH),i386)
 HELPER_CFLAGS+=-fomit-frame-pointer
 OP_CFLAGS+=-mpreferred-stack-boundary=2 -fomit-frame-pointer
@@ -629,58 +632,6 @@
 signal.o: signal.c
 	$(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
 
-vga.o: pixel_ops.h
-
-tcx.o: pixel_ops.h
-
-ifeq ($(TARGET_BASE_ARCH), i386)
-op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
-endif
-
-ifeq ($(TARGET_ARCH), arm)
-op.o: op.c op_template.h
-pl110.o: pl110_template.h
-endif
-
-ifeq ($(TARGET_BASE_ARCH), sparc)
-helper.o: cpu.h exec-all.h
-op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h exec.h cpu.h
-op_helper.o: exec.h softmmu_template.h cpu.h
-translate.o: cpu.h exec-all.h disas.h
-endif
-
-ifeq ($(TARGET_BASE_ARCH), ppc)
-op.o: op.c op_template.h op_mem.h op_helper.h
-op_helper.o: op_helper.c mfrom_table.c op_helper_mem.h op_helper.h
-translate.o: translate.c translate_init.c
-endif
-
-ifeq ($(TARGET_BASE_ARCH), mips)
-helper.o: cpu.h exec-all.h
-op.o: op_template.c fop_template.c op_mem.c exec.h cpu.h
-op_helper.o: op_helper_mem.c exec.h softmmu_template.h cpu.h
-translate.o: translate_init.c exec-all.h disas.h
-endif
-
-loader.o: loader.c elf_ops.h
-
-ifeq ($(TARGET_ARCH), sh4)
-op.o: op.c op_mem.c cpu.h
-op_helper.o: op_helper.c exec.h cpu.h
-helper.o: helper.c exec.h cpu.h
-sh7750.o: sh7750.c sh7750_regs.h sh7750_regnames.h cpu.h
-shix.o: shix.c sh7750_regs.h sh7750_regnames.h
-sh7750_regnames.o: sh7750_regnames.c sh7750_regnames.h sh7750_regs.h
-tc58128.o: tc58128.c
-endif
-
-ifeq ($(TARGET_BASE_ARCH), alpha)
-op.o: op.c op_template.h op_mem.h
-op_helper.o: op_helper_mem.h
-endif
-
-$(OBJS) $(LIBOBJS) $(VL_OBJS): config.h ../config-host.h
-
 %.o: %.c
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
 
@@ -689,6 +640,7 @@
 
 clean:
 	rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
+	rm -f *.d */*.d
 
 install: all
 ifneq ($(PROGS),)
@@ -699,6 +651,9 @@
 include .depend
 endif
 
+-include *.d
+-include */*.d
+
 ifeq (1, 0)
 audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \
 fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \
#4 lore raw
Quoted 6 lines · Stefan Weil
Quoted 5 lines · Blue Swirl
Quoted 3 lines · Stefan Weil

Wouldn't it be better to let the compiler create dependency files which make can read? I posted a patch some time ago and use it since many months for different QEMU target platforms.

Quoted 8 lines
Quoted 1 line

I don't know, the dependencies aren't changing very often.

The current Makefile.target contains a lot of dependencies, and I think they change often, their number is growing and nevertheless they are far from being complete.

The appended patch removes most explicit dependencies and adds gcc flags which create dependency files during normal compilation (so they are always up-to-date).

I arrived to the same conclusion, that hand coded dependencies are always bugged and/or incomplete. I then was to propose a similar patch with a few small differences. As -MMD / -MP is a preprocessor option, it seems more logical to add them in CPPFLAGS. The second difference is that it seems better to use the following syntax to include dependency files:
-include $(wildcard *.d)
-include $(wildcard */*.d)
(some also include /dev/null in the list then it's never empty...)

This patch has a great drawback; you are to recompile almost everything any time you change vl.h or target-xxx/cpu.h, for example. This, imho, should not prevent us to apply it but shows us that most headers should be splitted in a better way. As an example, it seems strange to me to declare all devices prototypes in vl.h when those declaration should never be used outside of hw subdirectory, where all hardware devices emulation related stuff should stay. I guess we could find a lot of examples of declarations/prototypes globally exported but only used locally. Fixing this would make the code cleaner and, as a side effect, would avoid a lot of waste of time recompiling useless stuff when doing changes in headers.

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#5 lore raw
Quoted 8 lines · J. Mayer
Quoted 7 lines · Stefan Weil
Quoted 6 lines · Blue Swirl
Quoted 3 lines · Stefan Weil

Wouldn't it be better to let the compiler create dependency files which make can read? I posted a patch some time ago and use it since many months for different QEMU target platforms.

I don't know, the dependencies aren't changing very often.

With the many features that I have been adding to our private branch the dependencies are changing and I've been considering how to make the dependencies more automated.

Quoted 10 lines
Quoted 7 lines

The current Makefile.target contains a lot of dependencies, and I think they change often, their number is growing and nevertheless they are far from being complete.

The appended patch removes most explicit dependencies and adds gcc flags which create dependency files during normal compilation (so they are always up-to-date).

I arrived to the same conclusion, that hand coded dependencies are always bugged and/or incomplete.

I'm interested in seeing this, also. I have begun building out new features for linux-user emulation and auto-generating the dependencies will be helpful - as well as ensure that the dependencies are up-to-date.

Quoted 9 lines

I then was to propose a similar patch
with a few small differences. As -MMD / -MP is a preprocessor option, it seems more logical to add them in CPPFLAGS. The second difference is that it seems better to use the following syntax to include dependency files:

(quoted diff) +0 -2
-include $(wildcard *.d)
-include $(wildcard */*.d)

(some also include /dev/null in the list then it's never empty...)

Quoted 4 lines

This patch has a great drawback; you are to recompile almost everything any time you change vl.h or target-xxx/cpu.h, for example. This, imho, should not prevent us to apply it but shows us that most headers should be splitted in a better way.

A similar example is linux-user/qemu.h. I want to submit some patches that will start breaking up the linux-user files. The linux-user emulation will benefit by breaking files up according to architecture rather than #ifdef'ing all the archs in the same file. If have also run into problems with too many #include files causing collisions of typedefs from system headers (yes, this indicates poorly constructed system headers).

Quoted 8 lines

As an example, it seems strange to me to
declare all devices prototypes in vl.h when those declaration should never be used outside of hw subdirectory, where all hardware devices emulation related stuff should stay. I guess we could find a lot of examples of declarations/prototypes globally exported but only used locally. Fixing this would make the code cleaner and, as a side effect, would avoid a lot of waste of time recompiling useless stuff when doing changes in headers.

I agree.