summaryrefslogtreecommitdiff
path: root/mk/c.mk
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-11-20 22:16:49 -0800
committerOri Bernstein <ori@eigenstate.org>2015-11-20 22:16:49 -0800
commita57ce36f628ff500404b41064bd2a95c7bfa510d (patch)
tree0f142c6cbbfaeaa6dc3e1b93d7829313c6f0333e /mk/c.mk
parentb558899eeecc4e42a9333d61ba0eeaec662a4b8b (diff)
downloadmc-a57ce36f628ff500404b41064bd2a95c7bfa510d.tar.gz
Sync makefile with latest templates.
Diffstat (limited to 'mk/c.mk')
-rw-r--r--mk/c.mk22
1 files changed, 17 insertions, 5 deletions
diff --git a/mk/c.mk b/mk/c.mk
index 42dbcf1..e69a240 100644
--- a/mk/c.mk
+++ b/mk/c.mk
@@ -1,12 +1,15 @@
.DEFAULT_GOAL=all
_DEPS=$(addprefix .deps/, $(OBJ:.o=.d))
+_PCHDRS=$(shell [ -z "$(PCPKGS)" ] || pkg-config --cflags $(PCPKGS))
+_PCLIBS=$(shell [ -z "$(PCPKGS)" ] ||pkg-config --libs $(PCPKGS))
+
_LIBSRCHPATHS=$(addprefix -L, $(dir $(DEPS)))
-_LIBINCPATHS=$(addprefix -I, $(dir $(DEPS)))
-_LIBPATHS=$(addprefix -l, $(patsubst lib%.a,%,$(notdir $(DEPS))))
+_LIBINCPATHS=$(addprefix -I, $(dir $(DEPS))) $(_PCHDRS)
+_LIBPATHS=$(addprefix -l, $(patsubst lib%.a,%,$(notdir $(DEPS)))) $(_PCLIBS)
# yeah, I should probably remove -Werror, but it's nice for developing alone.
-CFLAGS += -Wall -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-array-bounds -g
+CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-array-bounds -g
CFLAGS += -MMD -MP -MF .deps/$(subst /,-,$*).d
LIB ?= $(INSTLIB)
@@ -16,9 +19,9 @@ BIN ?= $(INSTBIN)
.SUFFIXES:
.SECONDARY:
.PHONY: clean clean-gen clean-bin clean-obj clean-misc clean-backups
-.PHONY: all
+.PHONY: all _modversions
-all: subdirs $(BIN) $(LIB) $(EXTRA)
+all: _modversions subdirs $(BIN) $(LIB) $(EXTRA)
$(LIB): $(OBJ) $(EXTRADEP) $(DEPS)
$(AR) -rcs $@ $(OBJ)
@@ -115,10 +118,19 @@ uninstall: subdirs-uninstall $(EXTRAUNINSTALL)
%.o: %.c $(GENHDR) .deps/stamp
$(CC) -c $(CFLAGS) $(_LIBINCPATHS) $<
+%.o: %.cpp $(GENHDR) .deps/stamp
+ $(CXX) -c $(CFLAGS) $(_LIBINCPATHS) $<
+
+%.o: %.cc $(GENHDR) .deps/stamp
+ $(CXX) -c $(CFLAGS) $(_LIBINCPATHS) $<
+
.deps/stamp:
mkdir -p .deps && touch .deps/stamp
config.mk: configure
./configure --redo
+_modversions:
+ @[ -z "$(PCPKGS)" ] || pkg-config --modversion $(PCPKGS) > /dev/null
+
-include $(_DEPS)