makefiles: build subdirs (Thanks Kacper)

This commit is contained in:
Michael Stapelberg 2011-07-25 00:31:35 +02:00
parent 1a3f4c2f7d
commit 6a07e08320
5 changed files with 31 additions and 13 deletions

View File

@ -18,14 +18,25 @@ else
UNUSED:=$(shell $(MAKE) loglevels.h) UNUSED:=$(shell $(MAKE) loglevels.h)
endif endif
SUBDIRS=i3-msg i3-input i3-nagbar i3-config-wizard
# Depend on the specific file (.c for each .o) and on all headers # Depend on the specific file (.c for each .o) and on all headers
src/%.o: src/%.c ${HEADERS} src/%.o: src/%.c ${HEADERS}
echo "CC $<" echo "CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="((uint64_t)1 << $(shell awk '/$(shell basename $< .c)/ { print NR; exit 0; }' loglevels.tmp))" -c -o $@ $< $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="((uint64_t)1 << $(shell awk '/$(shell basename $< .c)/ { print NR; exit 0; }' loglevels.tmp))" -c -o $@ $<
all: src/cfgparse.y.o src/cfgparse.yy.o src/cmdparse.y.o src/cmdparse.yy.o ${FILES} all: i3 subdirs
i3: src/cfgparse.y.o src/cfgparse.yy.o src/cmdparse.y.o src/cmdparse.yy.o ${FILES}
echo "LINK i3" echo "LINK i3"
$(CC) $(LDFLAGS) -o i3 $^ $(LIBS) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
subdirs:
for dir in $(SUBDIRS); do \
echo ""; \
echo "MAKE $$dir"; \
$(MAKE) -C $$dir; \
done
loglevels.h: loglevels.h:
echo "LOGLEVELS" echo "LOGLEVELS"
@ -74,10 +85,9 @@ install: all
$(INSTALL) -m 0644 i3.welcome $(DESTDIR)$(SYSCONFDIR)/i3/welcome $(INSTALL) -m 0644 i3.welcome $(DESTDIR)$(SYSCONFDIR)/i3/welcome
$(INSTALL) -m 0644 i3.desktop $(DESTDIR)$(PREFIX)/share/xsessions/ $(INSTALL) -m 0644 i3.desktop $(DESTDIR)$(PREFIX)/share/xsessions/
$(INSTALL) -m 0644 include/i3/ipc.h $(DESTDIR)$(PREFIX)/include/i3/ $(INSTALL) -m 0644 include/i3/ipc.h $(DESTDIR)$(PREFIX)/include/i3/
$(MAKE) TOPDIR=$(TOPDIR) -C i3-msg install for dir in $(SUBDIRS); do \
$(MAKE) TOPDIR=$(TOPDIR) -C i3-input install $(MAKE) -C $$dir install; \
$(MAKE) TOPDIR=$(TOPDIR) -C i3-nagbar install done
$(MAKE) TOPDIR=$(TOPDIR) -C i3-config-wizard install
dist: distclean dist: distclean
[ ! -d i3-${VERSION} ] || rm -rf i3-${VERSION} [ ! -d i3-${VERSION} ] || rm -rf i3-${VERSION}

View File

@ -13,9 +13,11 @@ HEADERS:=$(wildcard *.h)
echo "CC $<" echo "CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
all: cfgparse.y.o cfgparse.yy.o ${FILES} all: i3-config-wizard
i3-config-wizard: cfgparse.y.o cfgparse.yy.o ${FILES}
echo "LINK i3-config-wizard" echo "LINK i3-config-wizard"
$(CC) $(LDFLAGS) -o i3-config-wizard $^ $(LIBS) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
cfgparse.yy.o: cfgparse.l cfgparse.y.o ${HEADERS} cfgparse.yy.o: cfgparse.l cfgparse.y.o ${HEADERS}
echo "LEX $<" echo "LEX $<"

View File

@ -12,9 +12,11 @@ HEADERS=$(wildcard *.h)
echo "CC $<" echo "CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
all: ${FILES} all: i3-input
i3-input: ${FILES}
echo "LINK i3-input" echo "LINK i3-input"
$(CC) $(LDFLAGS) -o i3-input ${FILES} $(LIBS) $(CC) $(LDFLAGS) -o $@ ${FILES} $(LIBS)
install: all install: all
echo "INSTALL" echo "INSTALL"

View File

@ -14,7 +14,9 @@ HEADERS=$(wildcard *.h)
echo "CC $<" echo "CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
all: ${FILES} all: i3-msg
i3-msg: ${FILES}
echo "LINK i3-msg" echo "LINK i3-msg"
$(CC) $(LDFLAGS) -o i3-msg ${FILES} $(LIBS) $(CC) $(LDFLAGS) -o i3-msg ${FILES} $(LIBS)

View File

@ -12,9 +12,11 @@ HEADERS=$(wildcard *.h)
echo "CC $<" echo "CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
all: ${FILES} all: i3-nagbar
i3-nagbar: ${FILES}
echo "LINK i3-nagbar" echo "LINK i3-nagbar"
$(CC) $(LDFLAGS) -o i3-nagbar ${FILES} $(LIBS) $(CC) $(LDFLAGS) -o $@ ${FILES} $(LIBS)
install: all install: all
echo "INSTALL" echo "INSTALL"