Usermode/libc - Fix strchr and strrchr behavior
[tpg/acess2.git] / Externals / core.mk
1
2 # Acess2 OS - "Externals"
3 # - By John Hodge (thePowersGang)
4 #
5 # core.mk
6 # - Makefile code used by all externals
7
8 include $(dir $(lastword $(MAKEFILE_LIST)))/config.mk
9
10 #
11 # DEPS : Dependencies for this program/library 
12 # TARBALL_PATTERN : $(wildcard ) format [glob] pattern
13 # TARBALL_TO_DIR : $(patsubst ) format conversion
14 # PATCHES : List of altered files in the source
15 #  > If patches/%.patch exists, the original is patched, else patches/% is copied in
16 # [?]BTARGETS : Build targets (Defaults to all)
17 # [?]ARCHIVE : Optional forced archive (Defaults to latest)
18 # [?]NOBDIR : Set to non-empty to disable use of a separate build dir
19
20 # CONFIGURE_ARGS : Extra arguments to ./configure (ignoring host and prefix)
21 # [?]CONFIGURE_LINE : Command to create makefile (defaults to autotools configure)
22 # [?]AUTORECONF : Set to non-empty to regenerate ./configure
23
24
25 BTARGETS ?= all
26 ITARGETS ?= install
27
28 _VERS := $(wildcard $(TARBALL_PATTERN))
29 _VERS := $(sort $(_VERS))
30 _LATEST := $(lastword $(_VERS))
31
32 ifeq ($(ARCHIVE),)
33  ifeq ($(_LATEST),)
34   $(warning Unable to find an archive matching $(TARBALL_PATTERN))
35   $(error No archive found)
36  endif
37  
38  ifneq ($(_LATEST),$(_VERS))
39   $(warning Multiple archvies found, picked $(_LATEST))
40  endif
41  ARCHIVE := $(_LATEST)
42 endif
43
44 DIR := $(patsubst $(TARBALL_TO_DIR_L),$(TARBALL_TO_DIR_R),$(ARCHIVE))
45
46 ifeq ($(NOBDIR),)
47  BDIR := build-$(ARCH)
48 else
49  BDIR := $(DIR)
50 endif
51 SDIR := ../$(DIR)
52
53 .PHONY: all clean install _patch _build
54
55 all: $(DIR) _patch _build
56
57 clean:
58         rm -rf $(DIR) $(BDIR)
59
60 $(DIR): $(ARCHIVE)
61         tar -xf $(ARCHIVE)
62
63
64 $(DIR)/%: patches/%.patch
65         @echo [PATCH] $@
66         @tar -xf $(ARCHIVE) $@
67         @patch $@ $<
68
69 $(DIR)/%: patches/%
70         @echo [CP] $@
71         @mkdir -p $(dir $@)
72         @cp $< $@
73
74 PATCHED_FILES := $(addprefix $(DIR)/,$(PATCHES))
75
76 ifneq ($(wildcard patches/UNIFIED.patch),)
77 $(DIR)/_unified_applied: $(wildcard patches/UNIFIED.patch)
78         cd $(DIR) && patch -p1 < ../patches/UNIFIED.patch
79         touch $@
80 UNIFIED_TARGET=$(DIR)/_unified_applied
81 else
82 UNIFIED_TARGET=
83 endif
84
85 _patch: $(DIR) $(PATCHED_FILES) $(UNIFIED_TARGET)
86

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