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