Externals - Added start of a libSDL port, added autoreconf support
[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 # [?]AUTORECONF : Set to non-empty to regenerate ./configure
37
38
39 BTARGETS ?= all
40 ITARGETS ?= install
41
42 _VERS := $(wildcard $(TARBALL_PATTERN))
43 _VERS := $(sort $(_VERS))
44 _LATEST := $(lastword $(_VERS))
45
46 ifeq ($(ARCHIVE),)
47  ifeq ($(_LATEST),)
48   $(warning Unable to find an archive matching $(TARBALL_PATTERN))
49   $(error No archive found)
50  endif
51  
52  ifneq ($(_LATEST),$(_VERS))
53   $(warning Multiple archvies found, picked $(_LATEST))
54  endif
55  ARCHIVE := $(_LATEST)
56 endif
57
58 DIR := $(patsubst $(TARBALL_TO_DIR_L),$(TARBALL_TO_DIR_R),$(ARCHIVE))
59
60 ifeq ($(NOBDIR),)
61  BDIR := build-$(DIR)
62 else
63  BDIR := $(DIR)
64 endif
65 SDIR := ../$(DIR)
66
67 CONFIGURE_LINE ?= $(SDIR)/configure --host=$(HOST) --prefix=$(PREFIX) --exec-prefix=$(EPREFIX) $(CONFIGURE_ARGS)
68
69 .PHONY: all clean install _patch _build
70
71 install: all
72         cd $(BDIR) && make $(ITARGETS)
73
74 all: $(DIR) _patch _build
75
76 clean:
77         rm -rf $(DIR) $(BDIR)
78
79 $(DIR): $(ARCHIVE)
80         tar -xf $(ARCHIVE)
81
82 $(DIR)/%: patches/%.patch
83         @echo [PATCH] $@
84         @patch $@ $<
85
86 $(DIR)/%: patches/%
87         @echo [CP] $@
88         @cp $< $@
89
90 _patch: $(DIR) $(addprefix $(DIR)/,$(PATCHES))
91
92 _autoreconf: _patch
93 ifeq ($(AUTORECONF),)
94 else
95         cd $(DIR) && autoreconf --force --install
96 endif
97
98 $(BDIR)/Makefile: _autoreconf ../common.mk Makefile 
99         mkdir -p $(BDIR)
100         cd $(BDIR) && $(CONFIGURE_LINE)
101
102 _build: $(BDIR)/Makefile
103         cd $(BDIR) && make $(BTARGETS)
104

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