Fix Make, Make clean and when the src directories are cloned
[vswitchperf.git] / src / qemu / Makefile
1 # makefile to manage qemu package
2 #
3
4 # Copyright (c) 2015 OPNFV and Intel Corporation.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 #
19 # Contributors:
20 #   Aihua Li, Huawei Technologies.
21
22 include ../mk/master.mk
23 include ../package-list.mk
24
25 WORK_DIR = qemu
26 TAG_DONE_FLAG = $(WORK_DIR)/.$(QEMU_TAG).done
27 CONFIG_CMD =
28 CONFIG_CMD += ./configure
29 CONFIG_CMD += --target-list="x86_64-softmmu"
30 QEMU_VANILLA = ../../src_vanilla/qemu
31 QEMU_CUSE = ../../src_cuse/qemu
32
33 all: force_make
34
35 .PHONY: install force_install config force_make
36
37 # install depends on make
38 force_install: force_make
39         @echo "Finished making $(WORK_DIR) "
40
41 config $(WORK_DIR)/Makefile: $(WORK_DIR)/configure
42         $(AT)cd $(WORK_DIR); $(CONFIG_CMD)
43         @echo "Configure done"
44
45 INSTALL_TARGET = force_install force_make
46
47 force_make: $(WORK_DIR)/Makefile
48         $(AT)cd $(WORK_DIR) && git pull $(QEMU_URL) $(QEMU_TAG)
49         $(AT)echo "git pull done"
50         $(AT)$(MAKE) -C $(WORK_DIR) $(MORE_MAKE_FLAGS)
51         @echo "Make done"
52
53 force_install:
54         $(AT)sudo $(MAKE) -C $(WORK_DIR) install
55
56 install: $(INSTALL_TARGET)
57
58 # hard way to clean and clobber
59 clean:
60         $(AT)cd $(WORK_DIR) && git clean -xfd *.o
61 clobber:
62         $(AT)rm -rf $(WORK_DIR)
63         $(AT)rm -rf $(QEMU_VANILLA)
64         $(AT)rm -rf $(QEMU_CUSE)
65
66 # distclean is for developer who would like to keep the
67 # clone git repo, saving time to fetch again from url
68 distclean:
69         $(AT)cd $(WORK_DIR) && git clean -xfd && git checkout -f
70
71 test:
72         @echo "Make test in $(WORK_DIR) (stub) "
73
74 sanity:
75         @echo "Make sanity in $(WORK_DIR) (stub) "
76
77 $(WORK_DIR)/configure: $(TAG_DONE_FLAG)
78
79 $(WORK_DIR):
80         $(AT)git clone $(QEMU_URL)
81         $(AT)mkdir -p $(QEMU_VANILLA)
82         $(AT)cp -rf ./* $(QEMU_VANILLA)
83         $(AT)mkdir -p $(QEMU_CUSE)
84         $(AT)cp -rf ./* $(QEMU_CUSE)
85
86 $(TAG_DONE_FLAG): $(WORK_DIR)
87         $(AT)cd $(WORK_DIR); git checkout $(QEMU_TAG)
88 ifneq ($(PATCH_FILE),)
89         $(AT)cd $(WORK_DIR); patch -p1 < ../$(PATCH_FILE)
90 endif
91         $(AT)touch $@