51 lines
1.5 KiB
Makefile
51 lines
1.5 KiB
Makefile
#
|
|
# Makefile
|
|
#
|
|
|
|
BDIR = ./build
|
|
SDIR = ./src
|
|
CWD := $(shell pwd)
|
|
|
|
.PHONY: build clean all prepare glacier gpkg
|
|
|
|
include config.mk
|
|
|
|
all: prepare glacier gpkg
|
|
@echo "Build completed successfully."
|
|
|
|
prepare:
|
|
mkdir -p $(BDIR)
|
|
mkdir -p $(BDIR)/bin
|
|
mkdir -p $(BDIR)/etc
|
|
mkdir -p $(BDIR)/include
|
|
mkdir -p $(BDIR)/scripts
|
|
cp -f $(CWD)/include/common.h $(BDIR)/include/
|
|
|
|
# First compile the common functionality
|
|
common.o: $(SDIR)/common.c
|
|
$(CC) -c $(SDIR)/common.c -o $(BDIR)/common.o $(CFLAGS) $(LDFLAGS)
|
|
|
|
glacier_common.o: $(SDIR)/glacier_common.c $(SDIR)/glacier_common.h
|
|
$(CC) -c $(SDIR)/glacier_common.c -o $(BDIR)/glacier_common.o $(CFLAGS) $(LDFLAGS)
|
|
|
|
runtime_functions.o: $(SDIR)/runtime_functions.c $(SDIR)/runtime_functions.h
|
|
$(CC) -c $(SDIR)/runtime_functions.c -o $(BDIR)/runtime_functions.o $(CFLAGS) $(LDFLAGS)
|
|
|
|
# Now compile the actual executables
|
|
glacier: common.o glacier_common.o runtime_functions.o $(SDIR)/glacier.c
|
|
$(CC) $(SDIR)/glacier.c $(BDIR)/common.o $(BDIR)/glacier_common.o $(BDIR)/runtime_functions.o -o $(BDIR)/bin/glacier $(CFLAGS) $(LDFLAGS) $(LIBFLAGS)
|
|
chmod +x $(BDIR)/bin/glacier
|
|
|
|
gpkg: common.o glacier_common.o runtime_functions.o $(SDIR)/gpkg.c
|
|
$(CC) $(SDIR)/gpkg.c $(BDIR)/common.o $(BDIR)/glacier_common.o $(BDIR)/runtime_functions.o -o $(BDIR)/bin/gpkg $(CFLAGS) $(LDFLAGS) $(LIBFLAGS)
|
|
chmod +x $(BDIR)/bin/gpkg
|
|
|
|
install: all
|
|
mkdir -p $(BDIR)/scripts
|
|
cp -r $(SDIR)/../scripts/install.sh $(BDIR)/scripts/
|
|
chmod +x $(BDIR)/scripts/install.sh
|
|
cd $(BDIR)/scripts && ./install.sh
|
|
|
|
clean:
|
|
rm -rvf $(BDIR)
|