Better separate compilation

This commit is contained in:
Adrien Bourmault 2021-04-10 22:03:38 +02:00
parent 9f57a59f18
commit ab780ea237
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
2 changed files with 22 additions and 13 deletions

View File

@ -20,29 +20,38 @@
#=----------------------------------------------------------------------------=# #=----------------------------------------------------------------------------=#
.PHONY: all clean .PHONY: all clean
.DEFAULT_GOAL: all
CCOPTS=-pthread -fPIC -fwrapv -Wall -fno-strict-aliasing CCOPTS=-pthread -fPIC -fwrapv -Wall -fno-strict-aliasing
CCFLAGS=-I /usr/include/python3.9 CCFLAGS=-I /usr/include/python3.9
LDFLAGS=-lpython3.9 -lpthread -lm -lutil -ldl LDFLAGS=-lpython3.9 -lpthread -lm -lutil -ldl
BINDIR=../bin
DEPS=main.c scheduler.c server.c localthread.c DYNLIBS= $(BINDIR)/scheduler.so $(BINDIR)/server.so $(BINDIR)/localthread.so
gem-graph-server: $(DEPS) # ---- General recipes ------------------------------------------------------- #
$(CC) $(CCOPTS) $(CCFLAGS) -o $@ $(DEPS) $(LDFLAGS)
$(BINDIR)/%.so: %.c
@echo "Building dynamic library $@"
@$(CC) --shared $(CCOPTS) $(CCFLAGS) -o $@ $<
%.c: %.py %.c: %.py
cython3 $< -o $@ @echo "Cythonizing $< to $@"
@cython3 $< -o $@
# ---- Main recipe ----------------------------------------------------------- #
$(BINDIR)/gem-graph-server: main.c $(DYNLIBS)
@echo "Building program to $@"
@$(CC) $(CCOPTS) $(CCFLAGS) -o $@ $< $(LDFLAGS)
@echo "Success!"
main.c: main.py main.c: main.py
cython3 $< -o $@ --embed @echo "Cythonizing main file to $@"
@cython3 $< -o $@ --embed
# ---- Misc recipes ---------------------------------------------------------- #
clean: clean:
rm -rf *.c *.o gem-graph-server test rm -rf *.c ../bin/*
all: gem-graph-server all: $(BINDIR)/gem-graph-server
test: test.c
$(CC) $(CCOPTS) $(CCFLAGS) -o $@ $< $(LDFLAGS)
test.c: test.py
cython3 $< --embed

Binary file not shown.