'make clean' should tell buildrom that the package is now unconfigured.
[buildrom.git] / buildrom-devel / packages / coreboot-v2 / coreboot.inc
blobc256cd2656955705a56a9982f4f1bcfc879a0285
1 # This is the common code included by all the targets
3 ifeq ($(CONFIG_PLATFORM),y)
4 ifeq ($(COREBOOT_VENDOR),)
5 $(error No coreboot vendor specified)
6 endif
7 ifeq ($(COREBOOT_BOARD),)
8 $(error No coreboot board specified)
9 endif
10 ifeq ($(CBV2_CONFIG),)
11 $(error No coreboot config specified)
12 endif
13 ifeq ($(CBV2_TDIR),)
14 $(error No coreboot TDIR specified)
15 endif
16 endif
18 CBV2_OUTPUT=$(CBV2_BUILD_DIR)/coreboot.rom
19 CBV2_DIR=$(BUILD_DIR)/coreboot
21 # If the user wanted to override the build directory - obey that now
23 ifeq ($(CONFIG_CB_USE_BUILD),y)
24 CBV2_SRC_DIR=$(subst ",,$(CONFIG_CB_BUILDDIR))
25 else
26 CBV2_SRC_DIR=$(CBV2_DIR)/$(CBV2_BASE_DIR)
27 endif
29 CBV2_TARGET_DIR=$(CBV2_SRC_DIR)/targets/
30 CBV2_TARGET_NAME=$(COREBOOT_VENDOR)/$(COREBOOT_BOARD)
31 CBV2_CONFIG_NAME=$(CBV2_TARGET_NAME)/$(CBV2_CONFIG)
33 CBV2_BUILD_DIR=$(CBV2_TARGET_DIR)/$(CBV2_TARGET_NAME)/$(CBV2_TDIR)
35 CBV2_STAMP_DIR=$(CBV2_DIR)/stamps
36 CBV2_LOG_DIR=$(CBV2_DIR)/logs
38 ifeq ($(CONFIG_VERBOSE),y)
39 CBV2_FETCH_LOG=/dev/stdout
40 CBV2_CONFIG_LOG=/dev/stdout
41 CBV2_BUILD_LOG=/dev/stdout
42 CBV2_INSTALL_LOG=/dev/stdout
43 else
44 CBV2_FETCH_LOG=$(CBV2_LOG_DIR)/fetch.log
45 CBV2_BUILD_LOG=$(CBV2_LOG_DIR)/build.log
46 CBV2_CONFIG_LOG=$(CBV2_LOG_DIR)/config.log
47 CBV2_INSTALL_LOG=$(CBV2_LOG_DIR)/install.log
48 endif
50 # This allows us to skip the unpack/patch/configure stage
52 ifeq ($(CONFIG_CB_USE_BUILD),y)
53 CBV2_DIR_TARGET=
54 else
55 CBV2_DIR_TARGET=$(CBV2_STAMP_DIR)/.configured
56 endif
58 $(CBV2_PAYLOAD_TARGET): $(PAYLOAD_TARGET)
59         @ cp $< $@
61 $(CBV2_STAMP_DIR)/.unpacked: $(SOURCE_DIR)/$(CBV2_TARBALL) | $(CBV2_STAMP_DIR) $(CBV2_LOG_DIR)
62         @ echo "Unpacking coreboot ($(CBV2_TARBALL))..."
63         @ tar -C $(CBV2_DIR) -zxf $(SOURCE_DIR)/$(CBV2_TARBALL)
64         @ touch $@      
66 $(CBV2_STAMP_DIR)/.patched: $(CBV2_STAMP_DIR)/.unpacked 
67         @ echo "Patching coreboot..."
68         @ $(BIN_DIR)/doquilt.sh $(CBV2_SRC_DIR) $(CBV2_PATCHES)
69         @ touch $@
71 $(CBV2_STAMP_DIR)/.configured: $(CBV2_STAMP_DIR)/.patched
72         @ echo "Building target..."
73         @( cd $(CBV2_TARGET_DIR); \
74         ./buildtarget $(CBV2_CONFIG_NAME) > $(CBV2_CONFIG_LOG) 2>&1)
75         @ touch $@
77 $(CBV2_STAMP_DIR) $(CBV2_LOG_DIR):
78         @ mkdir -p $@
80 $(CBV2_OUTPUT): $(CBV2_STAMP_DIR) $(CBV2_LOG_DIR) $(CBV2_DIR_TARGET) $(CBV2_PAYLOAD_TARGET)
81         @ echo "Building coreboot..."
82         @ (export CPU_OPT="$(STACKPROTECT)"; \
83         make -C $(CBV2_BUILD_DIR) > $(CBV2_BUILD_LOG) 2>&1)
84         @ mkdir -p $(OUTPUT_DIR)/config/coreboot-v2/
85         @ cp $(CBV2_BUILD_DIR)/../$(CBV2_CONFIG) $(OUTPUT_DIR)/config/coreboot-v2/
86         @ cp $(BASE_DIR)/.config $(OUTPUT_DIR)/config/
87         @ mkdir -p $(OUTPUT_DIR)/config/system/
88         @ uname -a >$(OUTPUT_DIR)/config/system/uname-a
89         @ if [ -f /etc/lsb-release ]; then \
90         cp /etc/lsb-release $(OUTPUT_DIR)/config/system/; \
91         fi      
92         @ if [ -f /etc/debian-version ]; then \
93         cp /etc/debian-version $(OUTPUT_DIR)/config/system/; \
94         fi
95         @ if [ -f /etc/redhat-version ]; then \
96         cp /etc/redhat-version $(OUTPUT_DIR)/config/system/; \
97         fi
98         @ mkdir -p $(OUTPUT_DIR)/config/toolchain/
99         @ $(MAKE) --version >$(OUTPUT_DIR)/config/toolchain/$(MAKE)-version
100         @ $(CC) --version >$(OUTPUT_DIR)/config/toolchain/$(CC)-version
101         @ $(LD) --version >$(OUTPUT_DIR)/config/toolchain/$(LD)-version
102 ifeq ($(CONFIG_STORE_SVN_INFO),y)
103         @ mkdir -p $(OUTPUT_DIR)/config/svn/
104         @ svn diff > $(OUTPUT_DIR)/config/svn/svn.diff
105         @ svn info > $(OUTPUT_DIR)/config/svn/svn.info
106         @ svn status > $(OUTPUT_DIR)/config/svn/svn.status
107 endif
109 generic-coreboot-clean:
110         @ echo "Cleaning coreboot..."
111         @ rm -f $(CBV2_STAMP_DIR)/.configured
112         @ rm -f $(CBV2_PAYLOAD_TARGET)
113 ifneq ($(wildcard $(CBV2_BUILD_DIR)/Makefile),)
114         $(MAKE) -C $(CBV2_BUILD_DIR) clean > /dev/null 2>&1;
115 endif
116         @ rm -f $(CBV2_OUTPUT)
118 generic-coreboot-distclean:
119         @ if [ "$(CONFIG_CB_USE_BUILD)" = "y" ]; then \
120         echo "Cleaning coreboot build..."; \
121         $(MAKE) -C $(CBV2_BUILD_DIR) clean > /dev/null 2>&1; \
122         rm -f $(CBV2_OUTPUT); \
123         fi      
125         @ rm -rf $(CBV2_DIR)/*
127 coreboot-extract: $(CBV2_STAMP_DIR)/.patched