Drop main() prototype. Syncs with NetBSD-8
[minix.git] / etc / usr / Makefile
blobbb70a4d7713586ebe5c67dbf4b751ca17a564c63
1 # Makefile - installed as /usr/Makefile
3 # Provides simple targets to download and maintain /usr/pkgsrc and /usr/src.
5 ########################################################################
6 # Entry point
7 ########################################################################
8 all help: usage
10 MINIX_RELEASE!= uname -r
12 ########################################################################
13 # PKGSRC
14 ########################################################################
15 PKGSRC_REPO_DIR:= ${.CURDIR}/pkgsrc
16 PKGSRC_REPO_URL:= git://git.minix3.org/pkgsrc-ng.git
17 PKGSRC_BRANCH:= ${MINIX_RELEASE}
18 MSG_RENAMED_BRANCH:= "\
19 \n======================================================================== \
20 \nWarning: \
21 \n Renaming $$$${current_name} to $$$${new_name}. \
22 \n======================================================================== \
24 MSG_RESET_PKGSRC:= "\
25 \n======================================================================== \
26 \nNote: \
27 \n If problems occur you may have to rm -rf ${PKGSRC_REPO_DIR} \
28 \n and try again. \
29 \n======================================================================== \
32 .if exists(${PKGSRC_REPO_DIR}/.git)
33 # We can only update the repository if it *does* exist
34 pkgsrc-update: git
35 # If we can fast-forward, just do it, otherwise rename current branch
36 # and checkout the official branch (also warn the user).
37 @cd ${PKGSRC_REPO_DIR} && git pull --ff-only || \
38 ( current_name=$$(git rev-parse --abbrev-ref HEAD); \
39 new_name=$${current_name}-$$(git rev-parse --short HEAD); \
40 echo -e ${MSG_RENAMED_BRANCH}; \
41 echo -n "Do you want to continue [Y/n]? "; \
42 read ok; \
43 if [ "$${ok}" = "" -o "$${ok}" = "y" -o "$${ok}" = "Y" ]; then \
44 git branch -m $${new_name}; \
45 git checkout -t origin/${PKGSRC_BRANCH}; \
46 else \
47 exit 1; \
48 fi; \
50 @cd ${PKGSRC_REPO_DIR}/minix && sh minibootstrap.sh
52 .if !exists(${PKGSRC_REPO_DIR}/Makefile)
53 # If the .git directory is available, but not yet checked out, then
54 pkgsrc-checkout: git
55 @cd ${PKGSRC_REPO_DIR} && git checkout ${PKGSRC_BRANCH}
56 @cd ${PKGSRC_REPO_DIR}/minix && sh minibootstrap.sh
58 .endif # !exists(${PKGSRC_REPO_DIR}/Makefile)
59 .else
60 # We can only create the repository if it does *not* exist
61 pkgsrc: git
62 @echo -e ${MSG_RESET_PKGSRC}
63 @git clone -b ${PKGSRC_BRANCH} ${PKGSRC_REPO_URL} ${PKGSRC_REPO_DIR}
64 @cd ${PKGSRC_REPO_DIR}/minix && sh minibootstrap.sh
66 .endif # exists(${PKGSRC_REPO_DIR}/.git)
68 ########################################################################
69 # MINIX SRC
70 ########################################################################
71 SRC_REPO_DIR:= ${.CURDIR}/src
72 SRC_REPO_URL:= git://git.minix3.org/minix.git
73 SRC_BRANCH:= master
74 MSG_WRONG_BRANCH_SRC:= "\
75 \n======================================================================== \
76 \nERROR: \
77 \n An unknown branch is presently checked out, please checkout \
78 \n first the following branch: ${SRC_BRANCH} \
79 \n======================================================================== \
81 MSG_RESET_SRC:= "\
82 \n======================================================================== \
83 \nNote: \
84 \n If problems occur you may have to rm -rf ${SRC_REPO_DIR} \
85 \n and try again. \
86 \n======================================================================== \
88 .if exists(${SRC_REPO_DIR}/.git)
89 # We can only update the repository if it *does* exist
90 src-update: git
91 @cd ${SRC_REPO_DIR} && \
92 [ "$$(git rev-parse --abbrev-ref HEAD)" = "${SRC_BRANCH}" ] || \
93 ( echo -e ${MSG_WRONG_BRANCH_SRC}; exit 1 )
94 @cd ${SRC_REPO_DIR} && git pull
96 .if !exists(${SRC_REPO_DIR}/Makefile)
97 src-checkout: git
98 @cd ${SRC_REPO_DIR} && git checkout ${SRC_BRANCH}
99 .endif # !exists(${SRC_REPO_DIR}/Makefile)
100 .else
101 # We can only create the repository if it does not exist
102 src: git
103 @echo -e ${MSG_RESET_SRC}
104 @git clone ${SRC_REPO_URL} ${SRC_REPO_DIR}
106 .endif # exists(${SRC_REPO_DIR}/.git)
108 ########################################################################
109 # Support rules
110 ########################################################################
111 git:
112 @pkgin -y update 2>&1 > /dev/null
113 @pkgin -y install git-base 2>&1 > /dev/null
115 usage:
116 @echo "Usage: make [target]"
117 @echo ""
118 @echo " Where target is one of:"
119 @echo " help, all, usage - print this help"
120 @echo ""
122 .if exists(${SRC_REPO_DIR}/.git)
123 @echo " make src-update - update the src repo from the net"
124 .if !exists(${SRC_REPO_DIR}/Makefile)
125 @echo " make src-checkout - initial checkout of your pre-packaged"
126 @echo " pkgsrc repo."
127 .endif # !exists(${SRC_REPO_DIR}/Makefile)
128 .else
129 @echo " make src - fetch initial src repo from the net"
130 .endif # exists(${SRC_REPO_DIR}/.git)
131 @echo ""
133 .if exists(${PKGSRC_REPO_DIR}/.git)
134 .if !exists(${PKGSRC_REPO_DIR}/Makefile)
135 @echo " make pkgsrc-checkout - initial checkout of your pre-packaged"
136 @echo " pkgsrc repo."
137 .endif # !exists(${PKGSRC_REPO_DIR}/Makefile)
138 @echo " make pkgsrc-update - update your pkgsrc repo from the net"
139 .else
140 @echo " make pkgsrc - fetch initial pkgsrc repo from the net"
141 .endif # exists(${PKGSRC_REPO_DIR}/.git)
142 @echo ""
144 _debug:
145 @echo "Settings:"
146 .for var in MINIX_RELEASE \
147 SRC_REPO_DIR SRC_REPO_URL SRC_BRANCH \
148 PKGSRC_REPO_DIR PKGSRC_REPO_URL PKGSRC_BRANCH
149 @echo " ${var} = ${${var}}"
151 .endfor