2015-10-16 19:55:09 -05:00
|
|
|
# 16 october 2015
|
|
|
|
|
2015-12-11 19:04:31 -06:00
|
|
|
# TODO the loader looks for the soname, not the base name, which is frustrating
|
|
|
|
|
2015-12-11 17:28:07 -06:00
|
|
|
# Global flags.
|
2015-10-16 19:55:09 -05:00
|
|
|
|
|
|
|
CFLAGS += \
|
2015-12-11 17:28:07 -06:00
|
|
|
-fPIC \
|
2015-11-17 18:52:05 -06:00
|
|
|
-Wall -Wextra -pedantic \
|
2015-10-16 19:55:09 -05:00
|
|
|
-Wno-unused-parameter \
|
|
|
|
-Wno-switch \
|
|
|
|
--std=c99
|
|
|
|
|
2015-11-17 19:01:01 -06:00
|
|
|
# C++11 is needed due to stupid rules involving commas at the end of enum lists that C++03 stupidly didn't follow
|
|
|
|
# This means sorry, no GCC 2 for Haiku builds :(
|
2015-11-17 10:49:23 -06:00
|
|
|
CXXFLAGS += \
|
2015-12-11 17:28:07 -06:00
|
|
|
-fPIC \
|
2015-11-17 18:52:05 -06:00
|
|
|
-Wall -Wextra -pedantic \
|
2015-11-17 10:49:23 -06:00
|
|
|
-Wno-unused-parameter \
|
|
|
|
-Wno-switch \
|
2015-11-17 19:01:01 -06:00
|
|
|
--std=c++11
|
2015-11-17 10:49:23 -06:00
|
|
|
|
2015-10-16 19:55:09 -05:00
|
|
|
LDFLAGS += \
|
2015-12-11 17:28:07 -06:00
|
|
|
-fPIC
|
|
|
|
|
|
|
|
ifneq ($(NODEBUG),1)
|
|
|
|
CFLAGS += -g
|
|
|
|
CXXFLAGS += -g
|
|
|
|
LDFLAGS += -g
|
|
|
|
endif
|
|
|
|
|
2015-12-11 17:37:15 -06:00
|
|
|
# Build rules.
|
|
|
|
|
2015-12-11 17:28:07 -06:00
|
|
|
OFILES = \
|
|
|
|
$(subst /,_,$(CFILES)) \
|
|
|
|
$(subst /,_,$(CXXFILES)) \
|
|
|
|
$(subst /,_,$(MFILES)) \
|
|
|
|
$(subst /,_,$(RCFILES))
|
|
|
|
|
|
|
|
OFILES := $(OFILES:%=$(OBJDIR)/%.o)
|
2015-10-16 19:55:09 -05:00
|
|
|
|
|
|
|
OUT = $(OUTDIR)/$(NAME)$(SUFFIX)
|
2016-01-05 10:51:36 -06:00
|
|
|
OUTNOSONAME = $(OUTDIR)/$(NAME)$(LIBSUFFIX)
|
2015-10-16 19:55:09 -05:00
|
|
|
|
2015-12-11 17:37:15 -06:00
|
|
|
# TODO allow using LD
|
|
|
|
# LD is defined by default so we need a way to override the default define without blocking a user define
|
|
|
|
ifeq ($(CXXFILES),)
|
|
|
|
reallinker = $(CC)
|
|
|
|
else
|
|
|
|
reallinker = $(CXX)
|
|
|
|
endif
|
2015-11-17 10:49:23 -06:00
|
|
|
|
2015-10-16 19:55:09 -05:00
|
|
|
$(OUT): $(OFILES) | $(OUTDIR)
|
2015-12-11 17:37:15 -06:00
|
|
|
@$(reallinker) -o $(OUT) $(OFILES) $(LDFLAGS)
|
2016-01-05 10:51:36 -06:00
|
|
|
ifeq ($(USESSONAME),1)
|
2016-01-07 14:43:35 -06:00
|
|
|
@ln -sf $(NAME)$(SUFFIX) $(OUTNOSONAME)
|
2016-01-05 10:51:36 -06:00
|
|
|
endif
|
2015-10-16 19:55:09 -05:00
|
|
|
@echo ====== Linked $(OUT)
|
|
|
|
|
|
|
|
.SECONDEXPANSION:
|
|
|
|
|
|
|
|
$(OBJDIR)/%.c.o: $$(subst _,/,%).c $(HFILES) | $(OBJDIR)
|
|
|
|
@$(CC) -o $@ -c $< $(CFLAGS)
|
|
|
|
@echo ====== Compiled $<
|
|
|
|
|
2015-11-17 10:49:23 -06:00
|
|
|
$(OBJDIR)/%.cpp.o: $$(subst _,/,%).cpp $(HFILES) | $(OBJDIR)
|
|
|
|
@$(CXX) -o $@ -c $< $(CXXFLAGS)
|
|
|
|
@echo ====== Compiled $<
|
|
|
|
|
2015-10-16 19:55:09 -05:00
|
|
|
$(OBJDIR)/%.m.o: $$(subst _,/,%).m $(HFILES) | $(OBJDIR)
|
|
|
|
@$(CC) -o $@ -c $< $(CFLAGS)
|
|
|
|
@echo ====== Compiled $<
|
|
|
|
|
|
|
|
$(OBJDIR)/%.rc.o: $$(subst _,/,%).rc $(HFILES) | $(OBJDIR)
|
|
|
|
@$(RC) $(RCFLAGS) $< $@
|
|
|
|
@echo ====== Compiled $<
|
|
|
|
|
|
|
|
$(OBJDIR) $(OUTDIR):
|
|
|
|
@mkdir -p $@
|