| 1 |
VERSION = 019 |
| 2 |
|
| 3 |
# The toolchain definitions |
| 4 |
CC = cc |
| 5 |
SPARSE = sparse |
| 6 |
|
| 7 |
V = @ # Verbose build: make V=1 |
| 8 |
C = 0 # Sparsechecker build: make C=1 |
| 9 |
Q = $(V:1=) |
| 10 |
QUIET_CC = $(Q:@=@echo ' CC '$@;)$(CC) |
| 11 |
QUIET_DEPEND = $(Q:@=@echo ' DEPEND '$@;)$(CC) |
| 12 |
ifeq ($(C),1) |
| 13 |
QUIET_SPARSE = $(Q:@=@echo ' SPARSE '$@;)$(SPARSE) |
| 14 |
else |
| 15 |
QUIET_SPARSE = @true |
| 16 |
endif |
| 17 |
|
| 18 |
PREFIX ?= /usr/local |
| 19 |
CFLAGS ?= -Os -fomit-frame-pointer |
| 20 |
CFLAGS += -std=c99 -Wall -pedantic -D_BSD_SOURCE |
| 21 |
LDFLAGS ?= |
| 22 |
|
| 23 |
SRCS = fwcutter.c md5.c |
| 24 |
BIN = b43-fwcutter |
| 25 |
|
| 26 |
CFLAGS += -DFWCUTTER_VERSION_=$(VERSION) |
| 27 |
|
| 28 |
.SUFFIXES: |
| 29 |
.PHONY: all install clean distclean |
| 30 |
.DEFAULT_GOAL := all |
| 31 |
|
| 32 |
DEPS = $(sort $(patsubst %.c,dep/%.d,$(1))) |
| 33 |
OBJS = $(sort $(patsubst %.c,obj/%.o,$(1))) |
| 34 |
|
| 35 |
# Generate dependencies |
| 36 |
$(call DEPS,$(SRCS)): dep/%.d: %.c |
| 37 |
@mkdir -p $(dir $@) |
| 38 |
$(QUIET_DEPEND) -o [email protected] -MM -MT "$@ $(patsubst dep/%.d,obj/%.o,$@)" $(CFLAGS) $< && mv -f [email protected] $@ |
| 39 |
|
| 40 |
-include $(call DEPS,$(SRCS)) |
| 41 |
|
| 42 |
# Generate object files |
| 43 |
$(call OBJS,$(SRCS)): obj/%.o: |
| 44 |
@mkdir -p $(dir $@) |
| 45 |
$(QUIET_SPARSE) $(SPARSEFLAGS) $< |
| 46 |
$(QUIET_CC) -o $@ -c $(CFLAGS) $< |
| 47 |
|
| 48 |
all: $(BIN) |
| 49 |
|
| 50 |
$(BIN): $(call OBJS,$(SRCS)) |
| 51 |
$(QUIET_CC) $(CFLAGS) -o $(BIN) $(call OBJS,$(SRCS)) $(LDFLAGS) |
| 52 |
|
| 53 |
install: all |
| 54 |
install -d -o 0 -g 0 -m 755 $(PREFIX)/bin/ |
| 55 |
install -o 0 -g 0 -m 755 $(BIN) $(PREFIX)/bin/ |
| 56 |
install -d -o 0 -g 0 -m 755 $(PREFIX)/man/man1/ |
| 57 |
install -o 0 -g 0 -m 644 $(BIN).1 $(PREFIX)/man/man1/ |
| 58 |
|
| 59 |
clean: |
| 60 |
-rm -Rf obj dep *.orig *.rej *~ |
| 61 |
|
| 62 |
distclean: clean |
| 63 |
-rm -f *.fw $(BIN) |