X-Git-Url: https://git.saurik.com/apple/coreosmakefiles.git/blobdiff_plain/859ae4bff646ed09b0aa06c05ac3713294172044..HEAD:/ReleaseControl/BSDCommon.make?ds=sidebyside diff --git a/ReleaseControl/BSDCommon.make b/ReleaseControl/BSDCommon.make index d1af115..8aa550f 100644 --- a/ReleaseControl/BSDCommon.make +++ b/ReleaseControl/BSDCommon.make @@ -30,6 +30,9 @@ include $(MAKEFILEPATH)/CoreOS/ReleaseControl/Common.make ### ### Library_Prefix ?= lib +RELEASE_Library_Suffix = $(Library_Suffix) +DEBUG_Library_Suffix = _debug$(Library_Suffix) +PROFILE_Library_Suffix = _profile$(Library_Suffix) ProductType ?= tool ifeq ($(ProductType),tool) @@ -38,26 +41,46 @@ ifeq ($(ProductType),tool) else ifeq ($(ProductType),dylib) Library_Suffix ?= .dylib - ProductName ?= $(Library_Prefix)$(Project)$(if $(Library_Version),.$(Library_Version),)$(Library_Suffix) - ProductNameNoVersion ?= $(Library_Prefix)$(Project)$(Library_Suffix) + ProductName ?= $(Library_Prefix)$(Project)$(Library_Suffix) + ProductNameWithVersion ?= $(Library_Prefix)$(Project)$(if $(Library_Version),.$(Library_Version),)$(Library_Suffix) + RELEASE_ProductName = $(ProductName) + RELEASE_ProductNameWithVersion = $(ProductNameWithVersion) + DEBUG_ProductName = $(ProductName:$(Library_Suffix)=$(DEBUG_Library_Suffix)) + DEBUG_ProductNameWithVersion = $(ProductNameWithVersion:$(Library_Suffix)=$(DEBUG_Library_Suffix)) + PROFILE_ProductName = $(ProductName:$(Library_Suffix)=$(PROFILE_Library_Suffix)) + PROFILE_ProductNameWithVersion = $(ProductNameWithVersion:$(Library_Suffix)=$(PROFILE_Library_Suffix)) Install_Dir ?= /usr/lib else ifeq ($(ProductType),staticlib) Library_Suffix ?= .a ProductName ?= $(Library_Prefix)$(Project)$(Library_Suffix) + RELEASE_ProductName = $(ProductName) + DEBUG_ProductName = $(ProductName:$(Library_Suffix)=$(DEBUG_Library_Suffix)) + PROFILE_ProductName = $(ProductName:$(Library_Suffix)=$(PROFILE_Library_Suffix)) Install_Dir ?= /usr/local/lib else + ifeq ($(ProductType),none) + else $(error Unknown ProductType: $(ProductType)) + endif endif endif endif +BUILD_STYLES = RELEASE +ifeq ($(BuildDebug),YES) +BUILD_STYLES += DEBUG +endif +ifeq ($(BuildProfile),YES) +BUILD_STYLES += PROFILE +endif + ALL_FILES = $(CFILES) $(MFILES) $(CXXFILES) $(USERDEFS) $(SERVERDEFS) $(MANPAGES) ALL_SRCFILES = $(CFILES) $(MFILES) $(CXXFILES) ## MIG ## -MIGFLAGS=$(Extra_MIG_Flags) +MIGFLAGS=$(CFLAGS) $(Extra_MIG_Flags) ifneq ($(USERDEFS),) CFILES += $(foreach FILE, $(USERDEFS:.defs=_user.c), $(OBJROOT)/$(Project)/$(notdir $(FILE))) endif @@ -78,6 +101,13 @@ ifneq ($(RPCSVCFILES),) CFILES += $(foreach FILE, $(RPCFILES:.x=_svc.c), $(OBJROOT)/$(Project)/$(notdir $(FILE))) endif +## Lex ## + +LFLAGS=$(Extra_L_Flags) +ifneq ($(LFILES),) +CFILES += $(foreach FILE, $(LFILES:.l=.yy.c), $(OBJROOT)/$(Project)/$(notdir $(FILE))) +endif + ## Yacc ## YFLAGS=$(Extra_Y_Flags) @@ -90,12 +120,7 @@ endif ifneq ($(SDKROOT),) Extra_CC_Flags += -isysroot $(SDKROOT) Extra_LD_Flags += -Wl,-syslibroot,$(SDKROOT) -endif - -ifneq ($(RC_TARGET_CONFIG),) -ifeq ($(shell tconf --product),) -$(error undefined Target Config: $(RC_TARGET_CONFIG)) -endif +export MIGCC = $(shell xcrun -find -sdk $(SDKROOT) cc) endif ## Dylib Support ## @@ -107,12 +132,27 @@ ifeq ($(Library_Current_Version),) Library_Current_Version = $(if $(RC_ProjectSourceVersion), $(RC_ProjectSourceVersion), 1) endif -ALL_OFILES = $(foreach OFILE, \ +RELEASE_OFILE_SUFFIX=.o +DEBUG_OFILE_SUFFIX=_debug.o +PROFILE_OFILE_SUFFIX=_profile.o + +RELEASE_ALL_OFILES = $(foreach OFILE, \ $(CFILES:.c=.o) \ $(MFILES:.m=.o) \ - $(CXXFILES:.%=.o) \ + $(CXXFILES:.cc=.o) \ $(OTHER_OFILES), \ $(OBJROOT)/$(Project)/$(notdir $(OFILE))) +DEBUG_ALL_OFILES = $(RELEASE_ALL_OFILES:.o=$(DEBUG_OFILE_SUFFIX)) +PROFILE_ALL_OFILES = $(RELEASE_ALL_OFILES:.o=$(PROFILE_OFILE_SUFFIX)) +ALL_OFILES = $(RELEASE_ALL_OFILES) $(DEBUG_ALL_OFILES) $(PROFILE_ALL_OFILES) + +RELEASE_CFLAGS = $(CFLAGS) +DEBUG_CFLAGS = $(CFLAGS) -DDEBUG +PROFILE_CFLAGS = $(CFLAGS) -pg -DPROFILE + +RELEASE_LDFLAGS = $(LDFLAGS) +DEBUG_LDFLAGS = $(LDFLAGS) +PROFILE_LDFLAGS = $(LDFLAGS) ### ### ### Targets ### @@ -123,7 +163,13 @@ ALL_OFILES = $(foreach OFILE, \ Install_Headers_Directory ?= /usr/include Install_Private_Headers_Directory ?= /usr/local/include -installhdrs:: +installhdrs:: _installhdrs +ifneq ($(SubProjects),) + make recurse TARGET=$@ RC_ARCHS="$(RC_ARCHS)" +endif + +_installhdrs:: + @true # avoid nothing to be done warning ifneq ($(Install_Headers),) @echo "Installing headers for $(Project)..." $(INSTALL_DIRECTORY) $(DSTROOT)/$(Install_Headers_Directory) @@ -141,30 +187,38 @@ ifneq ($(Install_Private_Headers),) done endif -install:: build installhdrs - @echo "Installing $(Project)..." -ifneq ($(SubProjects),) - make recurse TARGET=install RC_ARCHS="$(RC_ARCHS)" -else +install:: build _installhdrs + @echo "====== Installing $(Project) =====" +#ifneq ($(SubProjects),) +# make recurse TARGET=$@ RC_ARCHS="$(RC_ARCHS)" +#endif $(INSTALL_DIRECTORY) $(DSTROOT)/$(Install_Dir) -ifneq ($(ALL_OFILES),) +ifneq ($(strip $(ALL_OFILES)),) ifeq ($(ProductType),tool) $(INSTALL_PROGRAM) $(SYMROOT)/$(ProductName) $(DSTROOT)/$(Install_Dir) else ifeq ($(ProductType),dylib) - $(INSTALL_DYLIB) $(SYMROOT)/$(ProductName) $(DSTROOT)/$(Install_Dir) - $(STRIP) -S $(DSTROOT)/$(Install_Dir)/$(ProductName) - ifneq ($(ProductName),$(ProductNameNoVersion)) - $(LN) -sf $(ProductName) $(DSTROOT)/$(Install_Dir)/$(ProductNameNoVersion) - endif + @$(foreach STYLE, $(BUILD_STYLES), \ + CMD="$(INSTALL_DYLIB) $(SYMROOT)/$($(STYLE)_ProductNameWithVersion) \ + $(DSTROOT)/$(Install_Dir)" ; \ + echo $${CMD} ; $${CMD} || exit 1 ; \ + CMD="$(STRIP) -S $(DSTROOT)/$(Install_Dir)/$($(STYLE)_ProductNameWithVersion)" ; \ + echo $${CMD} ; $${CMD} || exit 1 ; \ + if [ "$($(STYLE)_ProductName)" != "$($(STYLE)_ProductNameWithVersion)" ]; then \ + CMD="$(LN) -sf $($(STYLE)_ProductNameWithVersion) \ + $(DSTROOT)/$(Install_Dir)/$($(STYLE)_ProductName)" ; \ + echo $${CMD} ; $${CMD} || exit 1 ; \ + fi ; ) else ifeq ($(ProductType),staticlib) - $(INSTALL_LIBRARY) $(SYMROOT)/$(ProductName) $(DSTROOT)/$(Install_Dir) + @$(foreach STYLE, $(BUILD_STYLES), \ + CMD="$(INSTALL_LIBRARY) $(SYMROOT)/$($(STYLE)_ProductName) \ + $(DSTROOT)/$(Install_Dir)" ; \ + echo $${CMD} ; $${CMD} || exit 1 ; ) endif endif endif endif -endif ifneq ($(MANPAGES),) @make install-man-pages endif @@ -172,7 +226,6 @@ ifneq ($(LAUNCHD_PLISTS),) @make install-launchd-plists endif @make after_install - @$(MAKE) compress_man_pages migdefs:: @$(MKDIR) $(OBJROOT)/$(Project) @@ -213,6 +266,16 @@ rpcfiles: echo $${CMD} ; $${CMD} || exit 1; \ done +lfiles: + @$(MKDIR) $(OBJROOT)/$(Project) + @for FILE in $(LFILES); do \ + OUT=`basename $${FILE} .l` ; \ + CMD="$(LEX) $(LFLAGS) \ + --header-file=$(OBJROOT)/$(Project)/$${OUT}.yy.h \ + -o $(OBJROOT)/$(Project)/$${OUT}.yy.c $${FILE}"; \ + echo $${CMD} ; $${CMD} || exit 1; \ + done + yfiles: @$(MKDIR) $(OBJROOT)/$(Project) @for FILE in $(YFILES); do \ @@ -222,38 +285,56 @@ yfiles: echo $${CMD} ; $${CMD} || exit 1 ; \ done -build:: migdefs rpcfiles yfiles $(ALL_FILES) - @echo "Building $(Project)..." +build:: migdefs rpcfiles yfiles lfiles $(ALL_FILES) +ifneq ($(SubProjects),) + make recurse TARGET=install RC_ARCHS="$(RC_ARCHS)" +endif @$(MKDIR) $(OBJROOT)/$(Project) @$(MKDIR) $(SYMROOT) - @for CFILE in $(ALL_SRCFILES); do \ - OFILE=$$(echo $$(basename $${CFILE}) | sed -e 's,\.[^.]*$$,.o,') ; \ - CMD="$(CC) $(CFLAGS) -c -o $(OBJROOT)/$(Project)/$${OFILE} $${CFILE}" ; \ + @$(foreach STYLE, $(BUILD_STYLES), \ + echo ===== Building $(ProductName) $(STYLE) ===== ; \ + for CFILE in $(ALL_SRCFILES); do \ + OFILE=$(OBJROOT)/$(Project)/$$(echo $$(basename $${CFILE}) | \ + sed -e 's,\.[^.]*$$,$($(STYLE)_OFILE_SUFFIX),') ; \ + if [ ! "$${OFILE}" -nt "$${CFILE}" ]; then \ + CMD="$(CC) $($(STYLE)_CFLAGS) -c -o $${OFILE} $${CFILE}" ; \ echo $$CMD ; $$CMD || exit 1 ; \ - done + fi ; \ + done ; ) -ifneq ($(ALL_OFILES),) +ifneq ($(strip $(ALL_OFILES)),) ifeq ($(ProductType),tool) - $(CC) $(LDFLAGS) -o $(SYMROOT)/$(ProductName) $(ALL_OFILES) + @echo ===== Linking $(ProductName) RELEASE ===== + $(CC) $(RELEASE_LDFLAGS) -o $(SYMROOT)/$(ProductName) \ + $(RELEASE_ALL_OFILES) + dsymutil --out $(SYMROOT)/$(ProductName).dSYM \ + $(SYMROOT)/$(ProductName) || true else ifeq ($(ProductType),dylib) - $(CC) -dynamiclib $(LDFLAGS) \ + @$(foreach STYLE, $(BUILD_STYLES), \ + echo ===== Linking $(ProductName) $(STYLE) ===== ; \ + CMD="$(CC) -dynamiclib $($(STYLE)_LDFLAGS) \ -dynamic \ -compatibility_version $(Library_Compatibility_Version) \ -current_version $(Library_Current_Version) \ - -install_name `echo $(Install_Dir)/$(ProductName) | sed 's,//,/,g'` \ - -o $(SYMROOT)/$(ProductName) \ - $(ALL_OFILES) + -install_name `echo $(Install_Dir)/$($(STYLE)_ProductNameWithVersion) | sed 's,//,/,g'` \ + -o $(SYMROOT)/$($(STYLE)_ProductNameWithVersion) \ + $($(STYLE)_ALL_OFILES)" ; \ + echo $${CMD} ; $${CMD} || exit 1 ; \ + CMD="dsymutil --out $(SYMROOT)/$($(STYLE)_ProductNameWithVersion).dSYM \ + $(SYMROOT)/$($(STYLE)_ProductNameWithVersion)" ; \ + echo $${CMD} ; $${CMD} ; ) else ifeq ($(ProductType),staticlib) - $(LIBTOOL) -static -o $(SYMROOT)/$(ProductName) $(ALL_OFILES) + @$(foreach STYLE, $(BUILD_STYLES), \ + echo ===== Linking $(ProductName) $(STYLE) ===== ; \ + CMD="$(LIBTOOL) -static -o $(SYMROOT)/$($(STYLE)_ProductName) \ + $($(STYLE)_ALL_OFILES)" ; \ + echo $${CMD} ; $${CMD} || exit 1 ; ) endif endif endif - ifneq ($(ProductType),staticlib) - dsymutil --out $(SYMROOT)/$(ProductName).dSYM $(SYMROOT)/$(ProductName) || true - endif endif install-man-pages::