Aegisub/Makefile.target

186 lines
4.5 KiB
Makefile
Raw Normal View History

# *** THERE ARE NO USER-EDITABLE ITEMS HERE. ***
#
# TODO:
# * Allow variables to be overridden on the CL.
.PHONY: all install clean subdirs $(SUBDIRS)
all: subdirs $(PROGRAM)
.DEFAULT_GOAL := all
ifneq (no, $(BUILD_LIB))
all: $(LIB) $(LIB_SHARED)
endif
OBJ = $(addsuffix .o, $(basename $(SRC)))
DEP = $(addsuffix .d, $(basename $(SRC)))
###################
# PLATFORM SPECIFIC
###################
ifeq (yes, $(BUILD_DARWIN))
CFLAGS += -mmacosx-version-min=10.7 -gfull
CXXFLAGS += -mmacosx-version-min=10.7 -gfull
2014-04-28 04:45:14 +02:00
LDFLAGS += -mmacosx-version-min=10.7 -Wl,-dead_strip -pagezero_size 10000 -image_base 100000000
LIB_SHARED_LINK = $(LIB_SHARED_LINK_OSX)
endif
###########
# LIBRARIES
###########
$(LIB) : $(OBJ)
$(BIN_AR) cru $@ $(OBJ)
$(BIN_RANLIB) $@
ifdef LIB_SHARED
LIB_SHARED_FULL = $(LIB_SHARED).$(LIB_VERSION)
$(LIB_SHARED) : $(OBJ)
$(BIN_CXX) $(LIB_SHARED_LINK) $(LDFLAGS) $(OBJ) $(LIBS) -o $(LIB_SHARED_FULL)
$(BIN_LN) -sf $(LIB_SHARED_FULL) $(LIB_SHARED)
CLEANFILES+= $(LIB_SHARED_FULL)
endif
##########
# PROGRAMS
##########
$(PROGRAM): $(OBJ)
$(BIN_CXX) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
##########
# CLEANING
##########
clean: $(SUBDIRS)
$(BIN_RM) -f $(OBJ) $(CLEANFILES) $(LIB) $(LIB_SHARED) $(PROGRAM)
ifdef PRECOMPILED_HEADER_NAME
$(BIN_RM) -f $(PRECOMPILED_HEADER_NAME).gch
endif
mostlyclean: $(SUBDIRS)
$(BIN_RM) -f $(OBJ) $(CLEANFILES) $(LIB) $(LIB_SHARED) $(PROGRAM)
distclean: clean
$(BIN_RM) -rf $(DISTCLEANFILES) $(DEP)
ifdef PRECOMPILED_HEADER_NAME
$(BIN_RM) -f $(PRECOMPILED_HEADER_NAME).gch
endif
#########
# INSTALL
#########
ifeq (install, $(MAKECMDGOALS))
INSTALL_LIB=$(addprefix $(P_LIB)/, $(LIB_SHARED) $(LIB_SHARED_FULL))
endif
BIN_SINSTALL=$(BIN_INSTALL)
install: $(SUBDIRS) install-share install-program install-lib
install-strip:
$(MAKE) BIN_SINSTALL='$(BIN_INSTALL) -s' install
install-program:
ifdef PROGRAM_INSTALL
@$(BIN_MKDIR) -p $(DESTDIR)$(P_BINDIR)
@$(BIN_SINSTALL) $(PROGRAM) $(DESTDIR)$(P_BINDIR)/$(PROGRAM)
endif
install-lib:
ifdef LIB_SHARED_INSTALL
$(BIN_MKDIR) -p $(DESTDIR)$(P_LIB)
$(BIN_SINSTALL) $(LIB_SHARED_FULL) $(DESTDIR)$(P_LIB)/$(LIB_SHARED_FULL)
$(BIN_LN) -sf $(LIB_SHARED_FULL) $(DESTDIR)$(P_LIB)/$(LIB_SHARED)
endif
install-share:
ifdef DATA_SHARE
@$(BIN_MKDIR) -p $(addprefix $(DESTDIR)$(P_DATA)/, $(dir $(DATA_SHARE)))
@for i in $(DATA_SHARE); do \
$(BIN_ECHO) "$(BIN_INSTALL) $$i $(DESTDIR)$(P_DATA)/$$i"; \
$(BIN_INSTALL) $$i $(DESTDIR)$(P_DATA)/$$i; \
done
endif
ifdef DATA_SHARE_DOC
@$(BIN_MKDIR) -p $(addprefix $(DESTDIR)$(P_DOC)/, $(dir $(DATA_SHARE_DOC)))
@for i in $(DATA_SHARE_DOC); do \
$(BIN_ECHO) "$(BIN_INSTALL) $$i $(DESTDIR)$(P_DOC)/$$i"; \
$(BIN_INSTALL) $$i $(DESTDIR)$(P_DOC)/$$i; \
done
endif
########################
# SUBDIRECTORY TRAVERSAL
########################
subdirs: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)
# Set relations to ensure dependencies are built before their targets during parallel builds.
2014-04-28 04:45:14 +02:00
automation: libaegisub vendor/luajit
src: vendor/universalchardet vendor/luajit tools libaegisub
tests: libaegisub
tools: libaegisub
$(OBJ): $(GLOBAL_DEPS)
OBJCXXFLAGS := $(CXXFLAGS)
####################
# PRECOMPILED HEADER
####################
ifdef PRECOMPILED_HEADER_NAME
ifeq (yes, $(PRECOMPILED_HEADER))
CXXFLAGS += -include $(PRECOMPILED_HEADER_NAME) $(PCHFLAGS)
# This hack is required until we can use the 'private' keyword (gmake 3.82) to avoid all the
# per-object CXXFLAGS being triggered by the ($OBJ) line.
CXXFLAGS_GNU_MAKE_SUCKS := $(CXXFLAGS)
$(OBJ): | $(PRECOMPILED_HEADER_NAME).gch
$(PRECOMPILED_HEADER_NAME).gch: CXXFLAGS = $(CXXFLAGS_GNU_MAKE_SUCKS)
$(PRECOMPILED_HEADER_NAME).gch: $(PRECOMPILED_HEADER_NAME)
else
CXXFLAGS += -include acconf.h
endif
endif
########
# CCACHE
########
ifeq (yes, $(CCACHE_ENABLE))
CXX_ENV = $(CCACHE_ENV)
BIN_CC := ccache $(BIN_CC)
BIN_CXX := ccache $(BIN_CXX)
endif
##################
# TRANSFORM RULES
##################
.SUFFIXES:
.SUFFIXES: .o .c .cpp .cxx .mm
%.o: %.c
$(CXX_ENV) $(BIN_CC) $(CFLAGS_DEP) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
%.o: %.cpp
$(CXX_ENV) $(BIN_CXX) $(CFLAGS_DEP) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
%.o: %.cxx
$(CXX_ENV) $(BIN_CXX) $(CFLAGS_DEP) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
2012-11-07 16:36:31 +01:00
%.o: %.cc
$(CXX_ENV) $(BIN_CXX) $(CFLAGS_DEP) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
%.o: %.mm
$(CXX_ENV) $(BIN_CXX) $(CFLAGS_DEP) $(CPPFLAGS) $(OBJCXXFLAGS) -c -o $@ $<
$(PRECOMPILED_HEADER_NAME).gch: $(PRECOMPILED_HEADER_NAME)
$(CXX_ENV) $(BIN_CXX) $(CPPFLAGS) $(CXXFLAGS) -x c++-header $<
-include ($DEP)
.SUFFIXES: