### ###
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)
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)
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)
Extra_LD_Flags += -Wl,-syslibroot,$(SDKROOT)
endif
-ifneq ($(RC_TARGET_CONFIG),)
-ifeq ($(shell tconf --product),)
-$(error undefined Target Config: $(RC_TARGET_CONFIG))
-endif
-endif
-
## Dylib Support ##
ifeq ($(Library_Compatibility_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) \
$(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 ###
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)
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
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 \
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::