Externals/dropbear - Works, but install might be failing
[tpg/acess2.git] / Externals / common.mk
1
2 # Acess2 OS - "Externals"
3 # - By John Hodge (thePowersGang)
4 #
5 # common.mk
6 # - Common makefile code for imported code
7
8 -include ../../Makefile.cfg
9
10 ifeq ($(ARCH),x86)
11  BFD := i586
12 else ifeq ($(ARCH),x86_64)
13  BFD := x86_64
14 else
15  $(error No BFD translation for $(ARCH) in Externals/common.mk)
16 endif
17
18 #PREFIX=$(ACESSDIR)/Externals/Output
19 #EPREFIX=$(ACESSDIR)/Externals/Output/$(BFD)
20 PREFIX=$(ACESSDIR)/Externals/Output/$(ARCH)
21 EPREFIX=$(PREFIX)
22 SYSROOT=$(ACESSDIR)/Externals/Output/sysroot-$(BFD)
23 HOST=$(BFD)-acess_proxy-elf
24
25 #
26 # DEPS : Dependencies for this program/library 
27 # TARBALL_PATTERN : $(wildcard ) format [glob] pattern
28 # TARBALL_TO_DIR : $(patsubst ) format conversion
29 # PATCHES : List of altered files in the source
30 #  > If patches/%.patch exists, the original is patched, else patches/% is copied in
31 # CONFIGURE_ARGS : Extra arguments to ./configure (ignoring host and prefix)
32 # [?]BTARGETS : Build targets (Defaults to all)
33 # [?]ARCHIVE : Optional forced archive (Defaults to latest)
34 # [?]CONFIGURE_LINE : Command to create makefile (defaults to autotools configure)
35 # [?]NOBDIR : Set to non-empty to disable use of a separate build dir
36
37
38 BTARGETS ?= all
39 ITARGETS ?= install
40
41 _VERS := $(wildcard $(TARBALL_PATTERN))
42 _VERS := $(sort $(_VERS))
43 _LATEST := $(lastword $(_VERS))
44
45 ifeq ($(ARCHIVE),)
46  ifeq ($(_LATEST),)
47   $(warning Unable to find an archive matching $(TARBALL_PATTERN))
48   $(error No archive found)
49  endif
50  
51  ifneq ($(_LATEST),$(_VERS))
52   $(warning Multiple archvies found, picked $(_LATEST))
53  endif
54  ARCHIVE := $(_LATEST)
55 endif
56
57 DIR := $(patsubst $(TARBALL_TO_DIR_L),$(TARBALL_TO_DIR_R),$(ARCHIVE))
58
59 ifeq ($(NOBDIR),)
60  BDIR := build-$(DIR)
61 else
62  BDIR := $(DIR)
63 endif
64 SDIR := ../$(DIR)
65
66 CONFIGURE_LINE ?= $(SDIR)/configure --host=$(HOST) --prefix=$(PREFIX) --exec-prefix=$(EPREFIX) $(CONFIGURE_ARGS)
67
68 .PHONY: all clean install _patch _build
69
70 install: all
71         cd $(BDIR) && make $(ITARGETS)
72
73 all: $(DIR) _patch _build
74
75 clean:
76         rm -rf $(DIR) $(BDIR)
77
78 $(DIR): $(ARCHIVE)
79         tar -xf $(ARCHIVE)
80
81 $(DIR)/%: patches/%.patch
82         @echo [PATCH] $@
83         @patch $@ $<
84
85 $(DIR)/%: patches/%
86         @echo [CP] $@
87         @cp $< $@
88
89 _patch: $(DIR) $(addprefix $(DIR)/,$(PATCHES))
90
91 $(BDIR)/Makefile: _patch ../common.mk Makefile 
92         mkdir -p $(BDIR)
93         cd $(BDIR) && $(CONFIGURE_LINE)
94
95 _build: $(BDIR)/Makefile
96         cd $(BDIR) && make $(BTARGETS)
97

UCC git Repository :: git.ucc.asn.au