
VPATH := ..
# VPATH = .. allows GNU make find hopman.h in parent directory

OBJECTS := partition.o init_list.o inot.o sigfd.o hotplug_partition.o \
mountpoints.o devpath.o readwrite.o sysfs.o

SOURCES := $(patsubst %.o,%.c,$(OBJECTS)) watch.h

.SUFFIXES:

%.o: %.c
	gcc -c $< -I.. $(CFLAGS)

watch.a: $(OBJECTS)
	ar -rcs $@ $^

.NOTPARALLEL:
# Race condition may happen when making archive file annex.a
# The file is likely to be corrupted if 2 jobs write it in the same time

$(OBJECTS): watch.h hopman.h

#-----------------------------------------------------
.PHONY: clean cleanall print_srcs print_objs print_deps
.SILENT: print_objs print_srcs print_deps

clean:
	@rm -vf $(wildcard *.o) $(wildcard *~)

cleanall:
	@rm -vf $(wildcard *.o) $(wildcard *~) watch.a

print_objs:
	@echo $(OBJECTS)

print_srcs:
	@echo $(SOURCES)

print_deps:
	@echo $(SOURCES) hopman.h
