diff options
Diffstat (limited to 'src/prog.mk')
-rw-r--r-- | src/prog.mk | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/prog.mk b/src/prog.mk new file mode 100644 index 000000000..84f43142d --- /dev/null +++ b/src/prog.mk | |||
@@ -0,0 +1,36 @@ | |||
1 | # Common definitions for building C programs and non-shared objects. | ||
2 | # | ||
3 | # Note: $(ROOT)/config.mk must be included before this file. | ||
4 | # | ||
5 | # The includer should probably define PROG and TARGET and may also want to | ||
6 | # define MOD_HDRS, MOD_SRCS, MOD_OBJS, TOCLEAN and TODISTCLEAN. | ||
7 | |||
8 | HDRS := $(sort $(wildcard *.h)) $(MOD_HDRS) | ||
9 | SRCS := $(sort $(wildcard *.c)) $(MOD_SRCS) | ||
10 | OBJS := $(SRCS:.c=.o) $(MOD_OBJS) | ||
11 | |||
12 | CFLAGS += \ | ||
13 | -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' \ | ||
14 | -fstack-protector-all -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security \ | ||
15 | -fPIE \ | ||
16 | -DPREFIX='"$(prefix)"' -DSYSCONFDIR='"$(sysconfdir)/firejail"' \ | ||
17 | -DLIBDIR='"$(libdir)"' -DBINDIR='"$(bindir)"' \ | ||
18 | -DVARDIR='"/var/lib/firejail"' \ | ||
19 | $(HAVE_GCOV) $(MANFLAGS) | ||
20 | |||
21 | LDFLAGS += -pie -fPIE -Wl,-z,relro -Wl,-z,now | ||
22 | |||
23 | .PHONY: all | ||
24 | all: $(TARGET) | ||
25 | |||
26 | %.o : %.c $(HDRS) $(ROOT)/config.mk | ||
27 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@ | ||
28 | |||
29 | $(PROG): $(OBJS) $(ROOT)/config.mk | ||
30 | $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(EXTRA_LDFLAGS) | ||
31 | |||
32 | .PHONY: clean | ||
33 | clean:; rm -fr *.o $(PROG) *.gcov *.gcda *.gcno *.plist $(TOCLEAN) | ||
34 | |||
35 | .PHONY: distclean | ||
36 | distclean: clean; rm -fr $(TODISTCLEAN) | ||