| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
IDIR = ./src |
| 12 |
CC = gcc |
| 13 |
CFLAGS = -I$(IDIR) |
| 14 |
|
| 15 |
ODIR = examples/ |
| 16 |
LDIR = ./target/debug/ |
| 17 |
LDIR-RELEASE = ./target/release/ |
| 18 |
|
| 19 |
LIBS = -lsysinfo -lpthread |
| 20 |
|
| 21 |
_DEPS = sysinfo.h |
| 22 |
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS)) |
| 23 |
|
| 24 |
_OBJ = simple.o |
| 25 |
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ)) |
| 26 |
|
| 27 |
|
| 28 |
simple: $(OBJ) |
| 29 |
@echo "Compiling in debug mode" |
| 30 |
cargo rustc --features=c-interface --crate-type cdylib |
| 31 |
gcc -o $@ $^ $(CFLAGS) -L$(LDIR) $(LIBS) |
| 32 |
|
| 33 |
release: $(OBJ) |
| 34 |
@echo "Compiling in release mode" |
| 35 |
cargo rustc --features=c-interface --release --crate-type cdylib |
| 36 |
gcc -o simple $^ $(CFLAGS) -L$(LDIR-RELEASE) $(LIBS) |
| 37 |
|
| 38 |
$(ODIR)/%.o: %.c $(DEPS) |
| 39 |
$(CC) -c -o $@ $< $(CFLAGS) |
| 40 |
|
| 41 |
.PHONY: simple |
| 42 |
|
| 43 |
clean: |
| 44 |
@echo "Cleaning mess" |
| 45 |
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~ |