# # Roo/E, the Kangaroo Punch Portable GUI Toolkit # Copyright (C) 2022 Scott Duensing # # http://kangaroopunch.com # # # This file is part of Roo/E. # # Roo/E is free software: you can redistribute it and/or modify it under the # terms of the GNU Affero General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) # any later version. # # Roo/E is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU Affero General Public License # along with Roo/E. If not, see . # BACKEND=DJGPP #BACKEND=GRX # General CC = gcc LD = gcc RM = rm -f RMDIR = rm -rf INSTALL = install DEBUG = -g ## CHANGE THIS ## TARGET = roo_e SRCDIR = . OBJDIR = obj BINDIR = bin ## CHANGE THIS ## # CFLAGS, LDFLAGS, CPPFLAGS, PREFIX can be overriden on CLI CFLAGS := $(DEBUG) CFLAGS += -I$(SRCDIR)/shared -I$(SRCDIR)/roo_e/src CPPFLAGS := LDFLAGS := LDLIBS := PREFIX := TARGET_ARCH := # DJGPP ifeq ($(BACKEND),DJGPP) $(info Building DJGPP Backend) CFLAGS += -DBACKEND_DJGPP endif # GRX ifeq ($(BACKEND),GRX) $(info Building GRX Backend) CFLAGS += -DBACKEND_GRX CFLAGS += -I$(SRCDIR)/installed/dos/include LDFLAGS := -L$(SRCDIR)/installed/dos/lib LDLIBS := -lgrx20 -ljpeg -lpng -lz TARGET = grx endif # Compiler Flags ALL_CFLAGS := $(CFLAGS) ALL_CFLAGS += -Wall -Ofast #ALL_CFLAGS += -Wall -O0 -pg # Preprocessor Flags ALL_CPPFLAGS := $(CPPFLAGS) # Linker Flags ALL_LDFLAGS := $(LDFLAGS) ALL_LDLIBS := $(LDLIBS) -lc # Source, Binaries, Dependencies SRC := $(shell find $(SRCDIR)/roo_e/src -type f -name '*.c') SRC += $(shell find $(SRCDIR)/test/src -type f -name '*.c') OBJ := $(patsubst $(SRCDIR)/%,$(OBJDIR)/%,$(SRC:.c=.o)) DEP := $(OBJ:.o=.d) BIN := $(BINDIR)/$(TARGET) -include $(DEP) #$(info [${SRC}]) #$(info [${OBJ}]) # Verbosity Control, ala automake V = 0 # Verbosity for CC REAL_CC := $(CC) CC_0 = @echo "CC $<"; $(REAL_CC) CC_1 = $(REAL_CC) CC = $(CC_$(V)) # Verbosity for LD REAL_LD := $(LD) LD_0 = @echo "LD $@"; $(REAL_LD) LD_1 = $(REAL_LD) LD = $(LD_$(V)) # Verbosity for RM REAL_RM := $(RM) RM_0 = @echo "Cleaning..."; $(REAL_RM) RM_1 = $(REAL_RM) RM = $(RM_$(V)) # Verbosity for RMDIR REAL_RMDIR := $(RMDIR) RMDIR_0 = @$(REAL_RMDIR) RMDIR_1 = $(REAL_RMDIR) RMDIR = $(RMDIR_$(V)) # Build Rules .PHONY: clean .DEFAULT_GOAL := all all: setup $(BIN) setup: dir remake: clean all dir: @mkdir -p $(OBJDIR) @mkdir -p $(BINDIR) $(BIN): $(OBJ) $(LD) $(ALL_LDFLAGS) $^ $(ALL_LDLIBS) -o $@ $(OBJDIR)/%.o: $(SRCDIR)/%.c $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -c -MMD -MP -o $@ $< install: $(BIN) $(INSTALL) -d $(PREFIX)/bin $(INSTALL) $(BIN) $(PREFIX)/bin clean: $(RM) $(OBJ) $(DEP) $(BIN) $(RMDIR) $(OBJDIR) $(BINDIR) 2> /dev/null; true