forked from stamourv/picobit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
89 lines (70 loc) · 2.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Makefile for a Linux or OSX platform
# Guy Turcotte December 2017
#Compiler and Linker
CC := gcc
#The Target Binary Program
TARGET := picobit-vm
#The Directories, Source, Includes, Objects, Binary and Resources
SRCDIR := main
INCDIR := main/include
BUILDDIR := obj
TARGETDIR := bin
SRCEXT := c
DEPEXT := d
OBJEXT := o
#Flags, Libraries and Includes
CFLAGS := -Wall -O3 -std=gnu99
LIB :=
INC := -I$(INCDIR)
INCDEP := -I$(INCDIR)
#---------------------------------------------------------------------------------
#DO NOT EDIT BELOW THIS LINE
#---------------------------------------------------------------------------------
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))
#Default Make
all: resources $(TARGETDIR)/$(TARGET) compiler
#Remake
remake: cleaner all
run:
$(TARGETDIR)/$(TARGET) -T
#Copy Resources from Resources Directory to Target Directory
resources: directories .primitives.p
#Make the Directories
directories:
@mkdir -p $(TARGETDIR)
@mkdir -p $(BUILDDIR)
#Clean only Objecst
clean:
@$(RM) -f $(BUILDDIR)/*
#Full Clean, Objects and Binaries
cleaner: clean
@$(RM) -f $(TARGETDIR)/*
#Pull in dependency info for *existing* .o files
-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT))
#Link
$(TARGETDIR)/$(TARGET): $(OBJECTS)
$(CC) -o $(TARGETDIR)/$(TARGET) $^ $(LIB)
#Compile
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
@$(CC) $(CFLAGS) $(INCDEP) -MM $(SRCDIR)/$*.$(SRCEXT) > $(BUILDDIR)/$*.$(DEPEXT)
@cp -f $(BUILDDIR)/$*.$(DEPEXT) $(BUILDDIR)/$*.$(DEPEXT).tmp
@sed -e 's|.*:|$(BUILDDIR)/$*.$(OBJEXT):|' < $(BUILDDIR)/$*.$(DEPEXT).tmp > $(BUILDDIR)/$*.$(DEPEXT)
@sed -e 's/.*://' -e 's/\\$$//' < $(BUILDDIR)/$*.$(DEPEXT).tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $(BUILDDIR)/$*.$(DEPEXT)
@rm -f $(BUILDDIR)/$*.$(DEPEXT).tmp
primitive-gen = gawk -f scripts/scanner.awk -f scripts/primitive-$(1).awk .primitives.p >$(2)
.primitives.p: $(SOURCES)
rm -f $@
for object in $(SOURCES); do \
gcc -E -DNO_PRIMITIVE_EXPAND $(CFLAGS) $(INC) \
$$object -o - >>$@; \
done
$(call primitive-gen,headergen,main/include/gen.primitives.h)
$(call primitive-gen,schemegen,compiler/gen.primitives.rkt)
$(call primitive-gen,dispatchgen,main/include/gen.dispatch.h)
compiler:
raco make compiler/picobit.rkt
#Non-File Targets
.PHONY: all run remake clean cleaner resources compiler