aboutsummaryrefslogtreecommitdiffstats
path: root/build.mk
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-06-01 22:24:55 +0000
committerEric Wong <normalperson@yhbt.net>2008-06-01 22:24:55 +0000
commit8a4dff14ad7560aae83e9155d0c62ba7f8c101fd (patch)
treef9803ea83fa7cb6020e84b78f3fc45b4086e4a13 /build.mk
parent97698bd4aaf168620205fea26f089e7b1acc869d (diff)
downloadmpd-8a4dff14ad7560aae83e9155d0c62ba7f8c101fd.tar.gz
mpd-8a4dff14ad7560aae83e9155d0c62ba7f8c101fd.tar.xz
mpd-8a4dff14ad7560aae83e9155d0c62ba7f8c101fd.zip
Add the bs build system from mpd-ke
Dealing with autotools is too painful when having to deal with multiple build environments and configurations. git-svn-id: https://svn.musicpd.org/mpd/trunk@7368 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'build.mk')
-rwxr-xr-xbuild.mk103
1 files changed, 103 insertions, 0 deletions
diff --git a/build.mk b/build.mk
new file mode 100755
index 000000000..6962d00c2
--- /dev/null
+++ b/build.mk
@@ -0,0 +1,103 @@
+#!/usr/bin/make -f
+# default target
+all:
+
+# output directory can be set with O:=dir
+ifeq ($(O),)
+ O := .
+endif
+srcdir := src
+include src/Makefile.am
+mpd_SRC := $(addprefix src/,$(filter %.c,$(mpd_SOURCES)))
+mpd_HDR := $(addprefix src/,$(filter %.h,$(mpd_SOURCES)))
+mpd_OBJ := $(subst .c,.o,$(addprefix $(O)/,$(mpd_SRC)))
+mpd_DEP := $(subst .o,.d,$(mpd_OBJ))
+
+-include $(mpd_DEP)
+
+uname_s := $(shell uname -s | tr A-Z a-z 2>/dev/null || echo unknown)
+uname_m := $(shell uname -m | tr A-Z a-z 2>/dev/null || echo unknown)
+
+# build: the machine type this builds on
+# HOST: the machine this runs on
+build := $(uname_s)-$(uname_m)
+HOST ?= $(build)
+-include $(O)/config.mk
+-include $(O)/config_detected.mk
+include bs/deps-audio.mk
+include bs/deps-input.mk
+include bs/deps-misc.mk
+include bs/deps-conflicts.mk
+
+RANLIB ?= ranlib
+ifneq ($(HOST),$(build))
+ ifeq ($(origin CC),default)
+ CC := $(HOST)-$(CC)
+ endif
+ ifeq ($(origin RANLIB),default)
+ RANLIB := $(HOST)-$(RANLIB)
+ endif
+ ifeq ($(origin AR),default)
+ AR := $(HOST)-$(AR)
+ endif
+endif
+
+mpd_CFLAGS += -I$(O)/src
+mpd_LDFLAGS += -lm
+mpd_DIRS := $(O)/src/inputPlugins $(O)/src/audioOutputs
+
+STRIP ?= strip
+export O CC CPPFLAGS CFLAGS HOST SHELL
+
+defconfig: $(O)/config.mk
+
+$(O)/config.mk:
+ @test -d "$(@D)" || $(SHELL) ./bs/mkdir_p.sh "$(@D)"
+ @if ! test -e $@; then \
+ sed -e 's/@@HOST@@/$(HOST)/g' \
+ < bs/config.mk.default > $@+ && mv $@+ $@ && \
+ echo Please edit $(O)/config.mk to your liking; fi
+ @touch $@
+
+$(O)/src/../config.h: $(O)/config.h
+$(O)/config.h: $(O)/config.mk $(O)/config_detected.h
+ $(MAKE) -f bs/mkconfig.h.mk $(O)/config.h
+
+$(O)/config_detected.h:
+ @test -d "$(@D)" || $(SHELL) ./bs/mkdir_p.sh "$(@D)"
+ > $@+ && $(SHELL) ./bs/mkconfig-header.sh >> $@+ && \
+ $(SHELL) ./bs/cross-arch.sh >> $@+ && mv $@+ $@
+
+all: $(O)/src/mpd
+ @echo OK $<
+strip: $(O)/src/mpd
+ $(STRIP) $(STRIP_OPTS) $<
+$(O)/src/mpd: $(mpd_OBJ)
+ $(CC) -o $@ $^ $(CFLAGS) $(mpd_CFLAGS) $(LDFLAGS) $(mpd_LDFLAGS)
+$(O)/src/%.o: src/%.c $(O)/config.h
+ @HDR_DEP_HACK="$(O)/config.h $(mpd_HDR)" \
+ CFLAGS="$(CFLAGS) $(mpd_CFLAGS)" \
+ $(SHELL) ./bs/mkdep.sh $< $(dir $<) $(subst .o,.d,$@)
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(mpd_CFLAGS) -c -o $@ $<
+$(mpd_SRC): $(O)/config.h
+clean:
+ $(RM) $(O)/src/mpd $(mpd_OBJ)
+reallyclean: clean
+ $(RM) $(mpd_DEP) $(O)/depmode $(O)/config.h
+
+# in case a .d file had a dep on a deleted file, we have this:
+src/%.h src/%.c::
+ @true
+# we only do static linking in bs (since our main goal is cross-compiling),
+# if you want dynamic linking, use autotools
+$(O)/%.a::
+ $(RM) $@
+ $(AR) cru $@ $^
+ $(RANLIB) $@
+dist:
+ $(SHELL) ./bs/mkdist.sh
+
+.PHONY: clean reallyclean defconfig all
+.PRECIOUS: $(O)/%.h
+.SUFFIXES:
+.SUFFIXES: .c .o .h .d