summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorOri Bernstein <ori@odin.theasylum>2011-11-05 01:32:46 -0400
committerOri Bernstein <ori@odin.theasylum>2011-11-05 01:34:58 -0400
commita23fd593dadd3806339a7bbadc89031a8f542cf5 (patch)
treecd51bfe84f24f8aba6fd4aaf0885cb03b0e13f73 /mk
downloadmc-a23fd593dadd3806339a7bbadc89031a8f542cf5.tar.gz
Initial commit
Diffstat (limited to 'mk')
-rw-r--r--mk/c.mk73
-rw-r--r--mk/lexyacc.mk9
2 files changed, 82 insertions, 0 deletions
diff --git a/mk/c.mk b/mk/c.mk
new file mode 100644
index 0000000..4e6e3be
--- /dev/null
+++ b/mk/c.mk
@@ -0,0 +1,73 @@
+DEPSDIR = .deps
+DEPS=$(addprefix $(DEPSDIR)/, $(OBJ:.o=.d))
+
+CFLAGS += -Wall -Werror
+CFLAGS += -g
+CFLAGS += -MMD -MP -MF ${DEPSDIR}/$(subst /,-,$*).d
+
+.PHONY: clean clean-gen clean-bin clean-obj clean-misc clean-backups
+.PHONY: all
+
+all: subdirs $(BIN) $(LIB) $(EXTRA)
+install: subdirs-install install-bin install-lib install-hdr install-pc
+
+$(LIB): $(OBJ)
+ $(AR) -rcs $@ $^
+
+$(BIN): $(OBJ) $(EXTRADEP)
+ $(CC) -o $@ $(OBJ) $(LDFLAGS)
+
+subdirs:
+ @for i in $(SUB); do (\
+ cd $$i && \
+ $(MAKE) || \
+ exit 1 \
+ ) || exit 1; done
+
+subdirs-clean:
+ @for i in $(SUB); do (\
+ cd $$i && \
+ $(MAKE) clean|| \
+ exit 1 \
+ ); done
+
+subdirs-install:
+ @for i in $(SUB); do (\
+ cd $$i && \
+ $(MAKE) install|| \
+ exit 1 \
+ ); done
+
+
+clean: subdirs-clean
+ rm -f ${BIN} ${OBJ} ${CLEAN}
+
+
+install-bin: $(INSTBIN)
+ mkdir -p $(INST_ROOT)/bin
+ test -z "$(INSTBIN)" || install $(INSTBIN) $(INST_ROOT)/bin
+
+install-lib: $(INSTLIB)
+ mkdir -p $(INST_ROOT)/lib
+ test -z "$(INSTLIB)" || install $(INSTLIB) $(INST_ROOT)/lib
+
+install-hdr: $(INSTHDR)
+ mkdir -p $(INST_ROOT)/$(HDRDIR)/include
+ test -z "$(INSTHDR)" || install $(INSTHDR) $(INST_ROOT)/include
+
+install-pc: $(INSTPKG)
+ mkdir -p $(INST_ROOT)/pkgconfig
+ test -z "$(INSTPC)" || install $(INSTPC) $(INST_ROOT)/pkgconfig
+
+clean-backups:
+ find ./ -name .*.sw* -exec rm -f {} \;
+ find ./ -name *.bak -exec rm -f {} \;
+
+%.o: %.c .deps
+ $(CC) -c $(CFLAGS) $<
+
+.deps:
+ mkdir -p $(DEPSDIR)
+
+
+-include $(DEPS)
diff --git a/mk/lexyacc.mk b/mk/lexyacc.mk
new file mode 100644
index 0000000..8d104f6
--- /dev/null
+++ b/mk/lexyacc.mk
@@ -0,0 +1,9 @@
+NECFLAGS = $(subst -Werror,,$(subst -Wall,,$(CFLAGS)))
+
+%.o: %.y .deps
+ yacc -d -o$*.c $<
+ $(CC) -c $(NECFLAGS) $*.c
+
+%.o: %.l .deps
+ flex -o$*.c $<
+ $(CC) -c $(NECFLAGS) $*.c