xref: /openbmc/skeleton/rules.mk (revision f5110e11)
1.DEFAULT_GOAL := all
2sbindir=/usr/sbin
3
4LDLIBS+=$(shell pkg-config --libs $(PACKAGE_DEPS))
5ALL_CFLAGS+=$(shell pkg-config --cflags $(PACKAGE_DEPS)) -fPIC -Werror $(CFLAGS)
6
7BIN_SUFFIX?=.exe
8.PHONY: $(SUBDIRS)
9
10all: $(BINS:=$(BIN_SUFFIX)) $(SUBDIRS)
11
12%.o: %.c
13	$(CC) -c $(ALL_CFLAGS) -o $@ $<
14
15$(SUBDIRS):
16	$(MAKE) -C $@
17
18$(BINS:=$(BIN_SUFFIX)): %$(BIN_SUFFIX): %.o $(EXTRA_OBJS)
19	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
20
21install: $(BINS:=$(BIN_SUFFIX))
22	@mkdir -p $(DESTDIR)$(sbindir)
23	@for b in $(BINS:=$(BIN_SUFFIX)); do \
24		install $$b $(DESTDIR)$(sbindir) || exit 1; \
25	done
26	@for d in $(SUBDIRS); do \
27		$(MAKE) -C $$d $@ || exit 1; \
28	done
29
30clean:
31	rm -rf *.o $(BINS:=$(BIN_SUFFIX))
32	@for d in $(SUBDIRS); do \
33		$(MAKE) -C $$d $@ || exit 1; \
34	done
35