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

OBJECTS := config.o userinfo.o newpid.o do_all_config.o
SOURCES := $(patsubst %.o,%.c,$(OBJECTS)) annex.h

.SUFFIXES:

%.o: %.c
	gcc -c $< -I..

annex.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): annex.h hopman.h

#-----------------------------------------------------

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

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

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

print_objs:
	@echo $(OBJECTS)

print_srcs:
	@echo $(SOURCES)

print_deps:
	@echo $(SOURCES) hopman.h
