2015-10-16 19:55:09 -05:00
|
|
|
# 16 october 2015
|
|
|
|
|
2015-12-11 17:28:07 -06:00
|
|
|
# Global flags.
|
2015-10-16 19:55:09 -05:00
|
|
|
|
|
|
|
CFLAGS += \
|
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-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
|
|
|
|
2016-05-29 21:02:49 -05:00
|
|
|
# -fPIC shouldn't be used with static builds (see https://github.com/andlabs/libui/issues/72#issuecomment-222395547)
|
|
|
|
ifeq (,$(STATIC))
|
|
|
|
CFLAGS += -fPIC
|
|
|
|
CXXFLAGS += -fPIC
|
|
|
|
LDFLAGS += -fPIC
|
|
|
|
endif
|
2015-12-11 17:28:07 -06:00
|
|
|
|
2016-05-14 10:12:45 -05:00
|
|
|
ifneq ($(RELEASE),1)
|
2015-12-11 17:28:07 -06:00
|
|
|
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
|
|
|
|
2016-05-25 17:18:48 -05:00
|
|
|
include $(OS)/GNUosspecificlink.mk
|
2015-10-16 19:55:09 -05:00
|
|
|
|
|
|
|
.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 $@
|