summaryrefslogtreecommitdiff
path: root/make
diff options
context:
space:
mode:
Diffstat (limited to 'make')
-rw-r--r--make/AppleBI.mk85
-rw-r--r--make/config.mk57
-rwxr-xr-xmake/filter-inputs25
-rw-r--r--make/subdir.mk43
-rw-r--r--make/util.mk29
5 files changed, 239 insertions, 0 deletions
diff --git a/make/AppleBI.mk b/make/AppleBI.mk
new file mode 100644
index 000000000..a41fe6d5d
--- /dev/null
+++ b/make/AppleBI.mk
@@ -0,0 +1,85 @@
+
+#
+# Make rules to build compiler_rt in Apple B&I infrastructure
+#
+
+# set ProjSrcRoot appropriately
+ProjSrcRoot := $(SRCROOT)
+# set ProjObjRoot appropriately
+ifdef OBJROOT
+ ProjObjRoot := $(OBJROOT)
+else
+ ProjObjRoot := $(ProjSrcRoot)
+endif
+
+# We override this with RC_ARCHS because B&I may want to build on an
+# ARCH we haven't explicitly defined support for. If all goes well,
+# this will just work and the resulting lib will just have generic
+# versions for anything unknown.
+Archs := $(RC_ARCHS)
+
+# log full compile lines in B&I logs and omit summary lines
+Verb :=
+Summary := @true
+
+# list of functions needed for each architecture
+Funcs_all = absvdi2.o absvsi2.o addvdi3.o addvsi3.o ashldi3.o ashrdi3.o \
+ clear_cache.o clzdi2.o clzsi2.o cmpdi2.o ctzdi2.o ctzsi2.o \
+ divdc3.o divdi3.o divsc3.o enable_execute_stack.o ffsdi2.o \
+ fixdfdi.o fixsfdi.o fixunsdfdi.o fixunsdfsi.o fixunssfdi.o \
+ fixunssfsi.o floatdidf.o floatdisf.o floatundidf.o floatundisf.o \
+ gcc_personality_v0.o lshrdi3.o moddi3.o muldc3.o muldi3.o \
+ mulsc3.o mulvdi3.o mulvsi3.o negdi2.o negvdi2.o negvsi2.o \
+ paritydi2.o paritysi2.o popcountdi2.o popcountsi2.o powidf2.o \
+ powisf2.o subvdi3.o subvsi3.o ucmpdi2.o udivdi3.o \
+ udivmoddi4.o umoddi3.o apple_versioning.o eprintf.o
+Funcs_i386 = divxc3.o fixunsxfdi.o fixunsxfsi.o fixxfdi.o floatdixf.o \
+ floatundixf.o mulxc3.o powixf2.o
+Funcs_ppc = divtc3.o fixtfdi.o fixunstfdi.o floatditf.o floatunditf.o \
+ gcc_qadd.o gcc_qdiv.o gcc_qmul.o gcc_qsub.o multc3.o \
+ powitf2.o restFP.o saveFP.o trampoline_setup.o
+Funcs_x86_64 = absvti2.o addvti3.o ashlti3.o ashrti3.o clzti2.o cmpti2.o \
+ ctzti2.o divti3.o divxc3.o ffsti2.o fixdfti.o fixsfti.o \
+ fixunsdfti.o fixunssfti.o fixunsxfdi.o fixunsxfsi.o \
+ fixunsxfti.o fixxfdi.o fixxfti.o floatdixf.o floattidf.o \
+ floattisf.o floattixf.o floatundixf.o floatuntidf.o \
+ floatuntisf.o floatuntixf.o lshrti3.o modti3.o multi3.o \
+ mulvti3.o mulxc3.o negti2.o negvti2.o parityti2.o \
+ popcountti2.o powixf2.o subvti3.o ucmpti2.o udivmodti4.o \
+ udivti3.o umodti3.o
+
+# copies any public headers to DSTROOT
+installhdrs:
+
+
+# copies source code to SRCROOT
+installsrc:
+ cp -r . $(SRCROOT)
+
+
+# copy results to DSTROOT
+install: $(SYMROOT)/usr/local/lib/system/libcompiler_rt.a
+ mkdir -p $(DSTROOT)/usr/local/lib/system
+ cp $(SYMROOT)/usr/local/lib/system/libcompiler_rt.a \
+ $(DSTROOT)/usr/local/lib/system/libcompiler_rt.a
+ cd $(DSTROOT)/usr/local/lib/system; \
+ ln -s libcompiler_rt.a libcompiler_rt_profile.a; \
+ ln -s libcompiler_rt.a libcompiler_rt_debug.a
+
+
+# rule to make fat libcompiler_rt.a
+$(SYMROOT)/usr/local/lib/system/libcompiler_rt.a : $(foreach arch,$(Archs), \
+ $(OBJROOT)/$(arch)-pruned.a)
+ mkdir -p $(SYMROOT)/usr/local/lib/system
+ lipo -create $^ -o $@
+
+
+# rule to make filter each architecture of libcompiler_rt.a
+# adds project info so that "what /usr/lib/libSystem.B.dylib" will work
+$(OBJROOT)/%-pruned.a : $(OBJROOT)/Release/%/libcompiler_rt.Optimized.a
+ mkdir -p $(OBJROOT)/$*.tmp
+ cd $(OBJROOT)/$*.tmp; \
+ /Developer/Makefiles/bin/version.pl $(RC_ProjectName) > $(OBJROOT)/version.c; \
+ gcc -arch $* -c ${OBJROOT}/version.c -o version.o; \
+ ar -x $< $(Funcs_all) $(Funcs_$*); \
+ libtool -static *.o -o $@
diff --git a/make/config.mk b/make/config.mk
new file mode 100644
index 000000000..726e8ba41
--- /dev/null
+++ b/make/config.mk
@@ -0,0 +1,57 @@
+###
+# Configuration variables.
+
+# Assume make is always run from top-level of source directory. Note
+# than an Apple style build overrides these variables later in the
+# makefile.
+ProjSrcRoot := $(shell pwd)
+ProjObjRoot := $(ProjSrcRoot)
+
+Configs := Debug Release Profile
+Archs := i386 ppc x86_64
+
+Common.CFLAGS := -Wall -Werror
+
+# These names must match the configs, see GetArgs function.
+Debug.CFLAGS := -g
+Release.CFLAGS := -O3 -fomit-frame-pointer
+Profile.CFLAGS := -pg -g
+
+# Function: GetArgs config arch
+#
+# Return the compiler flags for the given config & arch.
+GetArgs = $(if $($(1).CFLAGS),$(Common.CFLAGS) $($(1).CFLAGS) -arch $(2), \
+ $(error "Invalid configuration: $(1)"))
+
+###
+# Tool configuration variables.
+
+CC := gcc
+# FIXME: LLVM uses autoconf/mkinstalldirs ?
+MKDIR := mkdir -p
+DATE := date
+AR := ar
+# FIXME: Remove these pipes once ranlib errors are fixed.
+AR.Flags := cru 2> /dev/null
+RANLIB := ranlib
+# FIXME: Remove these pipes once ranlib errors are fixed.
+RANLIB.Flags := 2> /dev/null
+LIPO := lipo
+
+###
+# Automatic and derived variables.
+
+# Adjust settings for verbose mode
+ifndef VERBOSE
+ Verb := @
+else
+ Verb :=
+endif
+
+Echo := @echo
+Archive := $(AR) $(AR.Flags)
+Ranlib := $(RANLIB) $(RANLIB.Flags)
+Lipo := $(LIPO)
+ifndef Summary
+ Summary = $(Echo)
+endif
diff --git a/make/filter-inputs b/make/filter-inputs
new file mode 100755
index 000000000..dbae957e5
--- /dev/null
+++ b/make/filter-inputs
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+
+#===- make/filter-inputs ---------------------------------------------------===#
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#===------------------------------------------------------------------------===#
+
+# Given a list of files, return a new list of files taking only the
+# first file for any particular filename.
+def main():
+ import os,sys
+
+ seen = set()
+ for file in sys.argv[1:]:
+ base = os.path.basename(file)
+ if base not in seen:
+ seen.add(base)
+ print file
+
+if __name__ == '__main__':
+ main()
diff --git a/make/subdir.mk b/make/subdir.mk
new file mode 100644
index 000000000..3aea16c73
--- /dev/null
+++ b/make/subdir.mk
@@ -0,0 +1,43 @@
+# This file is intended to be included from each subdirectory
+# makefile.
+
+ifeq ($(Dir),)
+ $(error "No Dir variable defined.")
+endif
+
+ifeq ($(DebugMake),1)
+ $(info MAKE: $(Dir): Processing subdirectory)
+endif
+
+# Expand template for each configuration and architecture.
+# FIXME: This level of logic should be in primary Makefile?
+ifeq ($(OnlyConfigs),)
+ ConfigsToTraverse := $(Configs)
+else
+ ConfigsToTraverse := $(OnlyConfigs)
+endif
+
+ifeq ($(OnlyArchs),)
+ ArchsToTraverse := $(Archs)
+else
+ ArchsToTraverse := $(OnlyArchs)
+endif
+
+$(foreach config,$(ConfigsToTraverse), \
+ $(foreach arch,$(ArchsToTraverse), \
+ $(eval $(call CNA_subdir_template,$(config),$(arch),$(Dir)))))
+
+###
+# Include child makefile fragments
+
+# Evaluate this now so we do not have to worry about order of
+# evaluation.
+SubDirsList := $(SubDirs:%=$(Dir)/%)
+ifeq ($(SubDirsList),)
+else
+ ifeq ($(DebugMake),1)
+ $(info MAKE: Descending into subdirs: $(SubDirsList))
+ endif
+ $(foreach subdir,$(SubDirsList),$(eval include $(subdir)/Makefile.mk))
+endif
+
diff --git a/make/util.mk b/make/util.mk
new file mode 100644
index 000000000..4c08fe4b7
--- /dev/null
+++ b/make/util.mk
@@ -0,0 +1,29 @@
+# Makefile utilities
+
+###
+# Utility functions
+
+# Function: Set variable value
+#
+# Set the given make variable to the given value.
+Set = $(eval $(1) := $(2))
+
+# Function: Append variable value
+#
+# Append the given value to the given make variable.
+Append = $(eval $(1) += $(2))
+
+###
+# Clean up make behavior
+
+# Cancel all suffix rules. We don't want no stinking suffix rules.
+.SUFFIXES:
+
+###
+# Debugging
+
+# General debugging rule, use 'make print-XXX' to print the
+# definition, value and origin of XXX.
+print-%:
+ $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))
+