summaryrefslogtreecommitdiff
path: root/sub/musl/Makefile
blob: 0d23c830554f08eea8f68a6fe20dbafa2b638fad (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
MUSL_BASE ?= /opt/musl-git

# Version from 2017-07-17
# MUSL_VERSION := a08910fc2cc739f631b75b2d09b8d72a0d64d285

# Version from 2017-10-31
MUSL_VERSION := 1b9406b03c0a94ebe2076a8fc1746a8c45e78a83


# Build-build

$(OUTPUT)/sources/.lh_musl_cloned: | $(OUTPUT)/tmp/.lh_prepared
	if ! test -d $(OUTPUT)/sources/musl ; then cd $(OUTPUT)/sources && git clone git://git.musl-libc.org/musl musl && cd musl && git checkout $(MUSL_VERSION) ; fi
	exec setuidgid $(NORMALUSER) touch $@

$(OUTPUT)/build-build$(MUSL_BASE)/.lh_copied: $(OUTPUT)/sources/.lh_musl_cloned
	exec setuidgid $(NORMALUSER) rm -rf $(OUTPUT)/build-build$(MUSL_BASE)/src
	exec setuidgid $(NORMALUSER) mkdir -p $(OUTPUT)/build-build$(MUSL_BASE)
	exec setuidgid $(NORMALUSER) cp -a $(OUTPUT)/sources/musl $(OUTPUT)/build-build$(MUSL_BASE)/src
	exec setuidgid $(NORMALUSER) touch $@

$(OUTPUT)/build-build$(MUSL_BASE)/.lh_configured: $(OUTPUT)/build-build$(MUSL_BASE)/.lh_copied
	cd $(OUTPUT)/build-build$(MUSL_BASE)/src && setuidgid $(NORMALUSER) ./configure --prefix=$(OUTPUT)/build-build$(MUSL_BASE) --enable-warnings --enable-gcc-wrapper "CC=$(BUILD_BUILD_CC)"
	exec setuidgid $(NORMALUSER) touch $@

$(OUTPUT)/build-build$(MUSL_BASE)/.lh_built: $(OUTPUT)/build-build$(MUSL_BASE)/.lh_configured
	cd $(OUTPUT)/build-build$(MUSL_BASE)/src && setuidgid $(NORMALUSER) $(MAKE)
	exec setuidgid $(NORMALUSER) touch $@

$(OUTPUT)/build-build$(MUSL_BASE)/.lh_installed: $(OUTPUT)/build-build$(MUSL_BASE)/.lh_built $(OUTPUT)/build-build/.lh_kernel_headers_installed
	cd $(OUTPUT)/build-build$(MUSL_BASE)/src && setuidgid $(NORMALUSER) $(MAKE) install syslibdir=$(OUTPUT)/build-build$(MUSL_BASE)
	exec setuidgid $(NORMALUSER) makenamelink $(OUTPUT)/build-build$(dir $(MUSL_BASE)) musl $(notdir $(MUSL_BASE)) $(OUTPUT)/tmp
	exec setuidgid $(NORMALUSER) makelinks $(OUTPUT)/build-build $(MUSL_BASE)/include /opt/linux/include
	exec setuidgid $(NORMALUSER) sub/musl/muslgccmake $(OUTPUT)/build-build$(MUSL_BASE)/bin/musl-gcc $(OUTPUT)/build-build$(MUSL_BASE)/lib/musl-gcc.specs $(BUILD_BUILD_CC) true
	exec setuidgid $(NORMALUSER) touch $@

$(OUTPUT)/build-build/tmp/libssp_nonshared.o: sub/musl/libssp_nonshared.c | $(OUTPUT)/tmp/.lh_prepared
	exec setuidgid $(NORMALUSER) $(BUILD_BUILD_CC) -O2 -o $@ -c $^

$(OUTPUT)/build-build$(MUSL_BASE)/lib/libssp_nonshared.a: $(OUTPUT)/build-build$(MUSL_BASE)/.lh_installed $(OUTPUT)/build-build/tmp/libssp_nonshared.o
	exec setuidgid $(NORMALUSER) ar cr $@ $(OUTPUT)/build-build/tmp/libssp_nonshared.o

$(OUTPUT)/build-build/.lh_gcc: $(OUTPUT)/build-build$(MUSL_BASE)/.lh_installed $(OUTPUT)/tmp/.lh_prepared $(OUTPUT)/build-build$(MUSL_BASE)/lib/libssp_nonshared.a
	exec setuidgid $(NORMALUSER) makelinks $(OUTPUT)/build-build /bin $(dir $(MUSL_BASE))musl/bin
	exec setuidgid $(NORMALUSER) ln -sf musl-gcc $(OUTPUT)/build-build/bin/gcc
	exec setuidgid $(NORMALUSER) touch $@


# Build-host

$(OUTPUT)/build-host/bin/muslgcc: $(OUTPUT)/build-host/kernel/.lh_headers_installed | $(OUTPUT)/tmp/.lh_layout_installed $(OUTPUT)/build-build/.lh_skarnet_installed
	exec setuidgid $(NORMALUSER) sub/musl/muslgccmake-buildhost $(OUTPUT) $(TRIPLE) $(BUILD_HOST_CC)
	exec setuidgid $(NORMALUSER) s6-ln -sf $(TRIPLE)-muslgcc $@