forked from oscourse-tsinghua/OS2018spring-projects-g13
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (68 loc) · 2.16 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#--------------------------------------------------------------------
# User Editable Interface
#--------------------------------------------------------------------
# Dir mapped into docker container
SOURCE := src
# Docker image name
IMAGE := ucore
# Docker container name
CONTAINER := ucore-container
#--------------------------------------------------------------------
# Get the LOCALIP of host for DISPLAY of different OS
#--------------------------------------------------------------------
ifeq ($(OS),Windows_NT)
# The default dockerNAT for windows is 10.0.75.1
# you can change it in docker for windows Application
WIN_DOCKERNAT := 10.0.75.1
LOCALIP := $(WIN_DOCKERNAT)
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
LOCALIP :=
endif
ifeq ($(UNAME_S),Darwin)
LOCALIP := docker.for.mac.localhost
endif
endif
#--------------------------------------------------------------------
# Docker flags and container settings
#--------------------------------------------------------------------
# container's work dir
WORKDIR := /usr/src/app
# map SOURCE into WORKDIR
VOLFLAGS := -v $(CURDIR)/$(SOURCE):$(WORKDIR)
# map X11-unix dir
GVOLFLAGS := -v /tmp/.X11-unix:/tmp/.X11-unix
# Bash in container
BASH := /bin/bash
V := @
DFLAGS := --privileged -itd $(VOLFLAGS)
DFLAGS_G := $(DFLAGS) -e DISPLAY=$(LOCALIP):0 $(GVOLFLAGS)
docker_run = docker run $(DFLAGS) --name $(CONTAINER) $(IMAGE)
docker_run_graphics = docker run $(DFLAGS_G) --name $(CONTAINER) $(IMAGE)
docker_exec = docker exec -it $(CONTAINER)
# docker_bash = $(docker_run) $(BASH) -c "$(1)"
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Make Tasks
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Get the Ubuntu develop environment
exec:
$(V)$(docker_exec) $(BASH)
# Main tasks
init: build run
build:
$(V)docker build -t $(IMAGE) .
run:
$(V)$(docker_run_graphics) $(BASH)
start:
$(V)docker start $(CONTAINER)
stop:
$(V)docker stop $(CONTAINER)
rm:
$(V)docker rm $(CONTAINER)
# Container make command copies
qemu:
$(V)$(docker_exec) make qemu
clean:
$(V)$(docker_exec) make clean
# ...