# This makefile uses features of GNU Make.  Uses bash on Linux.
# Meant to be run from the directory containing the mathc90 directory.

# You may need to change the first line above, and the definitions of CC,
# std_cflags, and CFLAGS below.  If code is to be used in production,
# you will want to change the optimization level.  (For example change
# -ggdb to -O3 or -O2.

CC = gcc
std_cflags=-march=native -pipe -fomit-frame-pointer -fweb\
 -frename-registers -funswitch-loops -fgcse-after-reload
CFLAGS = -W -Wall $(std_cflags) -ggdb

CXOPTS =
#
objc90 = $(patsubst %.c,%.o, $(wildcard *.c))
#
.PHONY: all
all: libmathc90.a
# .PHONY: all
# all: libmathc90.a
.SUFFIXES:
.SUFFIXES: .c .o .h

%.o: %.c $(wildcard *.h)
	$(CC) -c $(CFLAGS) $(COPTS) $*.c $(CXOPTS) &>>compile.msg

libmathc90.a: $(objc90)
	ar r $@ $(objc90) &>>compile.msg

demo: libmathc90.a makefile demo/dr$(code).c
	$(CC) $(CFLAGS) -o demo/dr$(code) demo/dr$(code).c -I. -Idemo\
 -L. -lmathc90 -LM -lm;\
 demo/dr$(code);\
 touch makefile

clean:
	rm -f *.o *.a *.msg
# touch lets one run different codes without make thinking all is up to date
