summaryrefslogtreecommitdiffstats
path: root/distropkg/Makefile
blob: 5c8743e568101c21243f1c7e026348554c2879aa (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
# Makefile stub to include common/Makefile.common and distropkg/Makefile.local
# We assume that the package name and our current directory name match
NAME := $(shell basename `pwd`)
SPECFILE = distropkg/$(NAME).spec

# Even though we are in distropkg/Makefile, we are included in the toplevel
# Makefile, so the location of common, as far as we are concerned, is relative
# to the toplevel Makefile
define find-makefile-common
for d in ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; if [ -d $$d/.git -a -w $$/Makefile.common ] ; then git pull -q $$d ; fi; echo "$$d/Makefile.common" ; break ; fi ; done
endef

MAKEFILE_COMMON := $(shell $(find-makefile-common))

ifeq ($(MAKEFILE_COMMON),)
# attempt a checkout
define checkout-makefile-common
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { test -d .git && { git clone `git config --get remote.origin.url | sed -e 's/$(NAME)/common'` ../common; echo "../common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } } >&2
endef

MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
endif

include $(MAKEFILE_COMMON)

MAKEFILE_LOCAL := $(wildcard distropkg/Makefile.local)
ifdef MAKEFILE_LOCAL
include $(MAKEFILE_LOCAL)
endif