aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 6d481ed52f04987558ca82f03f9d17e8f63e255b (plain)
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
kern_tools_LIST = kgit kgit-meta \
		  kconf_check \
		  kgit-create-buckets \
		  get_defconfig scc \
		  merge_config.sh spp kgit-s2q \
		  symbol_why.py \
		  kconfig-diff2frag.py

cmds := $(wildcard tools/scc-cmds/*)
libs := Kconfiglib/kconfiglib.py

INSTALL=install
RM=rm
ECHO=echo

define echo_action
    if [ "x$1" = "xDone" ]; then \
        $(ECHO) >&2 -e "=======================================================\
                    \n$1: $2 \
                    \n======================================================="; \
    else \
        $(ECHO) >&2 -e "-------------------------------------------------------\
                   \n$1: $2 \
                   \n-------------------------------------------------------"; \
    fi
endef
define install_cmd
	$(INSTALL) -m 0755 $(1) $(DESTDIR)/scc-cmds/;
endef
define install_lib
	$(INSTALL) -m 0755 $(1) $(DESTDIR);
endef
define install_tool
	$(INSTALL) -m 0755 tools/$(1) $(DESTDIR);
endef
define remove_tool
	$(RM) -f $(DESTDIR)/$(1);
endef

all:
	@$(ECHO) No action provided, so nothing will be done
	@$(ECHO) Available actions are 'install' and 'clean'

install:
	@if [ -z "$(DESTDIR)" ]; then \
		$(ECHO) "Error. DESTDIR must be provided"; \
		exit 1; \
	fi;
	@$(call echo_action,Install,kern_tools)
	@$(INSTALL) -d $(DESTDIR)
	@$(foreach tool,$(kern_tools_LIST),$(call install_tool,$(tool)))
	@$(INSTALL) -d $(DESTDIR)/scc-cmds/
	@$(foreach cmd,$(cmds),$(call install_cmd,$(cmd)))
	@$(foreach lib,$(libs),$(call install_lib,$(lib)))
	@$(MAKE_STAMP)

clean:
	@if [ -z "$(DESTDIR)" ]; then \
		$(ECHO) "Error. DESTDIR must be provided"; \
		exit 1; \
	fi;
	@$(call echo_action,Clean,kern_tools)
	@$(foreach tool,$(kern_tools_LIST),$(call remove_tool,$(tool)))
	@-$(RM) -f $(addprefix $(STAMP_DIR)/kern_tools,$(PKG_CLEAN_SUFFIXES));