1# Copyright 2019, Data61
2# Commonwealth Scientific and Industrial Research Organisation (CSIRO)
3# ABN 41 687 119 230.
4#
5# This software may be distributed and modified according to the terms of
6# the GNU General Public License version 2. Note that NO WARRANTY is provided.
7# See "LICENSE_GPLv2.txt" for details.
8#
9# @TAG(DATA61_GPL)
10#
11
12NAME=sumofn
13
14SRC=SumOfN.cogent
15
16LIBGUM=$(shell cogent --libgum-dir)
17
18ACFILES=main.ac
19
20PP=$(ACFILES:.ac=_pp.ac)
21PPINFER=$(ACFILES:.ac=_pp_inferred.c)
22
23ABSDIR=./abstract
24
25OBJ=$(PPINFER:.c=.o)
26
27CFLAGS+=-I. -I$(LIBGUM) -I$(LIBGUM)/gum/anti -std=gnu99
28
29.PHONY: default clean gen-anti test
30.SECONDARY:
31
32default: all
33
34all: gen-anti $(OBJ)
35	$(CC) -o $(NAME) $(OBJ)
36
37test: gen-anti $(OBJ)
38
39$(OBJ): $(PPINFER)
40
41gen-anti:
42	mkdir -p $(ABSDIR)
43	cogent $(SRC) -g -Od -ogenerated --fno-fncall-as-macro --ffunc-purity-attr \
44                --infer-c-types="$(AHFILES)" \
45                --Wno-warn --infer-c-funcs="$(ACFILES)" \
46                --cpp-args="\$$CPPIN -o \$$CPPOUT -E -P $(CFLAGS)" \
47                --ext-types=types.cfg \
48                --entry-funcs=entrypoints.cfg \
49
50clean:
51	rm -f $(COUTPUT) $(HOUTPUT) $(PP) $(PPINFER) $(OBJ)
52	rm -rf generated.h generated.c
53	rm -f $(ABSDIR)/*.h
54	rm -rf $(ABSDIR)
55	rm -f $(NAME)
56