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

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