50 lines
1.3 KiB
Makefile
50 lines
1.3 KiB
Makefile
CC = gcc
|
|
CFLAGS = -Wall -Wextra -std=c99 -Isrc -Isrc/miniz -Isrc/microtar
|
|
CFLAGS_MINIZ = -Wall -Wextra -std=c99 -D_POSIX_C_SOURCE=200112L -Isrc -Isrc/miniz -Isrc/microtar -Wno-unused-function -Wno-implicit-function-declaration
|
|
LIBS = -lm
|
|
LIBS_STATIC = -static -lm
|
|
ARCH = $(shell uname -m)
|
|
TARGET = build/otp-$(ARCH)
|
|
SOURCES = $(wildcard src/*.c)
|
|
MINIZ_SOURCES = $(wildcard src/miniz/*.c)
|
|
MICROTAR_SOURCES = $(wildcard src/microtar/*.c)
|
|
OBJS = $(SOURCES:.c=.o)
|
|
MINIZ_OBJS = $(MINIZ_SOURCES:.c=.o)
|
|
MICROTAR_OBJS = $(MICROTAR_SOURCES:.c=.o)
|
|
ALL_OBJS = $(OBJS) $(MINIZ_OBJS) $(MICROTAR_OBJS)
|
|
|
|
# Default build target
|
|
$(TARGET): $(ALL_OBJS)
|
|
@mkdir -p build
|
|
$(CC) $(CFLAGS) -o $(TARGET) $(ALL_OBJS) $(LIBS)
|
|
@rm -f $(ALL_OBJS)
|
|
|
|
# Static linking target
|
|
static: $(ALL_OBJS)
|
|
@mkdir -p build
|
|
$(CC) $(CFLAGS) -o $(TARGET) $(ALL_OBJS) $(LIBS_STATIC)
|
|
@rm -f $(ALL_OBJS)
|
|
|
|
# Compile main source files with full warnings
|
|
src/%.o: src/%.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
# Compile miniz library files with reduced warnings
|
|
src/miniz/%.o: src/miniz/%.c
|
|
$(CC) $(CFLAGS_MINIZ) -c $< -o $@
|
|
|
|
# Compile microtar library files normally
|
|
src/microtar/%.o: src/microtar/%.c
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
clean:
|
|
rm -f $(OBJS) src/*.o build/otp-* *.pad *.state
|
|
|
|
install:
|
|
sudo cp $(TARGET) /usr/local/bin/otp
|
|
|
|
uninstall:
|
|
sudo rm -f /usr/local/bin/otp
|
|
|
|
.PHONY: clean install uninstall static
|