PROJECTNAME=nstrophy
VERSION=0.0

#DB= -ggdb
OPT= -O3

WARNINGS=-Wall -Wextra -Wno-strict-overflow -std=c99 -Wpedantic

PREFIX=/usr
BINDIR=$(PREFIX)/bin
MANDIR=$(PREFIX)/share/man/man1

CC=/usr/bin/gcc
LD=$(CC)

#INCLUDES = 

#LIBDIRS = 
LIBS = -lm -lfftw3 -lfftw3_threads


override LDFLAGS +=$(LIBDIRS)$(LIBS)
override CFLAGS +=$(INCLUDES)$(DB)

override CFLAGS +=$(OPT) $(WARNINGS)

BUILDDIR=./build
SRCDIR=./src

OBJS=$(patsubst %.c,%.o,$(wildcard $(SRCDIR)/*.c))

all:	dist

$(PROJECTNAME):	$(OBJS)
	$(LD) -o $@ $^ $(LDFLAGS)

%.o:	%.c
	$(CC) -c $(CFLAGS) $< -o $@

dist:	$(PROJECTNAME)
	/bin/rm -rf $(BUILDDIR)
	/bin/mkdir $(BUILDDIR)
	/bin/cp $(PROJECTNAME) $(BUILDDIR)
	@rm -f $(SRCDIR)/*.o
	@rm -f $(PROJECTNAME)

install: dist
	install -Dm755 $(BUILDDIR)/$(PROJECTNAME) $(BINDIR)/$(PROJECTNAME)
	install -Dm644 man/$(PROJECTNAME).1.gz $(MANDIR)/$(PROJECTNAME).1.gz

clean:
	@rm -f $(SRCDIR)/*.o
	@rm -rf $(BUILDDIR)
	@rm -f $(PROJECTNAME)