[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Support splitting SOURCE in multiple rmk files
From: |
Bean |
Subject: |
[PATCH] Support splitting SOURCE in multiple rmk files |
Date: |
Wed, 24 Jun 2009 16:52:26 +0800 |
Hi,
In the current build system, all source files to build an executable
must reside in a single rmk file, this makes it difficult to break
down the build system in more logical blocks. This patch fixes this by
utilizing some tricks of GNU make.
First, you can specify the dependence of target in multiple lines, for example:
aa: aa.o
aa: bb.o
$^ represent all dependence, so
aa: aa.o
gcc -oaa $^
aa: bb.o
is the same as
aa: aa.o bb.o
gcc -oaa aa.o bb.o
Second, you can use ifdef so that only the first occurrence would
define a rule, for example:
ifdef aa_DEFINED
aa: aa.o
else
aa: aa.o
gcc -oaa $^
aa_DEFINED=1
endif
ifdef aa_DEFINED
aa: bb.o
else
aa: bb.o
gcc -oaa $^
aa_DEFINED=1
endif
Then, this two blocks can be placed in different makefile, in any order.
Third, there could be other dependence file that would cause problem
with gcc, but we can filter them out by replacing $^ with $(filter
%o,$^).
I've post the patch file for genmk.rb, it only changes the rules for
*_UTILITIES, but this applies to other targets as well.
This is an example to show how to move source file resolve.c of
grub_mkelfimage from common.rmk to i386.rmk.
diff --git a/conf/common.rmk b/conf/common.rmk
index dc78df9..3402faf 100644
--- a/conf/common.rmk
+++ b/conf/common.rmk
@@ -2,8 +2,9 @@
# For grub-mkelfimage.
bin_UTILITIES += grub-mkelfimage
-grub_mkelfimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
- util/resolve.c
+#grub_mkelfimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
+# util/resolve.c
+grub_mkelfimage_SOURCES = util/elf/grub-mkimage.c util/misc.c
util/elf/grub-mkimage.c_DEPENDENCIES = Makefile
# For grub-probe.
diff --git a/conf/i386.rmk b/conf/i386.rmk
index 89496ae..8e9e582 100644
--- a/conf/i386.rmk
+++ b/conf/i386.rmk
@@ -1,5 +1,8 @@
# -*- makefile -*-
+bin_UTILITIES += grub-mkelfimage
+grub_mkelfimage_SOURCES = util/resolve.c
+
pkglib_MODULES += cpuid.mod
cpuid_mod_SOURCES = commands/i386/cpuid.c
cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
--
Bean
genmk.diff
Description: Text Data
- [PATCH] Support splitting SOURCE in multiple rmk files,
Bean <=
- Re: [PATCH] Support splitting SOURCE in multiple rmk files, Robert Millan, 2009/06/24
- Re: [PATCH] Support splitting SOURCE in multiple rmk files, Bean, 2009/06/24
- Re: [PATCH] Support splitting SOURCE in multiple rmk files, Robert Millan, 2009/06/24
- Re: [PATCH] Support splitting SOURCE in multiple rmk files, Pavel Roskin, 2009/06/25
- Re: [PATCH] Support splitting SOURCE in multiple rmk files, Bean, 2009/06/25
- Re: [PATCH] Support splitting SOURCE in multiple rmk files, Pavel Roskin, 2009/06/26
- Re: [PATCH] Support splitting SOURCE in multiple rmk files, Bean, 2009/06/26
- Re: [PATCH] Support splitting SOURCE in multiple rmk files, Pavel Roskin, 2009/06/26