2018-07-06 18:13:36 +00:00
|
|
|
TARGET = lfs.a
|
|
|
|
ifneq ($(wildcard test.c main.c),)
|
|
|
|
override TARGET = lfs
|
|
|
|
endif
|
2017-02-25 20:31:14 +00:00
|
|
|
|
2018-02-18 20:22:24 +00:00
|
|
|
CC ?= gcc
|
|
|
|
AR ?= ar
|
|
|
|
SIZE ?= size
|
2017-02-25 20:31:14 +00:00
|
|
|
|
|
|
|
SRC += $(wildcard *.c emubd/*.c)
|
|
|
|
OBJ := $(SRC:.c=.o)
|
|
|
|
DEP := $(SRC:.c=.d)
|
|
|
|
ASM := $(SRC:.c=.s)
|
|
|
|
|
2017-03-25 23:11:45 +00:00
|
|
|
TEST := $(patsubst tests/%.sh,%,$(wildcard tests/test_*))
|
2017-03-25 22:02:16 +00:00
|
|
|
|
2017-11-22 20:49:48 +00:00
|
|
|
SHELL = /bin/bash -o pipefail
|
|
|
|
|
2017-02-25 20:31:14 +00:00
|
|
|
ifdef DEBUG
|
2018-01-29 17:30:53 +00:00
|
|
|
override CFLAGS += -O0 -g3
|
2017-02-25 20:31:14 +00:00
|
|
|
else
|
2018-01-29 17:30:53 +00:00
|
|
|
override CFLAGS += -Os
|
2017-02-25 20:31:14 +00:00
|
|
|
endif
|
|
|
|
ifdef WORD
|
2018-01-29 17:30:53 +00:00
|
|
|
override CFLAGS += -m$(WORD)
|
2017-02-25 20:31:14 +00:00
|
|
|
endif
|
2018-01-29 17:30:53 +00:00
|
|
|
override CFLAGS += -I.
|
2018-09-26 15:11:40 +00:00
|
|
|
override CFLAGS += -std=c99 -Wall -pedantic
|
|
|
|
override CFLAGS += -Wshadow -Wunused-parameter -Wjump-misses-init
|
2017-02-25 20:31:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
all: $(TARGET)
|
|
|
|
|
|
|
|
asm: $(ASM)
|
|
|
|
|
|
|
|
size: $(OBJ)
|
|
|
|
$(SIZE) -t $^
|
|
|
|
|
2017-03-25 23:11:45 +00:00
|
|
|
.SUFFIXES:
|
2018-04-08 22:26:03 +00:00
|
|
|
test: test_format test_dirs test_files test_seek test_truncate \
|
|
|
|
test_interspersed test_alloc test_paths test_orphan test_move test_corrupt
|
2018-07-06 18:13:36 +00:00
|
|
|
@rm test.c
|
2017-03-25 23:11:45 +00:00
|
|
|
test_%: tests/test_%.sh
|
2018-07-06 18:13:36 +00:00
|
|
|
|
2017-11-16 23:54:44 +00:00
|
|
|
ifdef QUIET
|
2018-01-29 18:54:48 +00:00
|
|
|
@./$< | sed -n '/^[-=]/p'
|
2017-11-16 23:54:44 +00:00
|
|
|
else
|
2017-03-25 23:11:45 +00:00
|
|
|
./$<
|
2017-11-16 23:54:44 +00:00
|
|
|
endif
|
2017-03-25 22:02:16 +00:00
|
|
|
|
2017-02-25 20:31:14 +00:00
|
|
|
-include $(DEP)
|
|
|
|
|
2018-07-06 18:13:36 +00:00
|
|
|
lfs: $(OBJ)
|
2017-02-25 20:31:14 +00:00
|
|
|
$(CC) $(CFLAGS) $^ $(LFLAGS) -o $@
|
|
|
|
|
|
|
|
%.a: $(OBJ)
|
|
|
|
$(AR) rcs $@ $^
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) -c -MMD $(CFLAGS) $< -o $@
|
|
|
|
|
|
|
|
%.s: %.c
|
|
|
|
$(CC) -S $(CFLAGS) $< -o $@
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(TARGET)
|
|
|
|
rm -f $(OBJ)
|
|
|
|
rm -f $(DEP)
|
|
|
|
rm -f $(ASM)
|